I have an LOD system based on multiple cameras and camera culling layers.
The setup has 3 cameras: High, Mid, and Low, each camera has its own culling layer and their clipping planes are set: High = 0-15, Mid = 15-30, Low = 30-1000, with Clear flags set as: Depth only, Depth only, Skybox.
The system works great but SHADOWS are creating a problem in that they start to fade out as they approach the far clipping plane.
eg. I start with the camera far away from an object so it appears in the Low camera, then I start to move the camera towards the object. When the Mid camera’s far clipping plane reaches the object, the Mid culling layer is revealed as expected, and the Mid object starts to appear BUT it appears fully lit with no shadows. The shadows start to fade in as the camera moves closer to the object and then the whole process happens again as the object passes from the Mid to High camera.
I’ve adjusted the Shadow Distance setting in Project Settings → Quality but it didn’t help.
I tried adjusting the Shadow Distance in each camera’s OnPreRender so that Shadow Distance would be camera dependent, but again, this didn’t work.
How can I ensure that shadows are applied to all objects between a cameras clipping planes?
Try having just one shadow cascade per camera. That might fix it. Maybe. Mostly, though, this is going to be tough because it’s a non-standard way to render and Unity shadows make a lot of assumptions.
Thanks for the suggestion. Sadly the cascades don’t make any difference that I can see to shadow length or fall-off distance.
This behaviour seems odd to me, as in, if I were to use the culling layers for their “designed” purpose of having smaller mesh objects only appearing when closer to the camera, I would still be getting an arc of undesirably shadow-less objects. Is this how the system is supposed to function?
So, Unity’s directional shadows are cascaded shadows. The idea is similar to your LOD setup, but for shadows. With cascaded shadow implementations, one of the classic problems is having hard seams between the cascades and at the end of the final cascade. You can get around this by blending between cascades, and also by fading out the last cascade. Of course it doesn’t make sense to render cascades beyond the camera’s frustum, and most games have shadow distances that are a fraction of the draw distance. I bet that Unity assumes that shadows should always fade out, should never be bigger than the camera frustum, so there’s essentially a forced fade out range for shadows if shadow distance is greater than or equal to the camera distance.
TL;DL not sure you can fix this easily.