Infinite Orthographic Projection

Started by
4 comments, last by zedz 16 years, 6 months ago
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
Advertisement
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.
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
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.
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 :-(
perhaps of interest
http://aoeu.snth.net/?p=7

This topic is closed to new replies.

Advertisement