Problem with gl_FragCoord

If gl_FragCoord is read in the fragment shader, the value of varyings seems not to be correct in all cases. The viewvec varying seems to be calculated from a fixed camera pos. If you replace gl_FragCoord.z in the fragment shader with 0, the view vector is interpolated correct. Btw: The shader doesn’t have any special meaning. I’ve got a Radeon 9800 pro and Catalyst 3.10. Thanks.

// Vertex Shader
varying vec3 viewvec;
varying vec3 texcoord;

void main()
{
texcoord = vec3(gl_MultiTexCoord0);
viewvec = viewpos - vec3(gl_Vertex);
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
}

// Fragment Shader
uniform sampler2D diffusemap;
varying vec3 viewvec;
varying vec3 texcoord;

void main()
{
gl_FragColor = vec4(normalize(viewvec)*vec3(texture2D(diffusemap,texcoord.xy)),gl_FragCoord.z);
}

[This message has been edited by LarsMiddendorf (edited 01-17-2004).]

hm Sounds like a bug in ATI’s driver (surely not the only one… :wink:
Send them a mail at devrel@ati.com

The ATI GLSL implementation in Catalyst 3.10 seems pretty broken to me.

Originally posted by jeremyz:
The ATI GLSL implementation in Catalyst 3.10 seems pretty broken to me.

Yep, extremely broken, my experience:

Matrices are not tracked correctly in some special cases.

gl_LightSource[n].position is not transformed by the matrix that was on top of the stack, when glLightfv was called

Use more then 4 texture lookups and the thing goes “woewoe” (SW rendering, but no visible result).

gl_TexCoord isn’t tracked cleanly. You’ve to set it in the vertex shader using gl_MultiTexCoord<n>

Materials are not trcked cleanly.

Try ATI Catalyst 4.1!
Some major bugs have been removed.

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