Skip to main content

Module grass

Module grass 

Source
Expand description

Procedural grass. The patch is split into square chunks; each chunk is one merged mesh with its own bounds, so the renderer frustum-culls whole chunks. Wind animation and distance thinning happen on the GPU in builtin:grass; the meshes are built once.

Chunks are Transient child entities: they never appear in the hierarchy or in saved scenes.

Structs§

Grass
Seeded grass patch split into transient mesh chunks for frustum culling. Wind is animated by the grass shader; geometry is rebuilt when parameters change.

Constants§

BLADE_TRIANGLES
Triangles per blade, both sides.
BLADE_VERTICES
Vertices per blade: four rows of two plus the tip.

Functions§

chunk_grid
Grid of chunks covering the patch: (columns, rows).
chunk_mesh
Builds the blades of chunk (ix, iz); vertices are relative to the chunk centre.
update
Rebuilds changed grass patches and their transient mesh chunks.