Screen space coordinates to Eye space conversion I'm trying to figure out how to reverse Eye space -> projection -> clip(divide by w) -> screen space conversion.

Basically, I want to get Screen space (still have z value for z-buffer) -> undivide? by w -> inverse projection. 

I found the inverse matrix for projection but can't figure out how to get the coordinate "undivided" by w.

Thank you!
Object Space → World Space → Eye Space → Clip Space → Normalized Device Space → Window Space


You get from Object Space to World Space by multiplying by the "World
Matrix" (This may actually be multiple matrices depending
on the parent-child object hierarchy of the scene.  Compose them all together to get a single "World Matrix" for a given object.)
You get from World Space to Eye Space by multiplying by the "View Matrix".
You get from Eye Space to Clip Space by multiplying by the "Projection Matrix".
You get from Clip Space to Normalized Device Space by performing the "perspective divide" (divide by w in clip space coordinates).  This is a non-linear transformation requiring a divide, and is not represented by a matrix.  Information can be destroyed in this step.  If w is divided by w you just get 1, and there's no way to recover the original w.


You get from Normalized Device Space to Window Space by performing the Viewport and Depth Range transform. (Simple linear relationship)






The World Matrix, View Matrix, and Projection Matrix are all just 4x4 matrices and can be inverted to get the reverse transformation.

So, to go backwards...


You get from Window Space to Normalized Device Space by performing the inverse of the Viewport and Depth Range transform.
You can get from Normalized Device Space to Clip Space by performing the inverse of the perspective divide (multiply by w).  This is a non-linear transformation requiring a multiply, and is not represented by a matrix.  In general this operation doesn't magically recover 3D data from 2D data.  You must know something about the depth externally to be able to recover the 3D position of a point on the 2D screen.
You can get from Clip Space to Eye Space by multiplying by the inverse of the "Projection Matrix"
You can get from Eye Space to World Space by multiplying by the inverse of the "View Matrix".
You can get from World Space to Object Space by multiplying by the inverse of the "World Matrix".


May I suggest reading this explanation of the OpenGL Transformation.