1
\$\begingroup\$

I'm using a directional light in Unity to cast shadows. However, the shadows don't appear to be "snapped" to the objects creating them. The object appears to be floating in mid air while it actually isn't.

How do I "snap" the shadow to the objects so it looks like it's actually on the ground?

enter image description here

\$\endgroup\$
  • \$\begingroup\$ I don't use Unity but this clearly looks like Peter-Panning caused by too large of a bias \$\endgroup\$ – MickLH Sep 17 '14 at 21:23
  • \$\begingroup\$ That actually was the case (I had bias on 2, changed it to 0)... So easy, feel kind of dumb right now. Well then, thanks. \$\endgroup\$ – Samurai Fox Sep 17 '14 at 21:25
  • \$\begingroup\$ Ah, I didn't see it was already answered, I was working on my answer. Well, it's here for future readers. I still suggest you edit your question to be more clear. \$\endgroup\$ – MichaelHouse Sep 17 '14 at 21:29
2
\$\begingroup\$

Check out the Bias property on your light. From the documentation (specifically the "Shadow Mapping and the Bias Property" section):

It is a mistake to set the bias too high, however, since areas of a shadow near to the object casting it can then sometimes be falsely illuminated. This effect is known as “Peter Panning” (i.e. the disconnected shadow makes the object look as if it is flying above the ground, like Peter Pan).

enter image description here

I suggest you lower the bias value. But don't lower it too much! If it's too low you'll get shadow acne.

enter image description here

\$\endgroup\$
  • \$\begingroup\$ I still get this effect for some objects, even when lowering bias to 0. A cube or a 3d model of a person both offsets the shadow incorrectly even at 0 bias. The person looks exactly like the top screenshot, appearing to hover in the air, although I've made sure that's not the case. A sphere or a cylinder seems to work fine though. \$\endgroup\$ – Aneon Sep 17 '14 at 23:51

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.