ND2D – Particles GPU vs. CPUOctober 5th, 2011 | Posted by in Experiments | Molehill / Stage3D | ND2D | Talk
A few people where wondering why they can’t control individual particles in the ND2D particlesystem. Let me explain why:
The ParticleSystem2D is built for speed. This means, that everything and really everything for each particle is calculated on the GPU. When you create a system, initially the starting values for each particles are created and uploaded to the GPU. From now on, everything is calculated in shaders based on the current time step. This way ND2D is able to render 10.000 (or even more) particles at 60hz without any CPU usage. The drawback is, that you don’t have control over each particle, but you’ll have a lot of CPU time left for more important stuff. The ParticleSystem2D can be used for effects like rain, fire or water, but you won’t be able to animate a swarm of birds with it. You can play around with the system below, but be careful. Depending on the size of the particles you can display 10.000 at 60hz or nearly freeze your machine. The larger, the slower.
If you want to have control over individual particles, you can use one of the batch nodes provided by ND2D. The Sprite2DCloud or the Sprite2DBatch. With these batch nodes you’re able to move each child, but they are slower, because all the positional information has to be uploaded to the GPU every single frame. When I say slower, I mean that you can still display 1000 (or a lot more) particles alphablended at 60hz. This should be enough for a whole army of kinghts or a fancy mousefollower. Play around with it here:
And if you haven’t installed the new Flash Player 11 that has been released yesterday, grab it here.