Problem with particle system

Hi Guys,

I’m writing a small 3D graphic engine for an school project. It works fine, but i have a little problem with my particle systems. I’m using GL_POINT_SPRITES and GL_POINTS to draw a particle. However, to make the particles look nice, I put a texture on it. But if I don’t disable depth testing, the only thing I get are flying squares.

When I disable depth testing, the particles are looking nice, but they are always drawn on top.

I would like to know if there is any other way to realise a particle system? I’ve tried GL_ALPHA_TESTING but it seems like i have to disable GL_BLEND for that and it doesn’t really work with my code.

greets,
Shelling

Order independant transparency is a complex problem.
You should only disable depthj writes (but keep depth test) when drawing particles, and use blend func GL_SRC_ALPHA GL_ONE for additive transparency (order independant).

Otherwise with classic gl src alpha gl one minus alpha you should sort your particles back to front.
It does not need to be exact, throwing your particles in one of 1000 possible distance bins can be enough. In this case Alpha testing can be useful use it to limit the “flying square” effect. Use a threshold near zero.

Thanks a lot for your help. That solved my problem.

By the way, for later use (maybe), would it be possible to write a pixelshader wich reads the alpha value from a textur and subtracts the alpha value of the pixel from the one of the giving textur? Though it would probably need more performance, it’s just my interest.

greets,
Shelling

Search for “depth peeling” for hardware accelerated order independant transparency.