Sign in to follow this  

Infinite Orthographic Projection

This topic is 3718 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I have an orthographic light view frustum. I would like to project things that are behind the near camera plane into the near plane. I saw that Kozlov in GPU Gems uses a what he calls virtual camera. He is using this in post-projective space ... is there a similar construct for a orthographic projection? Thanks for your help, - Wolf

Share this post


Link to post
Share on other sites
After you transform the point by the projection matrix in the vertex shader, clamp Z to 0 if it's negative. This will push everything behind the camera onto the near plane. You need to be careful though, since this means nothing behind the near plane but within the side planes will ever be clipped. You should also have a culling system in place to take care of objects completely outside the light view frustum.

Share this post


Link to post
Share on other sites
I do not quite understand why you need this, but from the reference to Kozlov's article I conclude that you need a way to construct a orthogonal frustum that encloses all focus points. If I am right, I've summarized the steps to success here: http://zeuxcg.blogspot.com/2007/09/robust-unit-cube-clipping-for-shadow.html

Share this post


Link to post
Share on other sites
Clarification:

Both approaches described in Kozlov's article (virtual slideback and inverted projection matrix) do not project things behind near plane on a single plane, virtual slideback simply enlarges view frustum to improve zfar/znear ratio (or, to be precise, to increase distance between light in PPS and the closest point of unit cube), inverted projection matrix is a tricky way to construct a frustum that "sees" points behind the viewer - they do not get projected to a specific plane, they just are inside unit cube after PPS, not outside.

If you need to include some casters/receivers in your light frustum, it's as simple as adjusting Z extents (for ortho frustum it's perfectly valid to have negative Z extents). For details read the link I posted above.

Share this post


Link to post
Share on other sites
For my orthographic shadow maps, I transform the caster bounds into light space, then simply get the extents of the bounds. The XY extents of the bounds represent the view "window" of the orthographic projection, and the Z extents represent what the Znear and Zfar should be. If the calculated Znear is less than the light space camera's near, then I move the camera back by the difference, effectively placing the light space camera's near at Znear. Of course, for an orthographic transform, this doesn't change the size of the view, results in a tight bounds in terms of maximizing the shadow map area and maximizing the depth precision, and is extremely simple code.

The only problem I've faced so far (apart from the usual depth and slope bias tweaking issues) is that GPU skinned object's bounds are not known when rendering into the shadow map, so I just make an approximation which seems to work well enough. In fact, before shadowing skinned objects, I never needed a scissor rect or anything to prevent the clipping of the casters because they always fitted well. Now I require a scissor rect/viewport/clip region that clips one pixel around the border :-(

Share this post


Link to post
Share on other sites

This topic is 3718 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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