View Full Version : One problem with transformations

10-16-2004, 01:49 AM
I'm trying to set up a framework for bumpmapping, but after 1 year of doing nothing in this case I can't get through those space transformations.

Currently my vertex shader looks like this:

uniform vec3 t;//Tangent from program
uniform vec3 b;//Binormal ...
uniform vec3 n;//Normal ...
varying vec3 l;//light to fsh

void main(void)
mat3 tbn = mat3(t,b,n);//t,b,n to matrix;
vec3 lpw = vec3(2.0,2.0,2.0);//Light position in world space
vec3 lpe = lpw-vec3(0.0,0.0,8.0);//Conversion from world coords to eye coords
vec3 lpo = gl_NormalMatrix * lpe;//IT to transform light position from eye space to object space
vec3 lvo = lpo-gl_Vertex.xyz;//going from light position (obj space) to light direction (obj space).
l = tbn * lvo;//light direction into tangent space
gl_Position = ftransform();
gl_TexCoord[0] = gl_MultiTexCoord0;
gl_TexCoord[1] = gl_MultiTexCoord1;

I have a quad at (0,0,1) rotated using glRotatef(angl,0,1,0); and Look at (0,0,8,0,0,0,0,1,0); But lighting is definately wrong.