about the inverse world view matrix

A place for users of OGRE to discuss ideas and experiences of utilitising OGRE in their games / demos / applications.
machineonpointer
Kobold
Posts: 35
Joined: Fri Dec 06, 2013 4:15 am

about the inverse world view matrix

Post by machineonpointer »

Why does normal in view space is got by mWorldViewIT * vec4(vNormal.xyz, 1.0).
while the vertex in view space is got by mWorldView * vPos
I'm really confused by this.
void FFP_Light_Directional_DiffuseSpecular(in mat4 mWorldView, in vec4 vPos, in mat4 mWorldViewIT, in vec3 vNormal, in vec3 vNegLightDirView, in vec3 vDiffuseColour, in vec3 vSpecularColour, in float fSpecularPower, in vec3 vBaseDiffuseColour, in vec3 vBaseSpecularColour, out vec3 vOutDiffuse, out vec3 vOutSpecular)
{
vOutDiffuse = vBaseDiffuseColour;
vOutSpecular = vBaseSpecularColour;
vec3 vNormalView = normalize((mWorldViewIT * vec4(vNormal.xyz, 1.0)).xyz);
float nDotL = dot(vNormalView, vNegLightDirView);
vec3 vView = -normalize((mWorldView * vPos).xyz);
vec3 vHalfWay = normalize(vView + vNegLightDirView);
float nDotH = dot(vNormalView, vHalfWay);
if (nDotL > 0.0)
{
vOutDiffuse += vDiffuseColour * nDotL;
vOutSpecular += vSpecularColour * pow(clamp(nDotH, 0.0, 1.0), fSpecularPower);
}
}
User avatar
Laubstein
Gnoblar
Posts: 15
Joined: Tue Nov 11, 2008 12:12 pm

Re: about the inverse world view matrix

Post by Laubstein »

Maybe it could help you to understand it: http://www.lighthouse3d.com/tutorials/g ... al-matrix/
*/You never know what is enough until you know what is more than enough*/