Re: [Algorithms] Othographic Light View Frustum

 [Algorithms] Othographic Light View Frustum From: Wolfgang Engel - 2007-04-12 15:26:06 Hi, I spent some time to think about the best way to generate an orthographic light view frustum for "full-screen" shadow maps. I actually use code to do this since a long time but I always perceive the resulting frustum as too big. The idea is to tightly fit the light frustum around a slice of the viewer's frustum. Here is how I do it: 1. determine a slice of the camera view frustum 2. calculate a near and far plane for this 3. transform in light space 4. take the extrema and build a bounding box 5. found the center of this box and transform it to world space 5. construct the orthographic frustum from this box By transforming to light space and then taking the extrema, you get a box that encloses one frustum slices. The problem is now rotation. Let's say you contruct the light view matrix upfront just by setting up fixed x and y vectors that just follow the z == light direction vector. If you rotate the camera view under the light what happens is the following: the enclosing orthographic light frustum will rotate around the camera view frustum slice, just by changing its shape. So in worst case it would look on the figure above like a diamond. There are two issues attached to this: the diamond is not necessarily the most efficient form to enclose the slice and second the rotation shows up in the result, because the render target will rotate with it. You can see the shadow flicker because of this. What I did now is a kind of hack: I used the direction of the camera and the x axis of the camera and "cross-product" them to the light direction. The result is better than before. Do I do anything substantially wrong and is there a better way to handle all this? Maybe I am completely off here ... - Wolfgang