mobeen

12-08-2010, 12:47 AM

Hi all,

I have a question on a discussion about point light gauraud shading shader in opengl super bible. The code gets the object space position like this (mvMatrix is the modelview matrix).

vec4 pos4 = mvMatrix* vVertex;

Then the part i dont understand, it does a division by w to get pos3 as follows

vec3 pos3 = pos4.xyz/pos4.w;

Form what i think if we are not multiplying by the projection matrix the w coord. would always be 1 wouldnt it? Then why do I need this division by w?

Regards,

Mobeen

I have a question on a discussion about point light gauraud shading shader in opengl super bible. The code gets the object space position like this (mvMatrix is the modelview matrix).

vec4 pos4 = mvMatrix* vVertex;

Then the part i dont understand, it does a division by w to get pos3 as follows

vec3 pos3 = pos4.xyz/pos4.w;

Form what i think if we are not multiplying by the projection matrix the w coord. would always be 1 wouldnt it? Then why do I need this division by w?

Regards,

Mobeen