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

[URP Shader Graph] Exceed Terrain 4-Layer Limit

Solution

terrain systemshader graphurplevel design

Unity 2021.3.x - Unity 6.3.x

Published Thu, Mar 12

Issue

 A challenge exists when attempting to utilize more than four Terrain Layer assets within a Universal Render Pipeline (URP) Shader Graph. The default behavior does not natively support the Add Pass methodology employed by the built-in Terrain shader, leading to incorrect blending and display errors when the Terrain Layer count increases.

Explanation

To correctly implement support for more than four Terrain Layer instances in a URP Shader Graph, it is necessary to replicate the Add Pass rendering strategy. While HDRP natively supports up to eight layers in a single pass, URP employs a multi-pass approach, allowing an extended number of Terrain Layer additions.

  1. Configure a base pass to render the initial four Terrain Layer textures as opaque geometry.
  2. Define subsequent passes using an Additive blending mode for every additional set of four layers.
  3. Remap the texture indices for each additive pass back into the [0,3] range within your script to ensure proper sampling by the Shader Graph nodes.
  4. Utilize the Splat Control maps to mask each pass, ensuring the output accurately reflects the blending logic for every Terrain Layer.
  5. Ensure your script or shader logic accounts for the offset in the Splat Map index when sampling beyond the first texture.

Additional Tips

  • Check the Terrain inspector to confirm how many Terrain Layer objects are assigned to ensure the Splat Map count matches your shader passes.
  • Monitor performance, as each additional Terrain Layer pass increases the draw call count for the terrain mesh.
  • For Unity 6, verify Render Graph compatibility if using custom pass injections to handle the Terrain Layer rendering loop.

TL;DR

Support higher Terrain Layer counts in URP by implementing multi-pass rendering and index remapping within your custom Shader Graph logic.


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.