Understanding shadowMap.camera

If I take a guess, the shadow map camera is the one from the light’s perspective? So then the far value for that camera determines how far away shadows can appear? If objects are further than that from a light, the shadows don’t appear?

Did I guess right?

(I’ll play around with it to try to decipher it)


Yes, that is the purpose of far. It says basically how far away the shadow is even relevant plus it’s comparison to other lights (the sun outdoes a simple lamp, so the lamp wont cast any shadow). So it’s not only distance, but almost like power.

light.shadow.mapSize.width = 512;  // default
light.shadow.mapSize.height = 512; // default
light.shadow.camera.near = 0.5;       // default
light.shadow.camera.far = 500      // default

I hope that answers your question :slight_smile:

Cool, thanks for painting that picture @TheCodeCrafter. Do you mean light.shadow.camera.far is like power? Does the shadow abruptly cut off after that point?

So (I’m guessing) in our scenes we need to take care to make sure the light camera always encompasses the objects that shadow will be rendered on, otherwise the Z clipping of the shadow area could cause irregular shadow shapes on the receiving objects if they are intersecting with the far plane of the light camera.

Interesting. I’m trying to make things easy in my API, so I think what I’ll do is somehow allow the user to specify a light, which objects are receivers of shadows from that light, then my API internally would adjust the light camera dimensions to make sure it automatically encompasses the furthest object. I want the dev experience to be super simple (for HTML devs that may not know much JavaScript let alone how to write an algorithm to dynamically adjust the camera frustum).

No, like I said, that represents the power of such, it isn’t a hard distance. So, there is still smooth lighting.

@TheCodeCrafter Have you tested that? As far as I know, shadows will cut off abruptly after the shadow.camera.far point.

1 Like