3D on 2D Plane (Z-Fighting)

Started by
5 comments, last by Enigma 18 years, 7 months ago
I'm currently working on a 3D in 2D project using 3D graphics to draw a 2D game. I'm trying to get weapons fire working on the 2D plane but I'm having trouble with the Z-Buffer. I'm rendering all of the weapons as quads on the 2D plane at the same depth and blending them. With backgroud objects this works fine beacuse it is drawn in the correct order for blending, but in terms of overlapping weapons fire I have problems getting the last drawn weapon (The correctly blended one) to render on top of an earlier drawn weapon. I've looked at a couple of the solutions people have address such as polygon offset and stenciling but I'm not sure which is best for my current problem. Any help/advice would be greatly appreciated.
Advertisement
Disable Z-test and sort polygons before draw them?
ni keep depthtest enabled (but diable depth writes)
and sort + draw in correct order
Ahh, thanks, that does exactly what I wanted.

For anyone who didn't know what he meant by disable depth writes (I didn't)

glDepthMask(GL_FALSE)
Is there a performance gain from using glDepthMask over glEnable/glDisable(GL_DEPTH_TEST)?
yes, the latter only disables testing again the zbuffer, the former disables writing of the zbuffer
Disabling the depth test also implicitly disables depth writes.

Enigma

This topic is closed to new replies.

Advertisement