glDepthMask(GL_FALSE), HELP !


The picture above is a particle system to simulate fire and smoke,all is well done , but when the camera move close to this smoke, the fps will reduce quickly, if the camera move in the center of the smoke ,the fps may reduce half, with the test result ,the function glDepthMask(GL_FALSE)bring on this result , the follow is the particle draw code:
(do not use alphafunc)

glDepthMask(GL_FALSE);

glBlendFunc(GL_ONE, GL_SRC_ALPHA_SATURATE);

glDisable(GL_FOG);

glDisable(GL_CULL_FACE);

//bind texture

glTranslatef(pos.x,pos.y,pos.z);
glColor4f(color.xcolor.w,color.ycolor.w,color.z*color.w,alpha);

glRotatef(Rotbase,0.0f,0.0f,1.0f);
Rotbase+=Rotf;

glBegin(GL_QUADS);

glTexCoord2f(0,1);
glVertex3f(size, size, 0);

glTexCoord2f(0,0);
glVertex3f(size, -size, 0);

glTexCoord2f(1,0);
glVertex3f(-size, -size, 0);

glTexCoord2f(1,1);
glVertex3f(-size, size, 0);

glEnd();

glEnable(GL_CULL_FACE);

glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_FOG);
glDepthMask(GL_TRUE);
glPopMatrix();

who can help me ?

Don’t think the depth-mask has much to do with the fps-drop.

Rendering particles is computationally intensive, since you blend many pixels. When you move close to your system, it will fill more and more pixels of the screen, each pixel being very expensive.

So the GPU cannot cope anymore and the fps drops, when it has too much to do, because you are too close.

The only way to lessen the problem, is to reduce overdraw. That means you need to simply render fewer particles. Of course it is a challenge to render fewer particles with the same result (high quality).

Nothing else, you can do about it.

Jan.

Jan is right, you are probably pixel-limited. You can verify this by making your viewport smaller, if the fps increase with you are pixel limited.

You need to render fewer/smaller Particles then. Do not render those particles which are overdrawn by many others.

The reason glDepthMask(GL_FALSE) slows things down is that without this loads of pixels will be discarded by the depth test prior to shading from previous particles. So performance will be faster with glDepthMask(GL_TRUE), however, the rendering will of course be largely different and many particles would be incorrectly culled. So glDepthMask(GL_FALSE) is in itself not the problem, it’s just that glDepthMask(GL_TRUE) “solves” performance by throwing away a lot of work that really needs to be done.