Sign in to follow this  
bene81

View Direction

Recommended Posts

bene81    138
Hey In shaders you often find something like this worldPosition = gl_ModelViewMatrix * gl_Vertex;; eyePosition = normalize( worldPosition.xyz / worldPosition.w ); I dont understand this because the mv matrix has only 0 0 0 1 in the last row, and vertices are (x,y,z,1), so I assume wordPosition.w is always 1. So why is there the division by w ?

Share this post


Link to post
Share on other sites
esr_ever    130
AFAIK, if you have any weird transformations going on, w will change. I always use only rotation & translation so it's always 1. If you want, expand the matrix multiplications of the modelview,and you'll probably see in which cases w is changed

Share this post


Link to post
Share on other sites
snoutmate    362
Yeah, those are homogenous coordinates. Note that vertices does not have to be (x,y,z,1), you can set (x,y,z,w) with glVertex4* functions. Also with w==0 the point is assumed to be at infinite distance.

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