# View-space vs window-space depth

## Recommended Posts

Kaptein    2224

I have a shader that I input both view-space and window-space depth to.

Both of these are ok, but I would like to get rid of window-space depth so I can replace the depth-texture with a (much faster) depth-renderbuffer.

So, the problem is:

	// windowspace depth to world coordinates
vec4 cofs = eye_direction * matview;
cofs.xyz *= linearizeDepth(texCoord);


Where eye-direction is:

	eye_direction = vec4(gl_Position.xy * nearPlaneHalfSize, -1.0, 1.0);


So, if i multiply eye_direction with any windowspace depth, it will turn into an eye-space position.

Now, if I wanted to get rid of this depth-texture read in linearizeDepth() and use my eye-space depth instead, how would I do that?

Can it even be done easily? Or, relatively speaking just as easily as window-depth to eye-space.

Bottom line: I have view-space depth already, how do I throw the window-space depth out the window and use my view-space depth in its stead to reconstruct view-space or world-space.

Edited by Kaptein