View Full Version : cg using GL_EQUAL

06-21-2005, 02:22 AM
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:

cgGLSetStateMatrixParameter(modelViewMatrix, CG_GL_MODELVIEW_PROJECTION_MATRIX, CG_GL_MATRIX_IDENTITY);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 ;)

06-21-2005, 03:16 AM
If you do switch to GLSL, the ftransform() function does what you need.

06-21-2005, 05:08 AM
The Cg manual mentions "position invariance" explicitly (at least in the 1.1 version I looked at).

06-22-2005, 02:36 AM
Thx Relic. I may have overseen this important thing :) . Using compileroption "-posinv" gives position invariance and GL_EQUAL works great :cool:

06-22-2005, 03:40 PM
Using GL_EQUAL when you can use GL_LEQUAL is not recommended. It doesn't work very well with HyperZ on current hardware.