PDA

View Full Version : GLSL Z-fighting



nbasili
01-03-2005, 05:26 AM
Hi everyone,
When draw an object using two passes I have the following problem:

The first pass is a color pass (simple texturing or an opengl shader).
The second pass is a environment-map pass using a cube map with some alpha-blending.

I notice that when I use a shader for the first pass there is z-fighting, but when I use stadard opengl (e.g. just a texture or solid) everything is OK.

Could the problem occur because of the vertex shader not returning the same vertex coordinates as the vertices of the second pass? (precision problem maybe?)

The vertex program is:

varying vec3 Normal;

void main(void)
{
Normal = normalize(gl_NormalMatrix * gl_Normal);
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
}

Could this be a driver bug? I have a GeForce5600Go with 65.73 drivers

Matt Zamborsky
01-03-2005, 05:51 AM
gl_Position = ftransform()

use this instead of the transformation the incoming position with modelviewprojection matrix. It's really caused with precision loss. Because shaders use different precision than the fixed-pipeline. The command "ftransform" garants that the result is the same. In ASM shaders the "posicion invariant" solve this problem.

nbasili
01-03-2005, 08:26 AM
Thanks alot, that fixed it!!!