Log inGet started
World

Sunfall Ridge

Branchmain
Branchesmain
Commitd4ca437cd5

README.md

conifers (module)

Grows Sunfall Ridge's conifers as meshes, deterministically from a species, a variant (1-3) and a level of detail: Norway spruce, silver fir, European larch, Swiss stone pine, mountain (mugo) pine and a dead spruce snag. Each tree is a trunk with a flared foot and dead stubs on the bare bole, carrying whorls of branches whose length follows the species' crown profile (narrow cone, fuller cone, rounded column, dome); each branch is a run of alpha-cut needle-spray cards set in a V along it, drooping and turning up at the tip by species. Every card vertex carries a crown normal (out of the crown and up), the crown's self-shading in its colour and its freedom in the wind in its alpha.

Level 0 (near, ~1.3-3.2k triangles) has every whorl and two cards per segment; level 1 (middle, ~0.4-1k) every other whorl with longer, wider cards; level 2 (far, 24-160) is a stack of jagged needle tiers and a trunk drawn with the canopy shader. Needle and bark textures are alpineMaterials' (the copy the Tidewater library carries).

local C = require("sunfall.dressing.conifers")
local parts = C.parts("spruce", 2, 0)     -- { { mesh, material } }: bark and needles, or the far canopy
print(C.triangles("fir", 1))              -- { near, middle, far }

parts makes each mesh once per session with renderer.mesh.create and holds it; a fresh mesh is kept for 5 s before it can be judged released. material(key) answers needles:<species>, bark:<species> or canopy. Called by sunfall.dressing.Forest.