Blurring the shadows in order to avoid flickering

Hi guys,

is there any post-process method to blur the Unity shadows (hard or soft) in order to avoid the flickering of those at distance?

I’m working on a driving simulator and the flickering is quite popping up while you are driving, so I’m wondering if there is any solution about this. I don’t care about shadow resolution, the main goal is to have stable shadows.

as you can see in the image the shadows loose their detail as they are far to the camera as they aren’t antialiased at all.

Using Soft shadows don’t solve the issue because shadows are softened only near the camera.

Thank you

Anyone? I’m ready to evaluate a shadow replacement technique to buy, but I don’t find any solution that fits my needs.

Reduce the shadow distance and use dual lightmaps?

I can’t use lightmaps for two main reasons:

1: The light must be realtime because I have a custom sky system and change the light position according to real world position at different time is crucial for this project

2: My tarmac shader is custom and use already the second UV channel in order to render static/dinamic grooves.

Hmm… you could possibly modify the shadow collector pass to scatter it’s samples further based on distance? Might end up with some odd artifacts further away though…

I think it will be a good thing to try but I don’t know how :slight_smile:

Sorry for the late reply, Sim.

Well…

Because Unity doesn’t expose the shadow map, you can’t apply post effect on it directly…

But!

You can however, render the shadow into the render target and then blend it back to the scene using the post effect of your own.
In order to render the shadow only to your render target , you need to set up another camera render everything using the replacement shader that only shows the shadow. (with background white)

Then, with your main camera, you can use that render target texture and post process it with blur filter and do simple multiply blend with the scene.

It is pretty simple process. It is just that it will certainly will cost more than just rendering straight with Unity shadow.

Let me know if you have any problems.