I noticed something very strange. When I change the shadow distance in the settings, it also affects their strength.
For example, if I have an object that is 40 meters away from the camera, and I set the shadow distance to 40 or 41, the shadows appear, but almost transparent. If I increase it to 50, the shadow of the same object, in the same shape, appears much stronger than before. See attachment that illustrates this.
I’m using the built in render pipeline.
Why does this happen? Is it a bug perhaps? If it is intentional, is there a way to disable this effect?
Shadow distance controls how far from the camera the shadows are visible, not how far away an object is before it stops casting shadows. This distinction is more obvious if you have something like a single long wall out into the distance casting a shadow, you can see the shadows fade away as the world position reaches the shadow distance. The intention is explicitly to avoid the hard cutoff that would be visible if it didn’t fade out.
The distinction is also relevant because an object that’s much, much further away from the camera can still cast a shadow if the shadow it casts is near the player.
It’s also not something that can be disabled, not directly. You can override Unity’s screen space shadows shader in the Graphics settings, if you’re targeting desktop or consoles.
There are a few threads on the topic out there on how to modify the screen space shadow shader to remove the fade, but unfortunately they all date back to an older version of Unity, so the information is no longer relevant and can’t be directly applied to the current version of Unity.
How do you change the current shader to fix it? I have no idea! It’s not something I’ve ever wanted to do, so I’ve never taken the time to figure it out.
Just keep the shadow distance a little larger than you “need” it to be.
Thanks. In my case the camera varies between top-down and isometric, so I’m trying to dynamically set the shadow distance to prevent objects way outside the frustrum being rendered for their shadows. Unfortunately that creates the effect of shadows fading out. I guess I’ll just have to give them a few extra meters on top of to prevent that.