Dark Cheetah

12-03-2006, 03:54 PM

i need to restore the 3d position of the screen pixel. my scene is rendered using FBO and then displayed on a quad. my screen pixel is the

point = gl_ModelViewProjectionMatrix * gl_Vertex i use

point as varying and send it to the fragment shader. if i understand everything correctly i need to do 2 operations. i take the inverse Projection and ModelView matrices which i used to render the scene (not the matrices used for the FBO quad rendering) and send it to the shader. then i first multiply inverse projection matrix

vec4 v_cam = proj_inv * point and after i restore the 3d vertex multiplying inverse model view matrix

vec4 vertex = mview_inv * v_cam unfortunately i have wrong result. does anyone know how to do this correctly?

point = gl_ModelViewProjectionMatrix * gl_Vertex i use

point as varying and send it to the fragment shader. if i understand everything correctly i need to do 2 operations. i take the inverse Projection and ModelView matrices which i used to render the scene (not the matrices used for the FBO quad rendering) and send it to the shader. then i first multiply inverse projection matrix

vec4 v_cam = proj_inv * point and after i restore the 3d vertex multiplying inverse model view matrix

vec4 vertex = mview_inv * v_cam unfortunately i have wrong result. does anyone know how to do this correctly?