Sign in to follow this  
Kaptein

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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this