Class TerrainTileLayerMap
The arithmetic of per-tile terrain layers (TerrainTileLayers): which of a tile's alphamap channels it keeps, the compacted alphamaps, and how a tile's channel numbers become the scene's layer ids wherever the ground is read by layer (the index map bake, the ground colour, the grass's surface layers). Pure, so the tests run it without Unity.
public static class TerrainTileLayerMap
- Inheritance
-
TerrainTileLayerMap
- Inherited Members
Remarks
Why. Every tile of a cut used to carry the scene's whole palette: Moron 2's 210 layers are 53 control maps of 512² RGBA with mips, 74 MB a tile, when no tile paints more than 62 of them (measured over the saved tiles, 2026-10-27). A tile now keeps exactly the layers it paints: those with a non-zero weight byte anywhere on it. No weight changes, so every texel — the ones on a seam too — holds the bytes it held, and two tiles meeting at a seam agree there as before, whatever either keeps. Dropping light layers by a threshold as well was measured and refused: 1–5% fewer maps for a visible change.
The scene's numbering stays the truth. The texture arrays, the layer table, the index maps, the backdrop's channels
and the path slices all count the scene's layers (the binder's provenance, one entry per array slice). A tile's channel
c is scene layer SceneLayers[c], its channels kept in scene order, so ties between equal weights still go to
the lower scene layer as they did. Null means a tile that carries the whole palette in scene order (every scene cut
before this): channel and scene layer are the same number.
Fields
MaximumTileLayers
The most layers a tile may still paint after it is compacted, where the cut reports an ERROR: 24 control maps (33 MB a 512² tile). The busiest tile measured paints 65 (Moron 3 1_1, 2026-10-27).
public const int MaximumTileLayers = 96
Field Value
Methods
Bake(float[,,], int[])
The index map of a tile's alphamaps in scene layers: Bake(float[,,]) of its channels, the ids renamed by its map. What the cut stores and what the client build checks it against.
public static uint[] Bake(float[,,] alphas, int[] sceneLayers)
Parameters
Returns
- uint[]
BakeTable(int[])
The table an index map bake renames its ids by (null for identity): a tile's own scene layers, then — for the slots a tile of fewer than Slots layers fills with zero-weight phantoms (channels L..3) — the lowest scene layers it does not hold, so a texel's four ids stay distinct after the rename as they were before it.
public static int[] BakeTable(int[] sceneLayers)
Parameters
sceneLayersint[]
Returns
- int[]
Compact(float[,,], int, int[], int[], float[,,])
One strip of a tile's alphamaps ([row, x, channel] as GetAlphamaps returns them) into the compacted tile's rows
rowBase..: output channel outputOf[i] takes input channel keep[i]
— exactly, a weight read from a byte writes back to that byte — and two kept channels of one scene layer are summed.
public static void Compact(float[,,] strip, int rowBase, int[] keep, int[] outputOf, float[,,] compact)
Parameters
ControlBytes(int, int)
Bytes of a tile's control maps: MapsFor(int) RGBA32 maps of resolution², every mip.
public static long ControlBytes(int layers, int resolution)
Parameters
Returns
IsIdentity(int[])
True when the map changes nothing: null, or every channel its own scene layer.
public static bool IsIdentity(int[] sceneLayers)
Parameters
sceneLayersint[]
Returns
Keep(bool[], int[])
The channels a tile keeps: every one painted (painted: a non-zero weight byte anywhere on the tile),
ordered by the scene layer each holds (sceneOfChannel, -1 where unknown: those last, in channel
order), at least one (channel 0 for a tile painted nowhere). A channel naming the same scene layer as an earlier kept
one is still listed: Compact(float[,,], int, int[], int[], float[,,]) folds it into that one.
public static int[] Keep(bool[] painted, int[] sceneOfChannel)
Parameters
Returns
- int[]
MapsFor(int)
The control maps a tile of layers layers carries (four channels each).
public static int MapsFor(int layers)
Parameters
layersint
Returns
MarkPainted(float[,,], bool[])
Marks every channel of a strip that has a non-zero weight byte anywhere in it.
public static void MarkPainted(float[,,] strip, bool[] painted)
Parameters
Remap(uint[], int[])
A whole index map (two words a texel) renamed in place: the CPU half of what the GPU bake does with the same table, so a stored map and a live one say the same.
public static uint[] Remap(uint[] map, int[] table)
Parameters
Returns
- uint[]
RemapIds(uint, int[])
A texel's id word with every id renamed by table (ids past it unchanged).
public static uint RemapIds(uint ids, int[] table)
Parameters
Returns
Resolve<T>(IList<T>, IList<T>)
A tile's scene layer per channel: the index in scene (the scene's layers, the binder's provenance) of
each of own (the tile's terrain layers), the first where one is listed twice; a layer the scene does
not name, or a missing one, gets a distinct number past the scene's count.
public static int[] Resolve<T>(IList<T> own, IList<T> scene) where T : class
Parameters
Returns
- int[]
Type Parameters
T
SceneLayerOf(int[], int)
The scene layer a tile's channel holds (itself for a tile without a map).
public static int SceneLayerOf(int[] sceneLayers, int channel)
Parameters
Returns
SceneLayersOf(int[], int[], int, out int[])
The scene layers of the kept channels, one per output channel of Compact(float[,,], int, int[], int[], float[,,]) (a scene layer named twice is
listed once, at its first channel). Unknown channels (-1) are given scene layers past sceneLayerCount,
distinct, so they still read as themselves.
public static int[] SceneLayersOf(int[] keep, int[] sceneOfChannel, int sceneLayerCount, out int[] outputOf)
Parameters
Returns
- int[]
Union<T>(IList<T>, IEnumerable<IList<T>>)
The scene's layers once its tiles carry their own: every layer recorded names, in its order (none
dropped or moved: the arrays, the stored index maps and the tiles' maps count by it), then every layer a tile carries
that it does not, in tile order.
public static List<T> Union<T>(IList<T> recorded, IEnumerable<IList<T>> tiles) where T : class
Parameters
recordedIList<T>tilesIEnumerable<IList<T>>
Returns
- List<T>
Type Parameters
T