Mobsan

04-04-2005, 01:17 AM

Hi I got a problem with making an alternativ gl_ModelViewMatrix matrix.

mat4 T; // T-matrix

T[0] = vec4( 1.0, 0.0, 0.0, -lightPos.x );

T[1] = vec4( 0.0, 1.0, 0.0, -lightPos.y );

T[2] = vec4( 0.0, 0.0, 1.0, -lightPos.z );

T[3] = vec4( 0.0, 0.0, 0.0, 1.0 );

vec3 n; vec3 u; vec3 v;

n = -normalize(lightPos.xyz - vec3(0.0, 0.0, 0.0)); // LOOK AT

v = normalize(cross(vec3(0.0, 0.0, 1.0),n)); // UP Vector

u = normalize(cross(v,n));

mat4 viewTOlight; //R

viewTOlight[0].x = u.x; viewTOlight[0].y = u.y; viewTOlight[0].z = u.z; viewTOlight[0].w = 0.0;

viewTOlight[1].x = v.x; viewTOlight[1].y = v.y; viewTOlight[1].z = v.z; viewTOlight[1].w = 0.0;

viewTOlight[2].x = n.x; viewTOlight[2].y = n.y; viewTOlight[2].z = n.z; viewTOlight[2].w = 0.0;

viewTOlight[3].x = 0.0; viewTOlight[3].y = 0.0; viewTOlight[3].z = 0.0; viewTOlight[3].w = 1.0;

mat4 V = viewTOlight * T; // R * TI can't get this to work, what is wrong with my matrix?

Im using this for shadowMapping.

I want these to be identical

gl_Position = gl_ProjectionMatrix * gl_ModelViewMatrix * gl_Vertex;

and

gl_Position = gl_ProjectionMatrix * V * gl_Vertex;

mat4 T; // T-matrix

T[0] = vec4( 1.0, 0.0, 0.0, -lightPos.x );

T[1] = vec4( 0.0, 1.0, 0.0, -lightPos.y );

T[2] = vec4( 0.0, 0.0, 1.0, -lightPos.z );

T[3] = vec4( 0.0, 0.0, 0.0, 1.0 );

vec3 n; vec3 u; vec3 v;

n = -normalize(lightPos.xyz - vec3(0.0, 0.0, 0.0)); // LOOK AT

v = normalize(cross(vec3(0.0, 0.0, 1.0),n)); // UP Vector

u = normalize(cross(v,n));

mat4 viewTOlight; //R

viewTOlight[0].x = u.x; viewTOlight[0].y = u.y; viewTOlight[0].z = u.z; viewTOlight[0].w = 0.0;

viewTOlight[1].x = v.x; viewTOlight[1].y = v.y; viewTOlight[1].z = v.z; viewTOlight[1].w = 0.0;

viewTOlight[2].x = n.x; viewTOlight[2].y = n.y; viewTOlight[2].z = n.z; viewTOlight[2].w = 0.0;

viewTOlight[3].x = 0.0; viewTOlight[3].y = 0.0; viewTOlight[3].z = 0.0; viewTOlight[3].w = 1.0;

mat4 V = viewTOlight * T; // R * TI can't get this to work, what is wrong with my matrix?

Im using this for shadowMapping.

I want these to be identical

gl_Position = gl_ProjectionMatrix * gl_ModelViewMatrix * gl_Vertex;

and

gl_Position = gl_ProjectionMatrix * V * gl_Vertex;