Lesson 19: Particle engine

Started by
4 comments, last by lc_overlord 16 years, 9 months ago
hi folks To draw the Particles in lesson 19, depth testing is disabled (glDisable(GL_DEPTH_TEST);) Lets say, we do have a landscape with some hills or mountains, or even just a wall. Now if i stand in front of the hill, and the particle effect is behind the hill, the particles will draw through the hill. How can i do particles, that wont shine through other, solid objects?
Advertisement
Draw the particle effects *before* drawing the hill. That should work.
lets say you have one big display list with the landscape, 2 hills and the particles between it, now if you draw the particle, then the hills, it won't be visible at all...
instead of setting depth test to false, i set glDepthMask to false, this works as it should

[Edited by - Rainer K on June 24, 2007 4:00:46 AM]
The other way to handle this is to sort your particles from furthest to closest to the camera and draw them with depth-testing and the depth mask enabled. There are some interesting performance tradeoffs, related to each method, that I could write about if you (or anyone) are interested.
It also depends on the nature of the particles.
there are two types of particles that does not need sorting.
1. glowing particles that are blended with (GL_ONE,GL_ONE).
2. single color alpha textured particles with regular alpha blending

All other types of particles needs to be sorted in some way to not produce many artifacts.

This topic is closed to new replies.

Advertisement