Class TerrainLayerTable
A scene's per-layer numbers as one small float texture the array terrain shader loads by layer: column = layer,
row = which number. Replaces the per-layer uniform arrays (_FishLayerST[32] and the rest).
public static class TerrainLayerTable
- Inheritance
-
TerrainLayerTable
- Inherited Members
Remarks
Why a texture. At 256 layers the six arrays and the three path tables would be 27 KB of constants, pushed per
terrain tile through its property block — more than the 16 KB uniform block OpenGL ES and WebGL guarantee, and
exactly the pattern that broke the grass on OpenGL (large constant arrays varied per draw:
unity-gl-indirect-args-barrier-bug). A structured buffer is not readable in a WebGL 2 fragment shader. A texture is
one binding everywhere, read with Load (no sampler, exact floats).
Rows, Width columns each (Pack(int, Vector4[], Vector4[], Vector4[], Vector4[], Vector4[]) for the first five):
- RowST: 1 / tile size and offset / tile size, applied to world x/z.
- RowTint: the diffuse remap maximum (a tint), normal scale in w.
- RowMaskOffset, RowMaskScale: the mask remap as sample × scale + offset.
- RowSurface: metallic, smoothness multiplier, has-mask flag.
- RowFlora: what the layer is made of for the planet's looks (LayerFlora()).
- RowPaths: the slices of the layer's own biome's path ground, road ground and cobbles (−1 none).
- RowBackdrop: not a layer's but a backdrop channel's: the scene layer channel c of the backdrop's control maps holds (ControlLayers), c itself when the backdrop names none.
- RowGlow: the layer's glow (2026-10-25, phase I2r; Biomes.BiomeGroundGlow.Pack), zero for none.
- RowClock: how the layer follows the shared clock (2026-10-26, phase GROUND-BANDS; Biomes.BiomeGroundClock.Pack): x kind, y from, z to, w falloff; zero for none.
- RowClockShare: x the share a clocked layer keeps outside its window, y the layer that takes the rest (−1 none), w 1 in every column when any layer of the scene follows a clock (the shader's one test before it reads more).
Columns past the scene's layers hold a neutral layer, no flora and no paths, as the arrays' unused slots did.
Fields
RowBackdrop
public const int RowBackdrop = 7
Field Value
RowClock
public const int RowClock = 9
Field Value
RowClockShare
public const int RowClockShare = 10
Field Value
RowFlora
public const int RowFlora = 5
Field Value
RowGlow
public const int RowGlow = 8
Field Value
RowMaskOffset
public const int RowMaskOffset = 2
Field Value
RowMaskScale
public const int RowMaskScale = 3
Field Value
RowPaths
public const int RowPaths = 6
Field Value
RowST
public const int RowST = 0
Field Value
RowSurface
public const int RowSurface = 4
Field Value
RowTint
public const int RowTint = 1
Field Value
Rows
Rows.
public const int Rows = 11
Field Value
Width
Columns: one per layer an index map can name.
public const int Width = 256
Field Value
Methods
Create(string)
A table texture, empty: RGBA float, point, clamped, no mips, never saved.
public static Texture2D Create(string name)
Parameters
namestring
Returns
- Texture2D
Fill(Texture2D, Vector4[])
Writes packed texels (Pack(int, Vector4[], Vector4[], Vector4[], Vector4[], Vector4[], Vector4[], float[], float[], float[])) into a table and uploads it.
public static void Fill(Texture2D table, Vector4[] texels)
Parameters
tableTexture2DtexelsVector4[]
Pack(TerrainArraySet, float[], float[], float[], int[])
The table of a baked set (its numbers and flora), a scene's path maps and its backdrop's channels.
public static Vector4[] Pack(TerrainArraySet set, float[] earth, float[] road, float[] stone, int[] backdropChannels = null)
Parameters
setTerrainArraySetearthfloat[]roadfloat[]stonefloat[]backdropChannelsint[]
Returns
- Vector4[]
Pack(int, Vector4[], Vector4[], Vector4[], Vector4[], Vector4[], Vector4[], float[], float[], float[], int[], Vector4[], Vector4[], Vector4[])
The table's texels, row after row (texel (layer, row) at row × Width + layer).
public static Vector4[] Pack(int layerCount, Vector4[] st, Vector4[] tint, Vector4[] maskOffset, Vector4[] maskScale, Vector4[] surface, Vector4[] flora, float[] earth, float[] road, float[] stone, int[] backdropChannels = null, Vector4[] glow = null, Vector4[] clock = null, Vector4[] clockShare = null)
Parameters
layerCountintThe scene's layers; columns past it are neutral.
stVector4[]tintVector4[]maskOffsetVector4[]maskScaleVector4[]surfaceVector4[]floraVector4[]Per layer what it is made of; null leaves the row zero (the looks then leave the ground as it is).
earthfloat[]Per layer its biome's path ground slice (−1 none); null or short: −1 past it.
roadfloat[]stonefloat[]backdropChannelsint[]The scene layer of each backdrop channel; null or short: the channel's own number.
glowVector4[]Per layer its packed glow (LayerGlow); null or short: none past it.
clockVector4[]Per layer its packed clock (LayerClock); null or short: none past it.
clockShareVector4[]Per layer its clock's floor and yield layer (LayerClockShare); null or short: none.
Returns
- Vector4[]