Cg using GL_EQUAL

i am using at the moment cg for my shaders. First i render lightmap-pass and adding texture/shader-pass. Because of adding it i need to use glDepthFunc( GL_LEQUAL ). If i turn of shaders everthing is fine and sorts well.
If i turn on shaders a get bad z-fighting because of vertex shader. I think using this matrix:


in the vertex shader(code in shader : OUT.HPos = mul(modelViewMatrix, IN.position)) brings not the same result as “pure” OpenGL. Any idea on how to fix it? my last hope is using GLSL will fix this issue but if there is another solution with less work it would be great.

btw, glPolygonOffset is no solution because of adding the shader-pass it will bring some ugly pixels on the edges of the polygons :wink:

If you do switch to GLSL, the ftransform() function does what you need.

The Cg manual mentions “position invariance” explicitly (at least in the 1.1 version I looked at).

Thx Relic. I may have overseen this important thing :slight_smile: . Using compileroption “-posinv” gives position invariance and GL_EQUAL works great :cool:

Using GL_EQUAL when you can use GL_LEQUAL is not recommended. It doesn’t work very well with HyperZ on current hardware.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.