Table of Contents

Class TerrainHoleMask

Namespace
FishMMO.Client
Assembly
FishMMO.Client.dll

A terrain's painted holes (GetHoles(int, int, int, int)) as the detail renderers read them: the blade grass (folded into its water line, GrassTerrain.Freeboard), the GPU detail scatter (a mask slice beside its heights; every mesh kind since the CPU chunk renderer went, 2026-10-27). Unity's own detail drawing is off on every terrain they drive, so nothing else keeps a plant out of a cave mouth: the detail layers under a hole still hold whatever the biome scatter painted before the hole was cut, and the 2 m density texels and scatter blocks reach past the hole's edge even where they do not.

public sealed class TerrainHoleMask
Inheritance
TerrainHoleMask
Inherited Members

Remarks

One cell per heightmap cell (UnityEngine.TerrainData.holesResolution = heightmap resolution − 1), cell (x, z) spanning heightmap samples x..x+1 and z..z+1; the terrain shader clips a whole texel (ClipHoles), so a point test of the cell under a root matches the drawn edge.

Constructors

TerrainHoleMask(TerrainData)

public TerrainHoleMask(TerrainData data)

Parameters

data TerrainData

Fields

CellMetres

One cell's side, metres (the terrain's width over Resolution).

public readonly float CellMetres

Field Value

float

PlantClearMetres

How far past a hole's edge no plant roots, metres (2026-10-27, Moron 2: "the ground details don't overlap the hole itself"): the 2 m density texels and scatter blocks spread what the cells beside an opening hold up to its edge, and a blade, a bush or a scattered stone rooted on that edge leans or spreads out over the opening. The cut clears the detail cells round every cave opening wider still (PointOfInterestCaveOpeningClearance.DetailMargin); this is the plants' own margin at every hole, which also keeps them out from under a canyon wall's or a cloud island's rim of rock.

public const float PlantClearMetres = 1.5

Field Value

float

Resolution

Cells per side.

public readonly int Resolution

Field Value

int

StripRows

Rows read per ReadStrip(TerrainData), as the builders read their other layers.

public const int StripRows = 64

Field Value

int

Properties

Any

True once any cell read so far is a hole.

public bool Any { get; }

Property Value

bool

Complete

True once every row has been read.

public bool Complete { get; }

Property Value

bool

Methods

HoleAt(float, float)

Whether the point at normalised terrain coordinates (0..1 across each side) lies in a hole.

public bool HoleAt(float nx, float nz)

Parameters

nx float
nz float

Returns

bool

HoleAtCell(int, int)

Whether cell (x, z) is a hole (clamped to the terrain).

public bool HoleAtCell(int x, int z)

Parameters

x int
z int

Returns

bool

HoleAtSample(int, int)

Whether heightmap sample (x, z) is a corner of any hole cell: the samples whose water line the grass pulls under so its bilinear zero falls on the hole's edge.

public bool HoleAtSample(int x, int z)

Parameters

x int
z int

Returns

bool

KeepClear(bool[], int, float, float)

Turns every solid cell whose square comes within metres of a hole cell's square into a hole, in place (solid row z first, true solid; the holes as they were before the call decide, so it never spreads further). Pure.

public static void KeepClear(bool[] solid, int resolution, float cellMetres, float metres)

Parameters

solid bool[]
resolution int
cellMetres float
metres float

KeepPlantsClear()

Counts every cell within PlantClearMetres of a hole as one (in place, once every row is read): the mask the plant builders read (the blade grass and the GPU detail scatter), never the terrain's own holes, which the clouds and the ambient life read through a mask of their own.

public void KeepPlantsClear()

Read(TerrainData)

The whole mask at once; null when the terrain has no hole.

public static TerrainHoleMask Read(TerrainData data)

Parameters

data TerrainData

Returns

TerrainHoleMask

ReadForPlants(TerrainData)

Read(TerrainData) with the plants' margin round every hole (KeepPlantsClear()); null when the terrain has no hole.

public static TerrainHoleMask ReadForPlants(TerrainData data)

Parameters

data TerrainData

Returns

TerrainHoleMask

ReadStrip(TerrainData)

Reads the next StripRows rows.

public void ReadStrip(TerrainData data)

Parameters

data TerrainData

ToTexels(int)

The mask as R8 texels at the heightmap's resolution (cell (x, z) at texel (x, z), 0 a hole, 255 solid; the last row and column solid), the detail scatter's slice.

public byte[] ToTexels(int heightResolution)

Parameters

heightResolution int

Returns

byte[]