Leadwerks
02-19-2008, 02:57 PM
I want to implement cascaded shadow maps like STALKER and Crysis have. I want the same quality and detail those engines allow. I understand the basic idea behind CSM.
My immediate thoughts are on how to allocate the shadow area. If we start from a top-down area in front of the camera it is easy enough to visualize. You could shear the rendering matrix to give a tilt to the light direction.
But once you start thinking about arbitrary geometry instead of just shadowing a flat plane, it gets very complicated. Shearing the matrix would cause errors on tall vertical walls. The only proper way to do it would be to render the scene from the point of view of the light, with the frustum stretched out to enclose the whole camera frustum (or the part of it the shadow map covers). This would result in a lot of wasted space, maybe 35% of the shadow map texture wouldn't even get used.
The simplest to visualize would be a series of squares around the camera, with the camera at the center. Each square uses the same resolution, but they cover more and more area. Shearing this matrix to tilt the light would be a little more reliable, since there would be a lot more room for error, but so much of the texture would be wasted, especially if the shadowmap was updated every frame. And if we are doing dynamic lighting, I think it should be.
Your thoughts?
My immediate thoughts are on how to allocate the shadow area. If we start from a top-down area in front of the camera it is easy enough to visualize. You could shear the rendering matrix to give a tilt to the light direction.
But once you start thinking about arbitrary geometry instead of just shadowing a flat plane, it gets very complicated. Shearing the matrix would cause errors on tall vertical walls. The only proper way to do it would be to render the scene from the point of view of the light, with the frustum stretched out to enclose the whole camera frustum (or the part of it the shadow map covers). This would result in a lot of wasted space, maybe 35% of the shadow map texture wouldn't even get used.
The simplest to visualize would be a series of squares around the camera, with the camera at the center. Each square uses the same resolution, but they cover more and more area. Shearing this matrix to tilt the light would be a little more reliable, since there would be a lot more room for error, but so much of the texture would be wasted, especially if the shadowmap was updated every frame. And if we are doing dynamic lighting, I think it should be.
Your thoughts?