Having textured particles seems like a very important thing to have. It’s been a slog to get there though. I really don’t know why it was so difficult.I’ve had particles spraying out in pretty patterns for a while, but I couldn’t figure out why I couldn’t get textures on the sprites. The first issue was that I had a planned holiday. I was going to spend a week visiting family. So I set up a laptop for development work. I made sure I had everything up to date and that Maratis ran smooth enough on it.
I failed to notice the supported version of OpenGL.
The Intel i915 chip meant that it only supported OpenGL 1.4.
OpenGL prior to 1.5 would only support one texture coordinate per point.
So yes. I got one texel per particle.
While trying to figure out what I was doing wrong, I made some headway in terms of allowing the particle system to not only have point sprites. As I’ve spent all this time trying to get point sprites to work, you might think “why bother”. Well, the thing is, point sprites are very limited. You can’t really do arbitrary rotations per particle, from what I can see. You can’t specify different sizes per sprite. You can’t have animated textures. But what you can have is a great many particles, very very cheaply. I really have to start tying the profiler into this, but I’m pretty sure that, even with my pretty simple calculations in the update, it’s still more likely to be a bottleneck than the rendering. Hopefully soon I will have empirical evidence as to what the performance is like. Before I do that, though, I think it might be a good idea to know what sort of numbers I would aim for. I will probably start thinking about that within the next week.
It turned out that I did end up that my netbook, which I also had with me, did support OpenGL 2.1, unfortunate that I didn’t realise until the last day, after I’d spent a day reformatting and setting it up.
Anyway. I did finally make some breakthroughs when I got back home. It turns out that, for some reason, I cannot specify a colour array for a vertex array of point sprites. I was either getting it drawing everything in black, or not drawing at all. Things started working a bit better when I removed the colour array altogether. I’m not entirely sure what I can do in this case, because, with the way things are set up, I need the colour array to hide the inactive particles.
But, I have textures. And I made a little video to show it. So that’s a start.
What is left to do then? Well, a great deal. As I’ve said, I want to do some profiling. The reason is that potentially I still would like to move the update functionality to the GPU. Any GPU work would not be done any time soon, but need to be considered with any data/design decisions. There’s still the standard billboard quad sprites which need to be implemented, along with extra features for them, like rotations, and growth. Finally there’s the world interaction, I want to be able to block out a room, and get particles to fill it with smoke, then drop an object into it and have the smoke swirl around it. I don’t think that needs a lot of physics work. In fact, I think we can probably get away with AABBs for the most part of world collision, maybe a couple of spheres, and simple sphere collision between particles.
There’s still a lot to do, and unfortunately a lot still to think about and plan, so, while I try to make decisions about some of them I will tidy up the interface, tidy up what’s exposed to the editor, and maybe make some examples of what currently works. See how things go.