PDA

View Full Version : glTexGen - no Texture Coordinate!



Adler
10-28-2004, 06:32 AM
Hello,

i work on an Radeon 9800 with GLSL, and I've a problem with generated Texture Coordinates.
If I draw a Quad an gave it Texture Coordinates with glTexCroord3f I can map the Texture with the registrated sampler. If I remove the glTexCoord calls an use Texture Generation instead, i sea a gray plane, but I expect a Texture there.
If I deaktivate the Shader, the Mapping works fine.

In short:
Expilzit Texture Coords with Shader works
Generated Texture Coords without Shader works
Generated Texture Coords with Shader fails.

Here my Fragment Shader Code:

varying float LightIntensity;
uniform sampler2D tex;

void
main (void)
{
vec3 color = vec3(texture2D(tex, gl_TexCoord[0].st));
color = color * LightIntensity;
gl_FragColor = vec4(color,1.0);
}

In the VertexShader the only relevant call
for TexCoords is:
gl_TexCoord[0] = gl_MultiTexCoord0;

In my Programm I don't forget to call glActiveTexture(GL_TEXTURE0) :-)

Thanks for any help.

Adler

mrbill
10-28-2004, 07:28 AM
Originally posted by Adler:
Hello,
...

In short:
Expilzit Texture Coords with Shader works
Generated Texture Coords without Shader works
Generated Texture Coords with Shader fails.

...

AdlerVertex Shaders *REPLACE*:
Vertex Transformation Normal Transformation (including rescale and normalize) TexCoord Generation and Transformation ...

Therefore, *YOU*, the shaderwriter, are responsible for providing the shader code to do TexCoord Generation and Transformation!
.
See Randi Rost's book "OpenGL Shading Language," Section 9.7 for shader code to do texcoord generation.
.
-mr. bill

Adler
10-30-2004, 04:21 AM
Originally posted by mrbill:

Therefore, *YOU*, the shaderwriter, are responsible for providing the shader code to do TexCoord Generation and Transformation!
-mr. bill

Thanks a lot. I forgot this. I reread the Chapter.
But there is a nother Question. I've got a Plane with 32x32 vertecies, for example and a shader for this. If I've in the Vertex Shader this:

gl_TexCoord[0] = gl_MultiTexCoord0;

and I 'don't use gl_TexCoord[0] in the Fragment Shader I've got something like a Ramp from high LightIntensity to low LightIntensity on the Plane. Why? Vendor spezific implementation behavoir?

Thanks for help!

Adler