Hello there fellow programmers, I have found yet an other obstacle in improving shadow mapping. The question is that I am doing some shadow mapping, and can not find any suitable depth biases for it. Some time ago in my XNA project when I was doing it for the first time, I could set it up quite nicely on a terrain, and could find a suitable bias in no time, because, if no bias was set, such acne occured: I was adjusting the bias until the shadows looked fine, that is the basic idea behind it as far as I could understand. This is the result what I am aiming for. Now moved on to DirectX 11, and set up a little scene later, and done some PCF shadow mapping. Then, when setting no bias, there were no such acne, but the shadows were disconnected, such as this (sorry for ugly texturing): It should have acne on the ground, and the shadow of the box connect to the box's edge, but instead it is disconnected. When lowering bias (to a negative), the gap starts to decrease, but soon the whole shadow map darkens before reaching optimal gap distance.
I am using the same shader code (only extended by pcf filtering) as on XNA, so I am assuming it is more to do with the api. Checking out the xna code, I can not even see what the render-to texture formats are, because they are hidden (I guess).
If anyone ever had this problem before, please help me achieve the shadow acne with a zero bias.
UPDATE: This image shows the uneven shadowing on a plain flat quad (the acne should be even across the whole quad, as it is on the terrain in XNA):
UPDATE2: I tried switching culling mode to cull out front-facing faces during the depth render pass, that way the shadows ccan be adjusted a little better, because there is no floor rendered that would darken if bias is modified, but the shadows are still very uneven. Individual meshes' shadows can be adjusted to look good, but then the others get messed up. Somehow, I think, the depth buffer distribution is very uneven, because objects closer to the far plane get better results. Not even my clipping distances are bad, I think. The Shadow Projection is set to 1-2000 depth distribution (in my scene, 1 meter is approximately 200 units), but somehow, accuracy is way off. I have tried depth texture formats of R32_FLOAT and D24_S8_UNORM.
I've seen a similar issue when not setting the 'SlopeScaledDepthBias' property appropriately (also part of the D3D11_RASTERIZER_DESC).
As is explained here, the SlopeScaledDepthBias is an important part of the depth bias calculation, make sure it's initialized to something that makes sense.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With