It sounds like a stupid question.
I saw this variable is used in an online tutorial and in the book “OpenGL Shading language,” but I can not find what it means, no matter from google, the book, or even glsl specification. I know it’s the texture coordinates which would be interpolated in fragment shader, but how about the “st” part? And what else variables are there in its structure.
I am new to glsl. Do I miss something?
As you saif, gl_TexCoord is the variable of texture coordinate sets. The “st” part you wonder about, is part of swizzle mask. The swizzle mask let you recombine your vector. The texture coordinates are four-component vectors, but st mask selects the first two (you can use “xy”, it would be the same). Look into GLSL specification, it is explained well there.
Specifically, look at section 5.5, “Vector Components”.
Another noob question.
Is it preferable to use gl_TexCoord or just make your own varying variable and pass a texture coordinate from the vertex shader to the fragment shader? Or is it the case, if you only have a vertex shader that gl_TexCoord will interact with the fixed pipeline?
It doesn’t matter, gl_texcoord is just an array of predefined varying variables, but it is nice to have, and FYI there is no fixed pipeline anymore.
But there is still fixed-function pipeline from the APi point of view… I would like to see it removed as soon as possible, all that Light, material, Vertex* calls etc. I hope the new releases will bring this changes…
Like OpenGL “Longs Peak” “Lean and Mean” profile you mean.
Thanks guys, it is in section 5.5 of GLSL spec. I couldn’t find it because I always search for the keyword “gl_TexCoord.”
This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.