Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 6 of 6

Thread: really mysterious gl_TexCoord[0] in fragment shader

  1. #1
    Intern Newbie
    Join Date
    Apr 2004
    Posts
    45

    really mysterious gl_TexCoord[0] in fragment shader

    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:

    Code :
    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 ..

    Code :
    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

  2. #2
    Member Regular Contributor
    Join Date
    Apr 2002
    Location
    Austria
    Posts
    328

    Re: really mysterious gl_TexCoord[0] in fragment shader

    This sounds like a bug. Which driver do you use?
    There is a theory which states that if ever anybody discovers exactly what the Universe is for and why it is here, it will instantly disappear and be replaced by something even more bizarre and inexplicable.

    There is another theory which states that this has already happened...

  3. #3
    Advanced Member Frequent Contributor yooyo's Avatar
    Join Date
    Apr 2003
    Location
    Belgrade, Serbia
    Posts
    872

    Re: really mysterious gl_TexCoord[0] in fragment shader

    I just test your shaders in ShaderDesigner. Both shaders comile and link with no errors, but gl_TexCoord[0] line has no effect in FP asm output (with or without this line). Tested with FW 61.32, FX5900XT.

    yooyo

  4. #4
    Intern Contributor
    Join Date
    Apr 2004
    Location
    Sweden
    Posts
    67

    Re: really mysterious gl_TexCoord[0] in fragment shader

    Sounds weird.

    Is there any reason to use gl_TexCoord (.xy) instead of varying vec2 TexCoord; ?

  5. #5
    Senior Member OpenGL Guru Humus's Avatar
    Join Date
    Mar 2000
    Location
    Stockholm, Sweden
    Posts
    2,345

    Re: really mysterious gl_TexCoord[0] in fragment shader

    If you're using fixed function fragment processing with a GLSL vertex shader, then you need to output to gl_TexCoord[0] to ensure it's written to the right interpolator. But when you use a vertex and fragment shader pair there's no point in using gl_TexCoord[n] as opposed to varying variables. In fact, using varyings give more flexibility to the driver and is more readable IMO.

  6. #6
    Intern Newbie
    Join Date
    Apr 2004
    Posts
    45

    Re: really mysterious gl_TexCoord[0] in fragment shader

    .. i'm working with a fireGl x2 (fgl 9800) APG 4x/8x on an xp system .. driver 6.14.10.6404 .. i'm thinking it's the newest one ..

    i have the same problem with an other shader .. exactly the same problem ..

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •