PDA

View Full Version : Problem with gl_FragCoord



LarsMiddendorf
01-17-2004, 12:50 PM
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).]

Corrail
01-17-2004, 03:03 PM
*hm* Sounds like a bug in ATI's driver (surely not the only one... ;-)
Send them a mail at devrel@ati.com

jeremyz
01-19-2004, 09:49 AM
The ATI GLSL implementation in Catalyst 3.10 seems pretty broken to me.

datenwolf
01-27-2004, 04:06 AM
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.

Corrail
01-27-2004, 07:22 AM
Try ATI Catalyst 4.1!
Some major bugs have been removed.