particle_system.cpp 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638
  1. /*
  2. * Copyright 2011-2017 Branimir Karadzic. All rights reserved.
  3. * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
  4. */
  5. #include <bgfx/bgfx.h>
  6. #include <bgfx/embedded_shader.h>
  7. #include "particle_system.h"
  8. #include "../bgfx_utils.h"
  9. #include <bx/easing.h>
  10. #include <bx/crtimpl.h>
  11. #include <bx/handlealloc.h>
  12. #include "vs_particle.bin.h"
  13. #include "fs_particle.bin.h"
  14. static const bgfx::EmbeddedShader s_embeddedShaders[] =
  15. {
  16. BGFX_EMBEDDED_SHADER(vs_particle),
  17. BGFX_EMBEDDED_SHADER(fs_particle),
  18. BGFX_EMBEDDED_SHADER_END()
  19. };
  20. static const bx::EaseFn s_easeFunc[] =
  21. {
  22. bx::easeLinear,
  23. bx::easeInQuad,
  24. bx::easeOutQuad,
  25. bx::easeInOutQuad,
  26. bx::easeOutInQuad,
  27. bx::easeInCubic,
  28. bx::easeOutCubic,
  29. bx::easeInOutCubic,
  30. bx::easeOutInCubic,
  31. bx::easeInQuart,
  32. bx::easeOutQuart,
  33. bx::easeInOutQuart,
  34. bx::easeOutInQuart,
  35. bx::easeInQuint,
  36. bx::easeOutQuint,
  37. bx::easeInOutQuint,
  38. bx::easeOutInQuint,
  39. bx::easeInSine,
  40. bx::easeOutSine,
  41. bx::easeInOutSine,
  42. bx::easeOutInSine,
  43. bx::easeInExpo,
  44. bx::easeOutExpo,
  45. bx::easeInOutExpo,
  46. bx::easeOutInExpo,
  47. bx::easeInCirc,
  48. bx::easeOutCirc,
  49. bx::easeInOutCirc,
  50. bx::easeOutInCirc,
  51. bx::easeInElastic,
  52. bx::easeOutElastic,
  53. bx::easeInOutElastic,
  54. bx::easeOutInElastic,
  55. bx::easeInBack,
  56. bx::easeOutBack,
  57. bx::easeInOutBack,
  58. bx::easeOutInBack,
  59. bx::easeInBounce,
  60. bx::easeOutBounce,
  61. bx::easeInOutBounce,
  62. bx::easeOutInBounce,
  63. };
  64. BX_STATIC_ASSERT(BX_COUNTOF(s_easeFunc) == bx::Easing::Count);
  65. struct PosColorTexCoord0Vertex
  66. {
  67. float m_x;
  68. float m_y;
  69. float m_z;
  70. uint32_t m_abgr;
  71. float m_u;
  72. float m_v;
  73. float m_blend;
  74. float m_angle;
  75. static void init()
  76. {
  77. ms_decl
  78. .begin()
  79. .add(bgfx::Attrib::Position, 3, bgfx::AttribType::Float)
  80. .add(bgfx::Attrib::Color0, 4, bgfx::AttribType::Uint8, true)
  81. .add(bgfx::Attrib::TexCoord0, 4, bgfx::AttribType::Float)
  82. .end();
  83. }
  84. static bgfx::VertexDecl ms_decl;
  85. };
  86. bgfx::VertexDecl PosColorTexCoord0Vertex::ms_decl;
  87. struct Particle
  88. {
  89. float start[3];
  90. float end[2][3];
  91. float blendStart;
  92. float blendEnd;
  93. float scaleStart;
  94. float scaleEnd;
  95. uint32_t rgba[5];
  96. float life;
  97. float lifeSpan;
  98. };
  99. struct ParticleSort
  100. {
  101. float dist;
  102. uint32_t idx;
  103. };
  104. inline uint32_t toAbgr(const float* _rgba)
  105. {
  106. return 0
  107. | (uint8_t(_rgba[0]*255.0f)<< 0)
  108. | (uint8_t(_rgba[1]*255.0f)<< 8)
  109. | (uint8_t(_rgba[2]*255.0f)<<16)
  110. | (uint8_t(_rgba[3]*255.0f)<<24)
  111. ;
  112. }
  113. inline uint32_t toAbgr(float _rr, float _gg, float _bb, float _aa)
  114. {
  115. return 0
  116. | (uint8_t(_rr*255.0f)<< 0)
  117. | (uint8_t(_gg*255.0f)<< 8)
  118. | (uint8_t(_bb*255.0f)<<16)
  119. | (uint8_t(_aa*255.0f)<<24)
  120. ;
  121. }
  122. struct Emitter
  123. {
  124. void create(EmitterShape::Enum _shape, EmitterDirection::Enum _direction, uint32_t _maxParticles);
  125. void destroy();
  126. void reset()
  127. {
  128. m_num = 0;
  129. }
  130. void update(float _dt)
  131. {
  132. uint32_t num = m_num;
  133. for (uint32_t ii = 0; ii < num; ++ii)
  134. {
  135. Particle& particle = m_particles[ii];
  136. particle.life += _dt * 1.0f/particle.lifeSpan;
  137. if (particle.life > 1.0f)
  138. {
  139. if (ii != num-1)
  140. {
  141. memcpy(&particle, &m_particles[num-1], sizeof(Particle) );
  142. --ii;
  143. }
  144. --num;
  145. }
  146. }
  147. m_num = num;
  148. if (0 < m_uniforms.m_particlesPerSecond)
  149. {
  150. spawn(_dt);
  151. }
  152. }
  153. void spawn(float _dt)
  154. {
  155. float mtx[16];
  156. bx::mtxSRT(mtx
  157. , 1.0f, 1.0f, 1.0f
  158. , m_uniforms.m_angle[0], m_uniforms.m_angle[1], m_uniforms.m_angle[2]
  159. , m_uniforms.m_position[0], m_uniforms.m_position[1], m_uniforms.m_position[2]
  160. );
  161. const float timePerParticle = 1.0f/m_uniforms.m_particlesPerSecond;
  162. m_dt += _dt;
  163. const uint32_t numParticles = uint32_t(m_dt / timePerParticle);
  164. m_dt -= numParticles * timePerParticle;
  165. float time = 0.0f;
  166. for (uint32_t ii = 0
  167. ; ii < numParticles && m_num < m_max
  168. ; ++ii
  169. )
  170. {
  171. Particle& particle = m_particles[m_num];
  172. m_num++;
  173. const float up[3] = { 0.0f, 1.0f, 0.0f };
  174. float pos[3];
  175. switch (m_shape)
  176. {
  177. default:
  178. case EmitterShape::Sphere:
  179. bx::randUnitSphere(pos, &m_rng);
  180. break;
  181. case EmitterShape::Hemisphere:
  182. bx::randUnitHemisphere(pos, &m_rng, up);
  183. break;
  184. case EmitterShape::Circle:
  185. bx::randUnitCircle(pos, &m_rng);
  186. break;
  187. case EmitterShape::Disc:
  188. {
  189. float tmp[3];
  190. bx::randUnitCircle(tmp, &m_rng);
  191. bx::vec3Mul(pos, tmp, bx::frnd(&m_rng) );
  192. }
  193. break;
  194. case EmitterShape::Rect:
  195. pos[0] = bx::frndh(&m_rng);
  196. pos[1] = 0.0f;
  197. pos[2] = bx::frndh(&m_rng);
  198. break;
  199. }
  200. float dir[3];
  201. switch (m_direction)
  202. {
  203. default:
  204. case EmitterDirection::Up:
  205. bx::vec3Move(dir, up);
  206. break;
  207. case EmitterDirection::Outward:
  208. bx::vec3Norm(dir, pos);
  209. break;
  210. }
  211. float start[3];
  212. float end[3];
  213. const float startOffset = bx::flerp(m_uniforms.m_offsetStart[0], m_uniforms.m_offsetStart[1], bx::frnd(&m_rng) );
  214. bx::vec3Mul(start, pos, startOffset);
  215. const float endOffset = bx::flerp(m_uniforms.m_offsetEnd[0], m_uniforms.m_offsetEnd[1], bx::frnd(&m_rng) );
  216. float tmp1[3];
  217. bx::vec3Mul(tmp1, dir, endOffset);
  218. bx::vec3Add(end, tmp1, start);
  219. particle.life = time;
  220. particle.lifeSpan = bx::flerp(m_uniforms.m_lifeSpan[0], m_uniforms.m_lifeSpan[1], bx::frnd(&m_rng) );
  221. float gravity[3] = { 0.0f, -9.81f * m_uniforms.m_gravityScale * bx::fsq(particle.lifeSpan), 0.0f };
  222. bx::vec3MulMtx(particle.start, start, mtx);
  223. bx::vec3MulMtx(particle.end[0], end, mtx);
  224. bx::vec3Add(particle.end[1], particle.end[0], gravity);
  225. memcpy(particle.rgba, m_uniforms.m_rgba, BX_COUNTOF(m_uniforms.m_rgba)*sizeof(uint32_t) );
  226. particle.blendStart = bx::flerp(m_uniforms.m_blendStart[0], m_uniforms.m_blendStart[1], bx::frnd(&m_rng) );
  227. particle.blendStart = bx::flerp(m_uniforms.m_blendEnd[0], m_uniforms.m_blendEnd[1], bx::frnd(&m_rng) );
  228. particle.scaleStart = bx::flerp(m_uniforms.m_scaleStart[0], m_uniforms.m_scaleStart[1], bx::frnd(&m_rng) );
  229. particle.scaleEnd = bx::flerp(m_uniforms.m_scaleEnd[0], m_uniforms.m_scaleEnd[1], bx::frnd(&m_rng) );
  230. time += timePerParticle;
  231. }
  232. }
  233. uint32_t render(const float* _mtxView, const float* _eye, uint32_t _first, ParticleSort* _outSort, PosColorTexCoord0Vertex* _outVertices) const
  234. {
  235. bx::EaseFn easeRgba = s_easeFunc[m_uniforms.m_easeRgba];
  236. bx::EaseFn easePos = s_easeFunc[m_uniforms.m_easePos];
  237. bx::EaseFn easeBlend = s_easeFunc[m_uniforms.m_easeBlend];
  238. bx::EaseFn easeScale = s_easeFunc[m_uniforms.m_easeScale];
  239. for (uint32_t jj = 0, num = m_num; jj < num; ++jj)
  240. {
  241. const Particle& particle = m_particles[jj];
  242. const float ttPos = easePos(particle.life);
  243. const float ttScale = easeScale(particle.life);
  244. const float ttBlend = bx::fsaturate(easeBlend(particle.life) );
  245. const float ttRgba = bx::fsaturate(easeRgba(particle.life) );
  246. float p0[3];
  247. bx::vec3Lerp(p0, particle.start, particle.end[0], ttPos);
  248. float p1[3];
  249. bx::vec3Lerp(p1, particle.end[0], particle.end[1], ttPos);
  250. float pos[3];
  251. bx::vec3Lerp(pos, p0, p1, ttPos);
  252. const uint32_t current = _first + jj;
  253. ParticleSort& sort = _outSort[current];
  254. float tmp[3];
  255. bx::vec3Sub(tmp, _eye, pos);
  256. sort.dist = bx::fsqrt(bx::vec3Dot(tmp, tmp) );
  257. sort.idx = current;
  258. uint32_t idx = uint32_t(ttRgba*4);
  259. float ttmod = bx::fmod(ttRgba, 0.25f)/0.25f;
  260. uint32_t rgbaStart = particle.rgba[idx];
  261. uint32_t rgbaEnd = particle.rgba[idx+1];
  262. float rr = bx::flerp( ( (uint8_t*)&rgbaStart)[0], ( (uint8_t*)&rgbaEnd)[0], ttmod)/255.0f;
  263. float gg = bx::flerp( ( (uint8_t*)&rgbaStart)[1], ( (uint8_t*)&rgbaEnd)[1], ttmod)/255.0f;
  264. float bb = bx::flerp( ( (uint8_t*)&rgbaStart)[2], ( (uint8_t*)&rgbaEnd)[2], ttmod)/255.0f;
  265. float aa = bx::flerp( ( (uint8_t*)&rgbaStart)[3], ( (uint8_t*)&rgbaEnd)[3], ttmod)/255.0f;
  266. float blend = bx::flerp(particle.blendStart, particle.blendEnd, ttBlend);
  267. float scale = bx::flerp(particle.scaleStart, particle.scaleEnd, ttScale);
  268. uint32_t abgr = toAbgr(rr, gg, bb, aa);
  269. float udir[3] = { _mtxView[0]*scale, _mtxView[4]*scale, _mtxView[8]*scale };
  270. float vdir[3] = { _mtxView[1]*scale, _mtxView[5]*scale, _mtxView[9]*scale };
  271. PosColorTexCoord0Vertex* vertex = &_outVertices[current*4];
  272. bx::vec3Sub(tmp, pos, udir);
  273. bx::vec3Sub(&vertex->m_x, tmp, vdir);
  274. vertex->m_abgr = abgr;
  275. vertex->m_u = 0.0f;
  276. vertex->m_v = 0.0f;
  277. vertex->m_blend = blend;
  278. ++vertex;
  279. bx::vec3Add(tmp, pos, udir);
  280. bx::vec3Sub(&vertex->m_x, tmp, vdir);
  281. vertex->m_abgr = abgr;
  282. vertex->m_u = 1.0f;
  283. vertex->m_v = 0.0f;
  284. vertex->m_blend = blend;
  285. ++vertex;
  286. bx::vec3Add(tmp, pos, udir);
  287. bx::vec3Add(&vertex->m_x, tmp, vdir);
  288. vertex->m_abgr = abgr;
  289. vertex->m_u = 1.0f;
  290. vertex->m_v = 1.0f;
  291. vertex->m_blend = blend;
  292. ++vertex;
  293. bx::vec3Sub(tmp, pos, udir);
  294. bx::vec3Add(&vertex->m_x, tmp, vdir);
  295. vertex->m_abgr = abgr;
  296. vertex->m_u = 0.0f;
  297. vertex->m_v = 1.0f;
  298. vertex->m_blend = blend;
  299. ++vertex;
  300. }
  301. return m_num;
  302. }
  303. EmitterShape::Enum m_shape;
  304. EmitterDirection::Enum m_direction;
  305. float m_dt;
  306. bx::RngMwc m_rng;
  307. EmitterUniforms m_uniforms;
  308. Particle* m_particles;
  309. uint32_t m_num;
  310. uint32_t m_max;
  311. };
  312. void EmitterUniforms::reset()
  313. {
  314. m_position[0] = 0.0f;
  315. m_position[1] = 0.0f;
  316. m_position[2] = 0.0f;
  317. m_angle[0] = 0.0f;
  318. m_angle[1] = 0.0f;
  319. m_angle[2] = 0.0f;
  320. m_particlesPerSecond = 0;
  321. m_offsetStart[0] = 0.0f;
  322. m_offsetStart[1] = 1.0f;
  323. m_offsetEnd[0] = 2.0f;
  324. m_offsetEnd[1] = 3.0f;
  325. m_rgba[0] = 0x00ffffff;
  326. m_rgba[1] = UINT32_MAX;
  327. m_rgba[2] = UINT32_MAX;
  328. m_rgba[3] = UINT32_MAX;
  329. m_rgba[4] = 0x00ffffff;
  330. m_blendStart[0] = 0.8f;
  331. m_blendStart[1] = 1.0f;
  332. m_blendEnd[0] = 0.0f;
  333. m_blendEnd[1] = 0.2f;
  334. m_scaleStart[0] = 0.1f;
  335. m_scaleStart[1] = 0.2f;
  336. m_scaleEnd[0] = 0.3f;
  337. m_scaleEnd[1] = 0.4f;
  338. m_lifeSpan[0] = 1.0f;
  339. m_lifeSpan[1] = 2.0f;
  340. m_gravityScale = 0.0f;
  341. m_easePos = bx::Easing::Linear;
  342. m_easeRgba = bx::Easing::Linear;
  343. m_easeBlend = bx::Easing::Linear;
  344. m_easeScale = bx::Easing::Linear;
  345. }
  346. static int32_t particleSortFn(const void* _lhs, const void* _rhs)
  347. {
  348. const ParticleSort& lhs = *(const ParticleSort*)_lhs;
  349. const ParticleSort& rhs = *(const ParticleSort*)_rhs;
  350. return lhs.dist > rhs.dist ? -1 : 1;
  351. }
  352. struct ParticleSystem
  353. {
  354. void init(bx::AllocatorI* _allocator)
  355. {
  356. m_allocator = _allocator;
  357. #if BX_CONFIG_ALLOCATOR_CRT
  358. if (NULL == _allocator)
  359. {
  360. static bx::CrtAllocator allocator;
  361. m_allocator = &allocator;
  362. }
  363. #endif // BX_CONFIG_ALLOCATOR_CRT
  364. PosColorTexCoord0Vertex::init();
  365. m_num = 0;
  366. s_texColor = bgfx::createUniform("s_texColor", bgfx::UniformType::Int1);
  367. m_particleTexture = loadTexture("textures/particle.ktx");
  368. bgfx::RendererType::Enum type = bgfx::getRendererType();
  369. m_particleProgram = bgfx::createProgram(
  370. bgfx::createEmbeddedShader(s_embeddedShaders, type, "vs_particle")
  371. , bgfx::createEmbeddedShader(s_embeddedShaders, type, "fs_particle")
  372. , true
  373. );
  374. }
  375. void shutdown()
  376. {
  377. bgfx::destroyProgram(m_particleProgram);
  378. bgfx::destroyTexture(m_particleTexture);
  379. bgfx::destroyUniform(s_texColor);
  380. m_allocator = NULL;
  381. }
  382. void update(float _dt)
  383. {
  384. uint32_t numParticles = 0;
  385. for (uint16_t ii = 0, num = m_emitterAlloc.getNumHandles(); ii < num; ++ii)
  386. {
  387. const uint16_t idx = m_emitterAlloc.getHandleAt(ii);
  388. Emitter& emitter = m_emitter[idx];
  389. emitter.update(_dt);
  390. numParticles += emitter.m_num;
  391. }
  392. m_num = numParticles;
  393. }
  394. void render(uint8_t _view, const float* _mtxView, const float* _eye)
  395. {
  396. if (0 != m_num)
  397. {
  398. bgfx::TransientVertexBuffer tvb;
  399. bgfx::TransientIndexBuffer tib;
  400. bgfx::allocTransientBuffers(&tvb
  401. , PosColorTexCoord0Vertex::ms_decl
  402. , m_num*4
  403. , &tib
  404. , m_num*6
  405. );
  406. PosColorTexCoord0Vertex* vertices = (PosColorTexCoord0Vertex*)tvb.data;
  407. ParticleSort* particleSort = (ParticleSort*)BX_ALLOC(m_allocator, m_num*sizeof(ParticleSort) );
  408. uint32_t pos = 0;
  409. for (uint16_t ii = 0, num = m_emitterAlloc.getNumHandles(); ii < num; ++ii)
  410. {
  411. const uint16_t idx = m_emitterAlloc.getHandleAt(ii);
  412. const Emitter& emitter = m_emitter[idx];
  413. pos += emitter.render(_mtxView, _eye, pos, particleSort, vertices);
  414. }
  415. qsort(particleSort
  416. , m_num
  417. , sizeof(ParticleSort)
  418. , particleSortFn
  419. );
  420. uint16_t* indices = (uint16_t*)tib.data;
  421. for (uint32_t ii = 0; ii < m_num; ++ii)
  422. {
  423. const ParticleSort& sort = particleSort[ii];
  424. uint16_t* index = &indices[ii*6];
  425. uint16_t idx = (uint16_t)sort.idx;
  426. index[0] = idx*4+0;
  427. index[1] = idx*4+1;
  428. index[2] = idx*4+2;
  429. index[3] = idx*4+2;
  430. index[4] = idx*4+3;
  431. index[5] = idx*4+0;
  432. }
  433. BX_FREE(m_allocator, particleSort);
  434. bgfx::setState(0
  435. | BGFX_STATE_RGB_WRITE
  436. | BGFX_STATE_ALPHA_WRITE
  437. | BGFX_STATE_DEPTH_TEST_LESS
  438. | BGFX_STATE_CULL_CW
  439. | BGFX_STATE_BLEND_NORMAL
  440. );
  441. bgfx::setVertexBuffer(&tvb);
  442. bgfx::setIndexBuffer(&tib);
  443. bgfx::setTexture(0, s_texColor, m_particleTexture);
  444. bgfx::submit(_view, m_particleProgram);
  445. }
  446. }
  447. EmitterHandle createEmitter(EmitterShape::Enum _shape, EmitterDirection::Enum _direction, uint32_t _maxParticles)
  448. {
  449. EmitterHandle handle = { m_emitterAlloc.alloc() };
  450. if (UINT16_MAX != handle.idx)
  451. {
  452. m_emitter[handle.idx].create(_shape, _direction, _maxParticles);
  453. }
  454. return handle;
  455. }
  456. void updateEmitter(EmitterHandle _handle, const EmitterUniforms* _uniforms)
  457. {
  458. Emitter& emitter = m_emitter[_handle.idx];
  459. if (NULL == _uniforms)
  460. {
  461. emitter.reset();
  462. }
  463. else
  464. {
  465. memcpy(&emitter.m_uniforms, _uniforms, sizeof(EmitterUniforms) );
  466. }
  467. }
  468. void destroyEmitter(EmitterHandle _handle)
  469. {
  470. m_emitter[_handle.idx].destroy();
  471. m_emitterAlloc.free(_handle.idx);
  472. }
  473. bx::AllocatorI* m_allocator;
  474. #define MAX_EMITTERS 64
  475. bx::HandleAllocT<MAX_EMITTERS> m_emitterAlloc;
  476. Emitter m_emitter[MAX_EMITTERS];
  477. bgfx::UniformHandle s_texColor;
  478. bgfx::TextureHandle m_particleTexture;
  479. bgfx::ProgramHandle m_particleProgram;
  480. uint32_t m_num;
  481. };
  482. static ParticleSystem s_ps;
  483. void Emitter::create(EmitterShape::Enum _shape, EmitterDirection::Enum _direction, uint32_t _maxParticles)
  484. {
  485. m_dt = 0.0f;
  486. m_uniforms.reset();
  487. m_shape = _shape;
  488. m_direction = _direction;
  489. m_num = 0;
  490. m_max = _maxParticles;
  491. m_particles = (Particle*)BX_ALLOC(s_ps.m_allocator, m_max*sizeof(Particle) );
  492. }
  493. void Emitter::destroy()
  494. {
  495. BX_FREE(s_ps.m_allocator, m_particles);
  496. m_particles = NULL;
  497. }
  498. void psInit(bx::AllocatorI* _allocator)
  499. {
  500. s_ps.init(_allocator);
  501. }
  502. void psShutdown()
  503. {
  504. s_ps.shutdown();
  505. }
  506. EmitterHandle psCreateEmitter(EmitterShape::Enum _shape, EmitterDirection::Enum _direction, uint32_t _maxParticles)
  507. {
  508. return s_ps.createEmitter(_shape, _direction, _maxParticles);
  509. }
  510. void psUpdateEmitter(EmitterHandle _handle, const EmitterUniforms* _uniforms)
  511. {
  512. s_ps.updateEmitter(_handle, _uniforms);
  513. }
  514. void psDestroyEmitter(EmitterHandle _handle)
  515. {
  516. s_ps.destroyEmitter(_handle);
  517. }
  518. void psUpdate(float _dt)
  519. {
  520. s_ps.update(_dt);
  521. }
  522. void psRender(uint8_t _view, const float* _mtxView, const float* _eye)
  523. {
  524. s_ps.render(_view, _mtxView, _eye);
  525. }