Light.shadow & light.shadow.camera

shadow

#1

Hi everyone, I have a question regarding shadowMaps for directional lighting.

Within my scene I can get some slick looking shadows if I ramp up the size of my light.shadow.mapSize.width & height to 16382. I set the mapSize to such a large size because the map covers the whole planet and I need the shadows to show with some level of detail for each tree.

here is a screen shot of the result:

As you can see the performance takes a huge hit because the mapSize is so large.
̶̶Q̶u̶e̶s̶t̶i̶o̶n̶ ̶1̶:̶̶̶ ̶w̶h̶a̶t̶ ̶i̶s̶ ̶t̶h̶e̶ ̶d̶i̶f̶f̶e̶r̶e̶n̶c̶e̶ ̶b̶e̶t̶w̶e̶e̶n̶ ̶l̶i̶g̶h̶t̶.̶s̶h̶a̶d̶o̶w̶.̶b̶o̶t̶t̶o̶m̶/̶t̶o̶p̶/̶l̶e̶f̶t̶/̶r̶i̶g̶h̶t̶ ̶a̶n̶d̶ ̶l̶i̶g̶h̶t̶.̶s̶h̶a̶d̶o̶w̶.̶c̶a̶m̶e̶r̶a̶.̶b̶o̶t̶t̶o̶m̶/̶t̶o̶p̶/̶l̶e̶f̶t̶/̶r̶i̶g̶h̶t̶?̶ [ edited out ]
Question 2:
can I adjust light.shadow.camera.bottom/top/left/right dynamically? The idea being that I can adjust the camera’s shadowMap location to correspond with the camera’s position. This might allow me to use a much smaller mapSize and just have it move around the scene with the camera.
Question 3:
I noticed that if I add .castShadow for moving geometry the shadowMap automatically updates to reflect those changes in position. Therefore I’d assume that I should be able to have some measure of custom control over when and why the shadowMap updates. So how can I manually update the shadowMap?

The ugly solution would be to create ump-teen directionalLights with their own respective quadrant of the world to caste a shadowMap, and then turn on and off each light as needed, but I really don’t want to have to do this.

Any help with this issue would be much appreciated.
Thanks in advance.


#2

Answer to Question 1: light.shadow.bottom/top/left & right do not exist. My bad oops.
Answer to Question 2&3: Just change the values of bottom/top/left & right and then fire the function light.shadow.camera.updateProjectionMatrix();

Bonus Answer: to turn off the shadows in a scene, light.castShadow = false;