Creates a field; anything not given uses DEFAULT_STATE_FIELD.
Readonlyboundsxy = field minimum relative to render-space zero, zw = size.
Float states, 4 per texel (RGBA = wetness, snow, burn, damage), row-major from (minX, minZ).
Resolved settings. Change them with StateField.set.
ReadonlytextureThe GPU copy (RGBA8, linear filtering).
Bumped on every write.
Minimum x of the region (frame coordinates).
Minimum z of the region (frame coordinates).
Texel size, metres.
Relaxes states towards 0 at rates per second (e.g. { damage: 0 }, { burn: 1 / 86400 }).
Frees the texture.
Calls fn(x, z, i, j) for every texel centre (frame coordinates).
The four states as TSL nodes at a render-space XZ position (default positionWorld.xz). Zero
outside the region. Pass the result straight to applyMaterialStates.
Paints a round brush of radius metres at (x, z). falloff (0…1) is the soft share of the radius.
Values are clamped to 0…1. Returns the number of texels touched.
Replaces all settings: anything not in input goes back to the defaults.
All four states at (x, z), bilinear. Zero outside the region.
Changes the region. Moving center shifts the data by whole texels (what scrolls out is lost, what
scrolls in is zero); changing size or resolution resamples it.
Sets the frame position at render-space zero (floating origin). [x, y, z] or [x, z].
Marks the field changed after writing to StateField.data directly (uploads on the next update).
Uploads changed data to the texture. Call once per frame (cheap when nothing changed).
Writes wetness and snow from Weather.surfaceAt at time. The work is spread over
calls: each call processes rows until budget milliseconds have passed, and a full pass uses the
time it started with, so the whole field is consistent. Returns true when a pass completes.
One state at (x, z), bilinear. Zero outside the region.
Writes one texel directly (clamped to 0…1). i, j are texel column and row.
A low-resolution world-space map of the four material states over a square region: accumulated wetness and snow cover from the weather, burn scars from wildfires, damage from storms and impacts. Terrain, grass and trees sample it in their shaders (StateField.node) and on the CPU (StateField.sample). Stored as float on the CPU and uploaded as an RGBA8 texture (R = wetness, G = snow, B = burn, A = damage).
Coordinates are local frame coordinates. With a floating origin, call StateField.setOrigin with the frame position of render-space zero; the GPU lookup stays exact at any distance.
Example