Sign in to follow this  

Vector Spaces

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
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 this post


Link to post
Share on other sites
ok thanks, this makes perfect sense.

What about this one:

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?

Share this post


Link to post
Share on other sites

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

If you intended to correct an error in the post then please contact us.

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