Poor quality shadows on tiny objects

What can I do to improve the shadows in my game? I have a cockpit, with a lot of small detail up close to the camera, and a spotlight a few meters away. The shadows look dreadful, and they shimmer and flicker as the light/cockpit move around... I've changed the shadow quality to Very High but it doesn't seem to have improved things much...

Above is a 5cm diameter tube in the cockpit., lit by a spotlight a few meters away.
Below are some small buttons on the cockpit panel, lit by a point light about 50cm (half a unity unit) away.

I tried scaling everything up by x10, and when I increased the range of the lights by x10 the result was identical.

The problem is the depth buffer resolution.
If you have a gigant distance to cover you will have a poor resolution for small stuff.
A good way to to fix it is to separate it into two different cameras, one for the cockpit and one for the rest of the world.
Fist you draw the world camera (camera does not render the cockpit).
Then the cockpit camera has a small draw distance and only renders the layer that the cockpit is on.
Make sure to set the Cockpit camera to clear depth only.

Digital ApeModerator

There are several assets (some free) which specialise in screen space shadows or contact shadows, these work with a directional light but have the resolution you require close up. These solutions work with Unity's existing shadows.

If it will have to work with point and spot, I can suggest you bake the shadows for it or look into your cascade setup.

The problem is the depth buffer resolution.
If you have a gigant distance to cover you will have a poor resolution for small stuff.
A good way to to fix it is to separate it into two different cameras, one for the cockpit and one for the rest of the world.
Fist you draw the world camera (camera does not render the cockpit).
Then the cockpit camera has a small draw distance and only renders the layer that the cockpit is on.
Make sure to set the Cockpit camera to clear depth only.

Click to expand...

But what sets the depth? Is it the camera far distance? I've tried setting the camera far distance and the shadow distance to 5, and there is no difference that I can see. I got rid of my VR camera rig. I have one standard camera, far distance set to 5, and my light is located 4 units away, and there's nothing else in the world apart from the cockpit, and the shadows are really dreadful :/

Shadows for spot lights, directional lights, and point lights all work differently. In the quality settings you can clamp the max resolution, as well as set it on a per light basis.

Point light shadows in Unity are of especially low quality. Even at high resolution they're going to not look great. Limiting the light's range to the smallest possible will help some, but the stair step effect is unavoidable.

Spot lights will generally have slightly better shadows than point lights, but only so far. Just like point lights keeping the range to a minimum will help significantly, as will setting the near plane as high as possible. But, again, the stair step effect is unavoidable.

Lastly is directional lights. The main directional light gets special treatment on desktop and consoles and will have the highest quality shadows of those built in to Unity. The camera's far plane or max shadow distance, along with the cascade ratios, allow for the highest possible shadow resolution as near and far objects get separate shadow maps. The other thing that will help is reducing the area that there are any shadow casting or receiving objects in the scene. Cascades will help with the shadow map's image resolution, but they can still have problems with depth resolution. The depth is determined by the range of objects in the scene that can receive and cast shadows.

The short version is Unity's shadows are really bad at handling this specific use case. You might have better luck with something like the Next Gen Soft Shadows asset. Especially using the screen space raytraced contact shadows.

Oops...

"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.