Talk:Compute eye space from window space
"Optimized method from XYZ of gl_FragCoord
I implemented this method, and I think I have found some problems with it (that can be fixed to make it work).
1. The method still uses indices from the projection matrix to calculate the eye space depth, which is confusing. This method seems to work just as well, and is less confusing: eye_z = ( camera_near / (camera_far - texture_depth * (camera_far - camera_near)) ) * camera_far [ http://www.leadwerks.com/files/Deferred_Rendering_in_Leadwerks_Engine.pdf ] 2. The method proposes that [-1, 1] should be used for the range of the coordinates when calculating eye direction. That "almost" works, but I have after some reasoning and testing found that this should probably be the corners of the near plane in eye space.