Single Layer Water: Purpose of Depth Prepass

Hello,

We are trying to understand exactly what the Depth Prepass is doing for Single Layer Water and why it is considered required in the code.

We are aware that to achieve soft shadows on Single Layer Water, it requires the following cvars:

  • r.Water.SingleLayer.ShadersSupportVSMFiltering
  • r.Water.SingleLayer.VSMFiltering
  • r.Water.SingleLayer.DepthPrepass

The first two seem pretty clear. Toggling the VSMFiltering has a notable effect on the water shadows going from completely crisp to expected soft shadows (see images). However, there seems to be no effect from changing Depth Prepass. A look at the code say the Depth Prespass is required (see code snippet). So could you please clarify this for us? Specifically:

  1. Confirmation the Depth Prepass is required
  2. And why VSM is dependent on the Depth Prepass

Thank you

bool IsSingleLayerWaterDepthPrepassEnabled(const FStaticShaderPlatform Platform, const FStaticFeatureLevel FeatureLevel) { static const auto CVarWaterSingleLayerDepthPrepass = IConsoleManager::Get().FindConsoleVariable(TEXT("r.Water.SingleLayer.DepthPrepass")); const bool bPrepassEnabled = CVarWaterSingleLayerDepthPrepass && CVarWaterSingleLayerDepthPrepass->GetInt() > 0; // Currently VSM is the only feature dependent on the depth prepass which is why we only enable it if VSM could also be enabled. // VSM can be toggled at runtime, but we need a compile time value here, so we fall back to DoesPlatformSupportVirtualShadowMaps() to check if // VSM *could* be enabled. const bool bVSMSupported = DoesPlatformSupportVirtualShadowMaps(Platform);

Hi! That’s the pass which marks VSM pages for update. In some cases where there is geometry close below the water the pages will already be updated so there’s no difference, but it’s not something that can be relied on. If VSM page marking isn’t done properly it can result in extremely blocky shadows. Also we have plans to use the depth prepass for other improvements, like the recently added depth occlusion mask https://github.com/EpicGames/UnrealEngine/commit/672ebfc3e3065bf6bc2cabbb593ab64a3094cade

// Kevin

Thank you for that info, Kevin. Appreciate it.