andreasMank

05-26-2004, 05:39 AM

i tried a little rim light shader .. no big problem, but i found a really mysterious thing .. i'm not sure if it should be like this ..

first my vertex shader:

uniform vec4 lightPos;

uniform vec4 eyePos;

varying vec3 N;

varying vec3 V;

void main(void)

{

gl_TexCoord[0] = gl_MultiTexCoord0;

vec3 P = vec3(gl_ModelViewMatrix * gl_Vertex);

N = gl_NormalMatrix * gl_Normal;

V = vec3 (gl_ModelViewMatrix * eyePos) - P;

gl_Position = ftransform();

}

no problem in here .. everything is really fine ..

so lets have a look in the fragment shader code .. its what we know from dawn demo ..

uniform vec4 rimColor;

uniform float rimPower;

varying vec3 N;

varying vec3 V;

void main (void)

{

gl_TexCoord[0];

vec3 nN = normalize(N);

vec3 nV = normalize(V);

float rim = pow(1.0 - max(dot(nV, nN), 0.0), rimPower);

gl_FragColor = rimColor * rim;

}

.. this one is working .. but if i delete the sensless gl_TexCoord[0]; in the fragment shader, i get different results .. ??? .. why do i need this line of code ???

thx

first my vertex shader:

uniform vec4 lightPos;

uniform vec4 eyePos;

varying vec3 N;

varying vec3 V;

void main(void)

{

gl_TexCoord[0] = gl_MultiTexCoord0;

vec3 P = vec3(gl_ModelViewMatrix * gl_Vertex);

N = gl_NormalMatrix * gl_Normal;

V = vec3 (gl_ModelViewMatrix * eyePos) - P;

gl_Position = ftransform();

}

no problem in here .. everything is really fine ..

so lets have a look in the fragment shader code .. its what we know from dawn demo ..

uniform vec4 rimColor;

uniform float rimPower;

varying vec3 N;

varying vec3 V;

void main (void)

{

gl_TexCoord[0];

vec3 nN = normalize(N);

vec3 nV = normalize(V);

float rim = pow(1.0 - max(dot(nV, nN), 0.0), rimPower);

gl_FragColor = rimColor * rim;

}

.. this one is working .. but if i delete the sensless gl_TexCoord[0]; in the fragment shader, i get different results .. ??? .. why do i need this line of code ???

thx