PDA

View Full Version : cg using GL_EQUAL



Dummbatz
06-21-2005, 01:22 AM
Hi,
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 ;)

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

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

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

Humus
06-22-2005, 02: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.