Table of Contents

Struct TerrainArrayLayerParams

Namespace
FishMMO.Shared
Assembly
FishMMO.Shared.dll

The numbers one terrain layer contributes to the array terrain shader, besides its textures.

public struct TerrainArrayLayerParams
Inherited Members

Remarks

A plain value rather than a UnityEngine.TerrainLayer because the layer whose numbers the ground draws with is not always one a scene may reference: when LOCAL art overrides a layer, its tiling and remaps come from an asset under Assets/LOCAL. These values are therefore copied into the baked TerrainArraySet (build output) and never into the scene.

The packing mirrors what Unity's terrain engine hands URP's TerrainLit, so a layer looks the same in both shaders: the diffuse remap's maximum is a tint (URP ignores the minimum), the mask remap becomes an offset (the minimum) and a scale (maximum minus minimum), and a layer whose albedo carries smoothness in its alpha uses a smoothness multiplier of one.

Fields

AlbedoHasAlpha

True when the albedo's alpha holds smoothness.

public bool AlbedoHasAlpha

Field Value

bool

DiffuseRemapMax

public Vector4 DiffuseRemapMax

Field Value

Vector4

HasMask

True when the layer has a mask map, so metallic, AO and smoothness come from it.

public bool HasMask

Field Value

bool

LegacyTableLength

The length the per-layer arrays had when they were the shader's own fixed-size uniforms, and still have for a scene of that many layers or fewer: a set baked then is the same set now, and every key hashed over its arrays (the ground colour bake's) still matches.

public const int LegacyTableLength = 32

Field Value

int

MaskRemapMax

public Vector4 MaskRemapMax

Field Value

Vector4

MaskRemapMin

public Vector4 MaskRemapMin

Field Value

Vector4

MaximumLayers

The most layers one scene's arrays hold: what a byte of the terrain's index map can name (TerrainIndexMap), and the depth every target graphics API guarantees a texture array.

public const int MaximumLayers = 256

Field Value

int

Remarks

It was 32 (eight control maps of four channels, all read per pixel) until 2026-10-16.

Metallic

public float Metallic

Field Value

float

NormalScale

public float NormalScale

Field Value

float

Smoothness

public float Smoothness

Field Value

float

TileOffset

public Vector2 TileOffset

Field Value

Vector2

TileSize

public Vector2 TileSize

Field Value

Vector2

VectorsPerLayer

How many float4 arrays the shader reads per layer.

public const int VectorsPerLayer = 5

Field Value

int

Properties

Default

The defaults of a fresh UnityEngine.TerrainLayer: what a layer with no settings draws as.

public static TerrainArrayLayerParams Default { get; }

Property Value

TerrainArrayLayerParams

Methods

Allocate(int, out Vector4[], out Vector4[], out Vector4[], out Vector4[], out Vector4[])

Five arrays of length, with every unused slot holding a neutral layer.

public static void Allocate(int length, out Vector4[] st, out Vector4[] tint, out Vector4[] maskOffset, out Vector4[] maskScale, out Vector4[] surface)

Parameters

length int
st Vector4[]
tint Vector4[]
maskOffset Vector4[]
maskScale Vector4[]
surface Vector4[]

Remarks

The shader reads them from the layer table now (TerrainLayerTable), which pads every scene to MaximumLayers itself; a set's arrays are TableLength(int) long.

Allocate(out Vector4[], out Vector4[], out Vector4[], out Vector4[], out Vector4[])

Five arrays of LegacyTableLength, with every unused slot holding a neutral layer.

public static void Allocate(out Vector4[] st, out Vector4[] tint, out Vector4[] maskOffset, out Vector4[] maskScale, out Vector4[] surface)

Parameters

st Vector4[]
tint Vector4[]
maskOffset Vector4[]
maskScale Vector4[]
surface Vector4[]

From(TerrainLayer, bool, bool)

Copies a terrain layer's numbers. The two flags describe the textures the arrays end up holding, which may not be the layer's own.

public static TerrainArrayLayerParams From(TerrainLayer layer, bool hasMask, bool albedoHasAlpha)

Parameters

layer TerrainLayer
hasMask bool
albedoHasAlpha bool

Returns

TerrainArrayLayerParams

Pack(int, Vector4[], Vector4[], Vector4[], Vector4[], Vector4[])

Writes this layer into slot index of the five shader arrays.

public void Pack(int index, Vector4[] st, Vector4[] tint, Vector4[] maskOffset, Vector4[] maskScale, Vector4[] surface)

Parameters

index int
st Vector4[]
tint Vector4[]
maskOffset Vector4[]
maskScale Vector4[]
surface Vector4[]

Remarks

  • st: 1/tile size, offset/tile size — applied to WORLD x/z, so a texture runs straight across tile seams.
  • tint: diffuse remap max rgb, normal scale in w.
  • maskOffset, maskScale: the mask remap as sample * scale + offset.
  • surface: metallic, smoothness multiplier, has-mask flag, 0.

A tile size of zero or less would divide by zero; it is clamped to a millimetre, which shows as obvious noise rather than a NaN that blacks out the ground.

TableLength(int)

The length of a set's per-layer arrays for layerCount layers.

public static int TableLength(int layerCount)

Parameters

layerCount int

Returns

int

Unpack(int, Vector4[], Vector4[], Vector4[], Vector4[], Vector4[])

Reads slot index back out of the five arrays: the inverse of Pack(int, Vector4[], Vector4[], Vector4[], Vector4[], Vector4[]), for tests and the inspector.

public static TerrainArrayLayerParams Unpack(int index, Vector4[] st, Vector4[] tint, Vector4[] maskOffset, Vector4[] maskScale, Vector4[] surface)

Parameters

index int
st Vector4[]
tint Vector4[]
maskOffset Vector4[]
maskScale Vector4[]
surface Vector4[]

Returns

TerrainArrayLayerParams