Go to bottom

GPU particles

category: general [glöplog]
What's the best way to create a GPU based particle emitter? I've got a few particles floating around a noise field, but I'm not sure what's the best way to add and remove particles.

BB Image
Coder colors (normal mal) with glow.
added on the 2013-08-15 20:53:34 by xernobyl xernobyl
buy a blender
added on the 2013-08-15 21:06:16 by olivil olivil

Dig through smashs articles, he wrote about it.
added on the 2013-08-15 21:20:11 by revival revival
Use a geometry shader. Every particle should know its type (emitter is a particle type). in the geometry shader emit your Emiter Particle unchanged, and then additionally emit the generated particle of your choice. Use transform feedback / stream out for getting your new particle buffer which you're going to render.
added on the 2013-08-15 23:34:29 by xTr1m xTr1m
So I should simply add (with glBufferSubData) a particle marked as an emitter at the end of the buffer, then I should process the physics of the thingy on the vertex shader, and emit 0 or a bunch of particles on the geometry shader?
added on the 2013-08-15 23:48:41 by xernobyl xernobyl
Yes, use two passes:

1st pass: with a GS: don't emit particles that became dead, emit generated particles and also emit the "emiter particle as well". Using transform feedback you route all emitted particles to a buffer, that buffer has your "live particles", which you can use for your 2nd pass.
2nd pass: use the live particles buffer, transform them in the VS, draw them with the PS.

finally use that live particles buffer as an input for the 1st pass in the next frame. You should ping-pong 2 buffers for this to work efficiently.
added on the 2013-08-16 11:47:26 by xTr1m xTr1m
oh, and of course, don't render your emitter particle in the 2nd pass. simply discard that vertex.
added on the 2013-08-16 11:48:09 by xTr1m xTr1m

Looks like when galaxies formed after the big bang :D
added on the 2013-08-16 14:39:22 by moredhel moredhel
@moredhel I don't know, I wasn't there.
@xTr1m right now I'm doing a for on the GS to emit particles if the particle is an emitter, or I emit none if life's too short. But I'm still not sure on how to add new emitters.
added on the 2013-08-16 14:57:44 by xernobyl xernobyl
add new emitters? use a ranodm is_emissive flag on the particles. maybe you can hide in an unused bit somewhere, so it doesn't blow up the buffer for nonemmissive particles. or maybe you can store a random primitive id somewhere that let's the GS know when to emit some more.
added on the 2013-08-16 15:23:02 by yumeji yumeji
and i just thought... there's a trick needed to output to a second stream while doing the standard rasterizer pipeline at the same. that way you could do it all in one pass i guess. M$ call. :D
added on the 2013-08-16 15:35:11 by yumeji yumeji
What's the best way to create a GPU based particle emitter

GPU particles


Go to top