Thursday, August 11, 2016

Define: How to transform normal vector from local to eye space :-)

Define


In order to understand how normal vectors are transformed to eye space, think the normals as coefficients of Plane-Equations, which are perpendicular to the planes

Imagine a triangle polygon with 3 vertices;v1-v2-v3,and the normal of this surface is (Nx,Ny,Nz,Nw) as a homogeneous plane (for euclidean space, the normal is (Nx,Ny,Nz)). If we think of the triangle as a homogeneous plane, then the plane equation becomes;(by replacing x,y,z to X/W,Y/W,Z/W, then multiplying on both sides)


XNx + YNy + ZNz + WNw = 0

Since 3 vertices lie on this plane, the plane equation is also true when we substitute these vertices to the equation.For example, for
V1=(x1,y1,z1,w1), it satisfies:


x1Nx + y1Ny + z1Nz + w1Nw = 0

The equivalent matrix form of the plane equation is:



The Plane equation is multiplying the transposed normal (NT) and the vertex together..

Now, we modify the above equation to acquire normal vector transformation formula by inserting GL_MODELVIEW matrix (M-1M)  in between.



As you can see, the right part of the above equation  is transforming vertex to eye space, and the left part  is going to be the normal vector in eye space because the plane equation is also transformed.

It reads as "The transformed vertex  lies on the transformed plane  in eye coordinates space".


Therefore, transforming normal from object space to eye space with GL_MODELVIEW matrix M is; 



Or, by converting pre-multiplication to post-multiplication form, we get:





No comments:

Post a Comment