I'm digging into shadow mapping again. The standard procedure I've followed is to:
- Extract the 8 frustum corners of the view frustum
- Get the centroid, move away from this in the direction of the light by the far clipping distance
- Create a LookAt matrix using this distance and the centroid as the from/to
- Transform the frustum corners by this Shadow View matrix i've created
- Get the min and max x/y/z values from the transformed frustum corners to generate an off-center Ortho Projection Matrix
- Use these Shadow Projection and Shadow View matrices for rendering to the shadow buffer.
I've always gotten strange clipping issues in the shadows when doing this method, and I've realized (after rendering the frustums in question) that it's because the Shadow View Matrix is translated substantially farther away from the camera frustum than the Ortho bounds can tolerate for the near/far distances.
Why isn't there generally a step in there to translate the Shadow View Matrix such that it aligns with the calculated Ortho near plane? Am I missing something?
EDIT: Well, duh, because the near/far values calculated are already in terms of the Shadow View Matrix.