mobeen

12-01-2010, 04:05 AM

Hi all,

I m trying to get the objt spce pos in the fragment shdr but without using the outputs from v.s. This is how i am doing it at the moment,

vec3 NDC = vec3(gl_FragCoord.xy/viewportSize, gl_FragCoord.z);

vec3 CSP = NDC * 2 -1;

mat4 M = mview_Inv*proj_Inv;

vec4 OSP = M*vec4(CSP,1);

OSP.w = 1.0/OSP.w;

OSP.xyz = OSP.xyz*OSP.w;

This gives me the following output if i output OSP as color.

http://www3.ntu.edu.sg/home2007/mova0002/iso/wrong.png

I should get a blend of colors not discrete colors as I am getting. Is my method correct or am i missing anythng?

I m trying to get the objt spce pos in the fragment shdr but without using the outputs from v.s. This is how i am doing it at the moment,

vec3 NDC = vec3(gl_FragCoord.xy/viewportSize, gl_FragCoord.z);

vec3 CSP = NDC * 2 -1;

mat4 M = mview_Inv*proj_Inv;

vec4 OSP = M*vec4(CSP,1);

OSP.w = 1.0/OSP.w;

OSP.xyz = OSP.xyz*OSP.w;

This gives me the following output if i output OSP as color.

http://www3.ntu.edu.sg/home2007/mova0002/iso/wrong.png

I should get a blend of colors not discrete colors as I am getting. Is my method correct or am i missing anythng?