I have a very basic but confusing question. I want to project an Eye-space radius on the image plane but I’m confusing about these projections. Can someone explain me more about image space and eye-space?
I need these information for implementing Image-Space Horizon-Based Ambient Occlusion. In this paper all of the calculations are based on these projections and I think I have some problem in this part.
Thanks in advance!
Eye space is what you get after applying the modelview transform. It is a coordinate system where the viewer (or eye) is in the origin looking down the negative z axis.
Image space is at the very end of the pipeline, after additionally applying the projection transform and perspective division (to get NDC = normalized device coordinates) and then the viewport transformation to get image space coordinares (i.e. coordinates in pixels).
Tnx for your explanations, but I’ve calculated the linear depth in one stage and saved the result on a texture and now in my program I have to convert this depth from texture coordinate to eye-space in my shader for further calculations. the problem is I don’t know about the mathematics behind this and if someone can introduce a reference or explain about this conversions I would really appreciate it
I’m sure this is in the forum archives a bunch of times, but here’s one that I posted a while back:
Skip down to “So, crunching some formulas quickly…” for the solution. Input to the function is a 0…1 depth value (e.g. from a DEPTH_COMPONENT texture previously used for rendering). left/right/bottom/top/near/far are the values you passed glFrustum (or similar). widthInv and heightInv are one over the 3rd and 4th values you passed glViewport (the X and Y resolution). And gl_FragCoord.xy are of course the viewport X and Y coordinates of the current pixel.
Since you’ve stored eye-space Z rather than window-space Z, you can skip the eye.z calculation and just look it up.
The NDC-to-eye space stuff you can get yourself just from the inverse perspective projection matrix in the Mathematics appendix of the OpenGL Programming Guide. And the window-to-NDC stuff is pretty simple (0…1 -> -1…1).