   Simple shadow map antialiasing?
Hi everyone, At the moment I've got basic shadow maps, but I'd like to try and remove the blocky pixel edges by adding some antialiasing. I'm not looking for soft shadows - I want to keep them hard, but I'd like to try and make the edges smoother. Thanks!
You are basing your tutorials from RasterTek aren't you? Just asking...;I sometimes use Rastertek but I got my shadow mapping stuff from Riemers (XNA) and changed it to DirectX.;The standard technique is called Percentage Closer Filtering, or PCF for short. It basically amounts to sampling the shadow map multiple times in a small radius, performing the shadow comparison for each sample, and averaging the result. Which version of D3D are you using?;OK - I'm using D3D9 and pixel/vertex shader 2.0 - I did hear about PCF but I thought that was primarily for making shadows softer. If it reduces the visibility of texels at the edge of the shadow, then I guess I'll use that!;Well, it's actually a form of filtering but it will have the result of "softening" your shadows by giving them a penumbra. Filtering is definitely a good way to reduce aliasing (the jagged, stair-step artifacts that you're talking about), but it will also reduce the sharp details. If you want really sharp details without aliasing, then the only good solution is to increase the effective resolution of your shadow map (either by increasing the size of the shadow map, or reducing the amount of screen space that it covers). High shadow map resolution + filtering will give you sharp, unaliased shadows.;That's useful, thanks! Since my game takes place on the Moon, I need to try and maintain reasonably hard shadows. I'm willing to trade off a little bit of hardness for antialiasing though, so I guess PCF it is! Thanks for your help!;I'm not sure what the effective screen resolution of your shadow map is, but I found that bumping the render target of the shadow map to 4096x4096 did the trick for me - I have both the hard shadows and enough detail. And I did not have to implement PCF.;Shadow volumes aren't a very popular technique these days, but if you want perfect sharp-edged shadows they might be worth considering.;I'm not sure what the effective screen resolution of your shadow map is, but I found that bumping the render target of the shadow map to 4096x4096 did the trick for me - I have both the hard shadows and enough detail. And I did not have to implement PCF. If your shadow map resolution is actually higher than your rendering resolution and you don't apply filtering, than you'll actually undersample the shadow map which can result in aliasing.