Blocky shadows on Single Layer Water

This has been an issue forever it seems. Is there any way to fix these blocky shadows on water yet, without resorting to raytracing?

I looks like they fixed it for Fortnite as seen in the video here, but it certainly isn’t fixed in 5.2: State of Unreal | GDC 2023 | Epic Games - ESRB: RP to M - YouTube

There is a cvar r.Water.SingleLayer.DepthPrepass, but is seems to be read only.

How would I go about getting the water depth prepass to work?

Read only cvars need to be changed outside of the editor, probably want to do this in the scalability ini file

Edit: Looks like it has to be in the engine ini file (best to keep it in your project’s defaultengine.ini file, not the one installed in the Unreal Engine folder itself), it will trigger a full shader recompile, just a warning. I can confirm that the setting does fix the issue though.

Thanks for the help. I was able to change that setting, but not seeing any improvement in shadow quality. Is there any other setting that is needed for this to work?

Are you in 5.2 preview?

Yes, 5.2 preview.

Where did you put the cvar? And what exactly did you put?

All I did was add: r.Water.SingleLayer.DepthPrepass=1

to DefaultEngine.ini in my project folder, in the Render Settings category.

I really feel like this should just be a checkbox in the project settings. Having a setting this important be an offline cvar seems silly tbh

1 Like

Tried testing it in a new project, still no luck. The renderer settings in a new project seems far less than in your example, so I wonder if another setting needs to be enabled for this to work.

This is what mine looks like in a fresh project (with the added setting):

Nice to see it is working in your project though. Are you on 5.2.0 preview 2?

I just built a new project from scratch, same as yours are enabled. Works fine for me…

Yes, 5.2p2. Honestly no idea what the issue could be.

When you added the setting to your ini file did it recompile all the shaders in the project?

Yes, it did recompile shaders. I’m going to test on some other systems, maybe it is hardware/driver related.

Honestly the only other thing I could think is that you’re not using the SingleLayerWater shading model for your water. That cvar only works on single layer water materials.

OK, I figured it out. I noticed with r.Water.SingleLayer.DepthPrepass=1 while the shadows were still blocky, the blocks would get smaller when you zoom into them. So in searching for other settings I found r.Water.SingleLayer.ShadersSupportVSMFiltering and r.Water.SingleLayer.VSMFiltering.

Adding all 3 the DefaultEngine.ini like so:

r.Water.SingleLayer.DepthPrepass=1
r.Water.SingleLayer.ShadersSupportVSMFiltering=1
r.Water.SingleLayer.VSMFiltering=1

Gives you nice soft virtual shadows on water:

Thanks for the help with this!

7 Likes

@3DMoss oh my god thank you! I was having this same issue for a while now, and randmly started digging through some single layer water cvars as well and googled them to come across this posting. This is the only thing I have ever seen about these documented anywhere. thanks a million!

Does this not work when applied from command line? I have tried with the above cvars from command line, but the hard edges seem to not go away at all.

thank you so much! Same issue and this works for me! 太感谢了

Yes, you need to edit in DefaultEngine.ini