2
\$\begingroup\$

I'm implementing a shadow map algorithm with a spotlight (a spotlight that always "looks" at a given object).

My issue is that for some configuration, part of the object the light is "looking at" is out of the light frustum. As a consequence everything that is not "seen" is shadowed.

To account for this I tried to increase the field of view of the "light camera", but as a result I get very blocky shadows.

Am I doing something wrong? Is there a more clever way to make sure the light can see the whole object? If not, how can I solve the above said artefact?

\$\endgroup\$
1
\$\begingroup\$

The field of view for the shadow map needs to be large enough to cover the whole cone of the spotlight. So if the cone is made wide enough to illuminate the whole object, the shadow map FoV will need to be wide enough to see all of it.

If the shadows are getting too blocky, you'll need to increase the shadow map texture resolution.

If the field of view gets very wide, approaching 180°, then a single shadow map won't work so well anymore—the texture will start to get stretched nonlinearly, putting more resolution around the edges and little at the center. For very wide spotlights or omnidirectional lights, one can use a cubemap (effectively 6 shadow maps pointing in different directions) instead of a single shadow map.

\$\endgroup\$
3
  • \$\begingroup\$ I'm sorry because this is probably an extremely basic question. If I increase the size of the texture I use to render the depth on, I just get the previous depthmap but with padding around. What have I misunderstood? \$\endgroup\$
    – user48448
    Jul 5 '14 at 18:09
  • \$\begingroup\$ @user48448 Did you update the viewport to match the size of the texture? \$\endgroup\$ Jul 5 '14 at 18:31
  • \$\begingroup\$ Gosh, silly me. Thank you! Still got plenty of artefacts, but I believe they're due to a bad bias selection. Thank you very much! \$\endgroup\$
    – user48448
    Jul 5 '14 at 18:47

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.