Vixen
02b45cc4
csharp
public readonly record struct TerrainSplat

What the generated splat material compiles as, derived from a terrain's layer list.

Read the guide page for this →

Remarks

[docs/plan/31 § D6]: the material is generated from the layer list, and nobody wires a graph. Every Unreal project rebuilds the same LandscapeLayerBlend material and every one of them rebuilds it slightly differently, which is why "why is my landscape black" is the most-asked landscape question. A configuration that cannot be miswired does not need a troubleshooting step.

⚠ Two permutation axes and no more. The layer count is quantised to 4/8/12/16 so a terrain gaining a seventh layer does not compile a new shader, and the height path is one bool so a terrain that blends only by weight pays for none of it. What is deliberately not a permutation is which mode each layer uses: that is per layer and the permutation is per material, so eight layers with three modes between them is one shader rather than eight.

Fields and properties (5)

  • public int LayerSlots

    How many layer slots the shader loops over. 4, 8, 12 or 16.

  • public bool HeightBlend

    Whether any layer wants the height path.

  • public int WeightMaps

    How many RGBA weightmaps the layers pack into.

  • public const int MaxLayerSlots

    The most layers a generated material will loop over.

  • public const int LayersPerWeightMap

    How many layers one RGBA weightmap holds.

Methods (8)

  • public TerrainSplat(int LayerSlots, bool HeightBlend, int WeightMaps)

    What the generated splat material compiles as, derived from a terrain's layer list.

  • public static TerrainSplat Of(TerrainWeights weights)

    What a terrain's layers compile to.

  • public static int SlotsFor(int layers)

    Which slot count a layer count compiles for.

  • public int UnusedSlots(int layers)

    How many slots the loop runs and never reads a layer for.

  • public IReadOnlyList<(string Key, object Value)> Permutations()

    The permutation keys the effect is compiled with.

  • public int FillScales(TerrainWeights weights, Span<float> scales)

    Fills the per-layer tiling scales the fragment stage divides its world XZ by.

  • public int FillBlends(TerrainWeights weights, Span<Vector2> blends)

    Fills the per-layer blend mode and contrast the fragment stage reads.

  • public static int Pack(TerrainWeights weights, int map, TerrainRect rect, Span<byte> texels)

    Packs the layer weights into RGBA texels, four layers to a texture.

Used by (3)

  • TerrainRendererVixen.Rendering.Terrain
  • TerrainSplatTestsVixen.Rendering.Terrain.Tests
  • SculptSessionTestsVixen.Editor.Terrain.Tests