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).]

// 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).]