Monday, August 24, 2009

Particle Systems, and Pixel Fill vs. Vertex Count

Ok, so here's me just spitting some of my thoughts out. I haven't yet implemented a particle system for my framework just yet, so it's still pretty pertinent.

So! First thing to know about drawing on a graphics card, which anyone who's familiar with rendering will know, is that graphics cards deal better with a few large chunks of draw data, rather than a lot of small chunks. So with a particle system of 10,000 particles, there's no way you want to have 10,000 different draw calls. So instead, you zip them all up into a single vertex buffer, and do some magic on the graphics card.

This is fantastically simple for billboards... but when I talk about particle systems, I'm including static particles, like grass, plant fronds, leaves, and possibly even rocks and ambient objects. As you can see, that gets a lot more complicated really fast. Complex geometry, abstract orientation, possibly even procedural animation!

An image (Oblivion) illustrating a scene full to the -brim- with static particles.

It might just be best to keep static particles at least mildly separate from the dynamic particles, simply because of how different they are from eachother. But I'll see just how re-usable the code is when I get there!

And as a note, or rather, the thought that inspired this entire post :/ developers actually spend the extra vertices on rain to do individual droplets! Evidently, it's faster that way, since they don't have to worry about all the transparent pixels that would get drawn/discarded using transparent textures. Fascinating how technology changes, isn't it?