The bonus section will combine the particle systems with the terrain rendering, but until then, we have no need of any of the previous code.
If you start with a new project, please add a camera component, and create two folders, The technique will use two render targets, of the same size.
When the particle’s life passes a certain value, it dies, and can be reborn again.
The updating of the position and velocity textures is done by using some pixel shaders, similar to how morphing was done in the previous chapter.
Creation of particles is still done by CPU-calls such as: //### As you can see, not a lot of action here.
### Particle Vertex tmp Vertices = Particle Quad. Time Alive); particle Vertices[i] = tmp Vertices; particle Vertices[i 1] = tmp Vertices; particle Vertices[i 2] = tmp Vertices; particle Vertices[i 3] = tmp Vertices; particle Vertices[i 4] = tmp Vertices; particle Vertices[i 5] = tmp Vertices; particle Vertex Buffer.
Set Data(particle Vertices); My thoughts are that maybe I shouldn't create particles that often, maybe there is a way to let the GPU create everything, or maybe I just don't know how you do these stuff.
;) Edit: If I weren't to create particles that often, what is the workaround for still making it look good?
The particles are rendered on in the world where the emitter is initialized.
So I am posting here in hope that you know how a good particle-engine should be designed and if maybe I took the wrong route somewhere.
There is no way to have the GPU create everything (short of using Geometry Shaders which requires SM4.0).
My GPU easily handles 10k particles without breaking a sweat and I wouldn't be surprised if I could add a bunch more.
My problem: Whenever I have a lot of particles created at the same time, my frame rate hates me. A lot of CPU-usage, even though I have minimized it to contain almost only memory operations.