UnityRef is currently in early development. Some features may be incomplete and/or not functioning.

UNITYREF

Your Pit Stop For Solving ANYTHING in Unity

graphics

[HDRP Water] Eliminate Visual Glitches: Subsurface Control with UnderwaterMask

Solution

graphicsshadersrendering

Unity 2022.3.x - Unity 6.3.x

Published Sat, Mar 14

Issue

 Customizing the underside rendering of the HDRP Water System for specific visual effects necessitates identifying the responsible shader or script file within the High Definition Render Pipeline.

Explanation

Configure custom underside rendering for your Water System by utilizing the internal UnderwaterMask buffer.

  1. Open your Shader Graph and create a new HDRP Water shader.

  2. Add the HDSampleBuffer node and set its source to UnderwaterMask.

  3. Implement logic to lerp between surface and underside visual properties based on UnderwaterMask output.

  4. For deep integration, locate core logic in com.unity.render-pipelines.high-definition/Runtime/Material/Water/Water.hlsl.

Additional Tips

  • Use a Custom Pass to inject logic without modifying package files to maintain upgrade path compatibility.

  • Enable ‘State Aware’ water settings to ensure proper depth testing with UnderwaterMask.

  • Review UnderWaterUtilities.hlsl within the package to see how the engine calculates UnderwaterMask volume.

TL;DR

Control water underside rendering by targeting the UnderwaterMask via the HDSampleBuffer node or core HLSL files.


Related Posts Haven't quite found a solution to your problem? We think these posts might help you.

Content inspired by a Unity discussion post.