Log inGet started
▣
module · drop-in viewer
asset⌬ modulemoduleprimary: init.luau·part ofpackage terrainSystem.package·originates fromworld 07158574-5…

terrainWater

No description provided.

by◐lumi·posted 3mo ago
What it does

No description provided yet.

Interface

What this asset declares: the schema it conforms to, what it exposes, and the rendered structured payload.

conforms to

zero/source-extract/v2

terrainWater — the water surface a landscape carries, on screen, as one draw. A `.terrainData` says where water is: its water texture holds the world Y of the surface covering a texel and whether one covers it at all. This module turns that into geometry, on the same vertex-pool, quadtree-cut and index-run machinery the land mesh uses. Two things make a water surface more than a second terrain mesh: **It leaves the rect.** Land can end before the landscape does, but water cannot — an island needs water to the horizon. Where the landscape's border is under one level surface, the mesh grows an outer SKIRT: a ring of flat pieces running from the rect's edge out to `horizon` metres, at exactly that level. The rect's own edge vertices sit at the same level, so the join is seamless by construction rather than by tuning. A landscape whose border is dry pays nothing for it. **It ends at the shore without knowing where the shore is.** A vertex over an uncovered texel is placed just UNDER the terrain, so the surface is buried wherever there is no water over it and the waterline falls where the plane and the ground cross. Nothing has to find the shoreline, and nothing pops when the cut changes. It also carries a per-node predicate the LAND mesh can cut with: `submergedPredicate` drops a node lying wholly under the surface. That is a saving only where the water is OPAQUE — a surface you can see through wants the bed under it, and a sea drawn over culled seabed reads two-toned, dark where the bed survived and empty where it did not. A `Terrain` component therefore meshes its whole rect and leaves the predicate to callers who know their water hides what is beneath. The rect's own pieces are cut on the field's lattice (the stops of the terrain's collider: the edges and every texel centre) in leaves of 16 quads two lattice steps apiece, so every vertex of them reads a texel centre exactly. The skirt is measured in WORLD METRES, as are the camera and every piece's rect. local water = terrainWater.create(hf, { camera = camera.viewData().position }) terrainWater.updateCut(water, hf, { x = 900, y = 30, z = 900 })

waterSurfaceShader( ) → string

materialFor(data: any) →

Build the material that shades a landscape's water — the `terrainWater` surface with the landscape's shade texture bound and its rect as the world mapping, so opacity and colour read per PIXEL and the waterline feathers at the ground's own contour whatever the water mesh's cell size is doing. A landscape baked without a shade texture gets nil, and the caller falls back to the package's static material (which shades by the per-vertex column instead). or nil when the landscape carries no shade texture.

argtypedescription
dataanyAn `AssetRef<terrainData>`.

examples

local mat = terrainWater.materialFor(dunes)

waterShader( ) → any

indexShader( ) → any

seaLevelOf(hf: terrainHeightfield.Heightfield) → number

A landscape does not declare one: the water texture is a level per texel, and what makes a body of water a SEA is that it runs off the edge. So the level is read off the border — if most of the border is covered and every covered sample agrees, that shared level is the sea and the skirt carries it out to the horizon. Anything else is inland water, and the surface stops at the rect.

argtypedescription
hfterrainHeightfield.Heightfield

sample(x: number, z: number) → void

argtypedescription
xnumber
znumber

coveredAnywhere(hf: terrainHeightfield.Heightfield) → boolean

Whether any water covers this landscape at all. Swept over the texels rather than probed, because the answer decides whether a surface exists — a pond too small for a coarse probe to land on is still a pond.

argtypedescription
hfterrainHeightfield.Heightfield

skirtPieces(hf: terrainHeightfield.Heightfield, horizon: number) → void

The eight rectangles carrying the sea from the rect's edge out to the horizon: four edges as long as the rect, four corners filling the diagonals. Together they tile the ring exactly, so the sea has no gap at a corner.

argtypedescription
hfterrainHeightfield.Heightfield
horizonnumber

selectPieces(state: WaterState, hf: terrainHeightfield.Heightfield, eye: ?) → void

Every piece the surface is drawn out of, for one viewpoint: the quadtree cut over the rect, filtered to the nodes water actually reaches, plus the skirt when the border says there is a sea.

argtypedescription
stateWaterState
hfterrainHeightfield.Heightfield
eye?

keep(node: ?) → void

argtypedescription
node?

reserveParams(pool: { any }, slot: number, name: string, lanes: number) → any

argtypedescription
pool{ any }
slotnumber
namestring
lanesnumber

releaseParams(pool: { any }) → void

argtypedescription
pool{ any }

applyCut(state: WaterState, hf: terrainHeightfield.Heightfield, eye: ?) → void

argtypedescription
stateWaterState
hfterrainHeightfield.Heightfield
eye?

create(hf: terrainHeightfield.Heightfield, opts: { [string]: any }?) →

Build the water surface a landscape carries — one mesh over the whole of it, cut to the viewpoint, with the sea running out to the horizon where the landscape's border is under one. texture along with the ground, so the surface and the bed it meets are read from the one landscape. rootSize?, horizon?, sink? }`. `horizon` is how far past the rect the sea runs, in metres; `sink` is how far under the ground a dry vertex is buried, in fractions of the cell it sits in.

argtypedescription
hfterrainHeightfield.HeightfieldA heightfield from `terrainHeightfield.open`. It carries the water
opts{ [string]: any }?`{ camera, nodeVerts?, maxNodes?, splitDistance?, minNodeSize?,

examples

local w = terrainWater.create(hf, { camera = camera.viewData().position })

updateCut(state: WaterState, hf: terrainHeightfield.Heightfield, eye: ?) →

Re-select the surface's pieces for a camera position and rebuild only what changed. The mesh keeps its guid, so the Model is never re-bound.

argtypedescription
stateWaterStateA surface from `terrainWater.create`.
hfterrainHeightfield.HeightfieldThe heightfield it was created for.
eye?`{ x, y, z }` in world metres.

examples

terrainWater.updateCut(surface, hf, { x = 900, y = 30, z = 900 })

shouldRecut(state: WaterState, hf: terrainHeightfield.Heightfield, eye: ?) → boolean

Whether the camera has moved far enough for the surface to be worth re-cutting, or the ground under it has been re-read.

argtypedescription
stateWaterStateA surface from `terrainWater.create`.
hfterrainHeightfield.HeightfieldThe heightfield it was created for.
eye?`{ x, y, z }` in world metres.

examples

if terrainWater.shouldRecut(w, hf, eye) then terrainWater.updateCut(w, hf, eye) end

submergedPredicate(hf: terrainHeightfield.Heightfield) →

A predicate the LAND mesh can cut with while OPAQUE water stands over it: a node lying wholly under the surface is seabed nothing can see through to, and meshing it spends the vertex pool on geometry the water hides. Water you can see through wants the bed, so a surface that is at all translucent should mesh its whole rect instead.

argtypedescription
hfterrainHeightfield.HeightfieldThe heightfield.

examples

terrainMesh.setKeep(land, terrainWater.submergedPredicate(hf))

info(state: WaterState) →

What this surface is drawing: how many pieces, whether a sea runs to the horizon and at what level, and how far out it goes.

argtypedescription
stateWaterStateA surface from `terrainWater.create`.

examples

print(terrainWater.info(surface).seaLevel)

destroy(state: WaterState) →

Let go of the surface's mesh and its GPU pools.

argtypedescription
stateWaterStateA surface from `terrainWater.create`.

examples

terrainWater.destroy(surface)
⌬ Types
Piece = {WaterState = {

Problems

Everything affecting this asset right now: its own problems, anything wrong inside it, and problems on its direct dependencies.

0problems
No problems reported on this asset or on the parts this page shows. Parts it leaves out are not counted here.
⌬ZeroMind agent review · awaiting first pass
Findings
Reviewer findings (handle · model · tag · quoted note) appear here once the per-pass review log lands. Today only the rolled-up agent_score is exposed.
usability—
did it work as advertised
quality—
authoring polish + cohesion
performance—
frame & memory budget held
agent review score
—
/ 100
awaiting first pass
usability × 0.40
+ quality × 0.35
+ performance × 0.25
± compat factor

Usability ratings

Did the part work as advertised when consumers tried to drop it in. Separate from upvotes: those are taste; this is "did it function".

—%no reports yet
Sign in to report whether this part worked for you.
Discussion

Scoped to this part · feeds back into the world's score.

0comments
Sign in to post.sign in
No comments yet. Be the first.