7

I've added a directional light to my scene, but it doesn't show all the shadow. The shadow gets cut off, just like when the FOV of a spotlight is too small.

When I enable the shadowCameraVisible, i see that my light is like a big box which shows the shadow (which makes sense). The question is: how can I make this 'box' bigger?

Giel Berkers
  • 2,852
  • 3
  • 39
  • 58

1 Answers1

11

Found it! Turns out the shadowcamera has left, right, top and bottom properties:

light.shadowCameraLeft = -3000;
light.shadowCameraRight = 3000;
light.shadowCameraTop = 3500;
light.shadowCameraBottom = -3000;

If you get pixelized shadows, it means your shadow map (read: memory) is not big enough. Experiment which is the lowest map you need, because this seems to be expensive. Example:

 light.shadow.mapSize.x = 2048
 light.shadow.mapSize.y = 2048
e-motiv
  • 5,795
  • 5
  • 27
  • 28
Giel Berkers
  • 2,852
  • 3
  • 39
  • 58
  • Nice find. Thanks. However when I set as big as I need, the shadows become pixelized. Any idea why? From a certain smaller area the pixelization is gone again..Very weird. – e-motiv Apr 12 '22 at 15:21
  • OK, I fixed it. We need to make shadow map bigger. Expensive, but you can tweak it to what you want. `light.shadow.mapSize.x = 2048; light.shadow.mapSize.y = 2048` – e-motiv Apr 12 '22 at 15:29
  • Actually, even just setting the map bigger makes the size bigger also, so I wonder how this really works. Someone, please advize on this. – e-motiv Apr 12 '22 at 15:39