Sign in to follow this  
Saimi

auto-generated texture coords to shader

Recommended Posts

i'm trying to implement bumpmapping in cg, but i've run into a problem. i want calculate my tbn-matrix in the vertex shader, but this requires the texture coords as far as i know. my problem is that i've mapped the texture onto an object using glTexGen, and i really don't know how to extract the auto generated tex coords and pass them to the shader. can anyone help me?? kind regards /s a i m i

Share this post


Link to post
Share on other sites
In short; you don't.

Auto-texture coord generation is part of the vertex stage, if you are using a vertex shader you have to generate them yourself.

However, 3DLabs has a program which can generate fixed function like shaders, so you might want to take a look at that to get the code, iirc it's linked to in the Forum FAQ

Share this post


Link to post
Share on other sites
Supposedly in GLSL you can grab contexts to these FFP settings, but I tried it and couldn't make heads or tails out of it. I ended up just modifying the texture matrix myself (which is what glTexGen* does anyway) and grabbing that in the vertex shader.

Share this post


Link to post
Share on other sites
Quote:
Original post by talas
Supposedly in GLSL you can grab contexts to these FFP settings, but I tried it and couldn't make heads or tails out of it. I ended up just modifying the texture matrix myself (which is what glTexGen* does anyway) and grabbing that in the vertex shader.
You should be able to access the following built-in uniform state variables (the page numbers refer to the OpenGL 1.4 Spec)
Quote:
From the GLSL 1.2 Spec
//
// Texture Environment and Generation, p. 152, p. 40-42.
//
uniform vec4 gl_TextureEnvColor[gl_MaxTextureUnits];
uniform vec4 gl_EyePlaneS[gl_MaxTextureCoords];
uniform vec4 gl_EyePlaneT[gl_MaxTextureCoords];
uniform vec4 gl_EyePlaneR[gl_MaxTextureCoords];
uniform vec4 gl_EyePlaneQ[gl_MaxTextureCoords];
uniform vec4 gl_ObjectPlaneS[gl_MaxTextureCoords];
uniform vec4 gl_ObjectPlaneT[gl_MaxTextureCoords];
uniform vec4 gl_ObjectPlaneR[gl_MaxTextureCoords];
uniform vec4 gl_ObjectPlaneQ[gl_MaxTextureCoords];
Also, TexGen doesn't do anything to the texture matrix. The result of TexGen is sent on down the pipe just like a texture coordinate specified by glTexCoord* (the next step is that it's multiplied by the texture matrix).

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this