• Advertisement
Sign in to follow this  

View Direction

This topic is 3651 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

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
Advertisement
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
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
Sign in to follow this  

  • Advertisement