# Vector Spaces

This topic is 3158 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

PARAM mvi[4] = {state.matrix.modelview.inverse} #vector pointing to light0 DP4 light0pos.x, mvi[0], state.light[0].position; DP4 light0pos.y, mvi[1], state.light[0].position; DP4 light0pos.z, mvi[2], state.light[0].position; DP4 light0pos.w, mvi[3], state.light[0].position; SUB light0vec, light0pos, vertex.position Please correct me if I'm wrong but the light[0].position is in object space and the inverse modelviewmatrix maps from eye to object space so why on earth do we multiply with it and not with the modelviewmatrix itself which maps from object to eye space?

##### Share on other sites
Quote:
 From glLight man-page...The position is transformed by the modelview matrix when glLight is called (just as if it were a point), and it is stored in eye coordinates....

So the light position is given in view space, while the vertices are given in their model space. Transforming the light from view space into the object's local space means to have a common space where calculations using both kinds of values can take place.

##### Share on other sites
ok thanks, this makes perfect sense.

ATTRIB tangent = vertex.texcoord[1];
ATTRIB binormal = vertex.texcoord[2];
ATTRIB normal = vertex.normal;

# transform light0 vector into tangent space (DO NOT NORMALIZE)
DP3 result.texcoord[1].x, light0vec, tangent;
DP3 result.texcoord[1].y, light0vec, binormal;
DP3 result.texcoord[1].z, light0vec, normal;
MOV result.texcoord[1].w, 1.0;

Usually the tangent space should be comprised of 3 axes of length 1.0, right? So why don't we normalize here? If we don't normalize and the texture coordinates were (0.5, 1) the T-axis of our resulting coordinate system will be half as long as the B-axis, right? So don't we get wrong results then if we transform the light vector into this space?

1. 1
Rutin
29
2. 2
3. 3
4. 4
5. 5

• 13
• 13
• 11
• 10
• 13
• ### Forum Statistics

• Total Topics
632960
• Total Posts
3009475
• ### Who's Online (See full list)

There are no registered users currently online

×