6
\$\begingroup\$

I'm using a slope scaled depth bias to reduce shadow acne with shadow maps. However, it's causing artifacts when used with normal mapped surfaces because the bias varies over the surface, where it should really take the normal of the underlying geometry as a bias for all texels instead.

enter image description here

The bias is calculated like this:

float bias = 0.005 * tan(acos(dot(normal,-lightDirection)));

How can I get around this problem, when I don't have geometry information available while applying the shadow map (e.g. during lighting pass of deferred shader)?

\$\endgroup\$
8
\$\begingroup\$

You could apply the bias when rendering the shadow map, instead of when sampling it. I think that's the usual/"standard" approach to shadow map biasing, actually.

BTW, if you want tan(acos(something)), it's probably faster to calculate sqrt(1 - something^2) / something, which is equivalent (using some trig identities). Generally if you're combining forward and inverse trig functions in an equation, there's another way to write it with no trig functions at all.

\$\endgroup\$
  • \$\begingroup\$ apply the bias when rendering the shadow map, instead of when sampling it. I think that's the usual/"standard" approach to shadow map biasing You seem correct. At least the slide 68 of the presentation "Secrets of CryENGINE 3 Graphics Technology", about Shadow Artifacts, agrees with that practice. \$\endgroup\$ – wip Sep 11 '14 at 2:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.