We have this shadow artifacting in our game when using a moving directional light. Deferred rendering in 2021. In this gif, I’m rocking the directional light’s X rotation just a little to give you a sense of its entire look.
I can no longer see the video, so just assuming your issue is ‘Shadow Acne’.
I just resolved my issues with this problem and thought I’d share what I did…
Note that small values in the camera Near Clip Plane can make the problem appear worse.
Try increasing you camera’s near clip plane and see if it helps.
Yikes! yes this sort of artifacting can be caused by a series of different issues such as, but definitely not limited to, the shadow resolution, filtering, bias settings, or even the precision of the shadow depth buffer. Since i’m unsure what exactly it is in this case, let try a few things:
Increase shadow resolution: Higher shadow resolution can help improve the quality of shadows and reduce artifacts. You can change the shadow resolution by going to the directional light’s properties in the Inspector and adjusting the “Shadow Resolution” dropdown under the “Shadows” section. Keep in mind that increasing the resolution may impact performance.
Adjust shadow filtering: Unity offers different shadow filtering options that can influence the quality of shadows. You can change the filtering option by going to the “Edit > Project Settings > Quality” and adjusting the “Shadow filtering” setting. PCF (Percentage Closer Filtering) or PCF Soft Shadows usually provide better results than hard shadows, but they can be more performance-intensive, so your mileage may vary, you’ve been warned =)
Tweak shadow bias settings: Incorrect bias settings can lead to shadow artifacts like acne or peter panning (you can read about both acne and peter panning here [docs]). You can adjust the “Bias” and “Normal Bias” settings under the “Shadows” section of the directional light’s properties. Increasing the “Bias” value can help reduce shadow acne, while increasing the “Normal Bias” value can help with peter panning. Be cautious when adjusting these values, as increasing them too much can result in shadow gaps.
Use a cascaded shadow map (CSM): Cascaded shadow maps can provide better shadow quality for different distances from the camera. To enable CSM, In the Built-in Render Pipeline, configure Shadow Cascades per quality level property in your Project’s Quality Settings. In the Universal Render Pipeline (URP), configure Shadow Cascades in the Universal Render Pipeline Asset. In the High Definition Render Pipeline (HDRP), configure Shadow Cascades for each Volume. You can then adjust the “Number of Cascades” and the “Cascade Splits” settings to balance shadow quality and performance. [docs]
Adjust the shadow distance: Reducing the shadow distance can help improve shadow quality by focusing on the shadows closer to the camera. You can change the shadow distance by going to “Edit > Project Settings > Quality” and adjusting the “Shadow Distance” setting.
Use a custom shadow resolution for specific objects: If you have specific objects in your scene that require higher shadow quality, you can assign a custom shadow resolution to those objects using a custom script or Unity’s LOD system. But that may not be relevant in this case since its just the terrain, just thought I’d add it.
Remember that some of these changes can impact performance, so it’s essential to find a balance between shadow quality and performance based on your target platform and the requirements of your game.