GrassShader
A game’s own shaping of its grass, in GLSL, spliced in as three’s
onBeforeCompile splices a chunk: Holdfast’s grass gives way to its
cobbled ring and its worn earth, which only its own paint knows.
Properties
Section titled “Properties”| Property | Type | Description |
|---|---|---|
dispose? |
() => void |
What the engine calls once it stops drawing this shape: the grass unmounts, the ground stands on a new surface, the quality level turns the grass off, or the Landscape is handed a new function. It disposes nothing of the shape itself, so dispose here what the function made for it, such as a texture it baked; a texture the game shares elsewhere stays the game’s. |
functions? |
string |
GLSL ahead of the vertex shader’s main: the functions shape calls. Each key of uniforms is declared before it. |
shape |
string |
GLSL run for each blade after the engine’s own, a bunch’s blades near the camera too: it reads bladeRoot, the blade’s root in the world once its clump pulls it in, bladeSeed, 0 to 1 and the blade’s own, groundUp, the y of the ground’s normal there, and coverShare, how much of the ground there grows grass, 0 to 1, and bladeVariety, an int, 0 for the cover’s own blade and 1 to 4 for its varieties in their order, and changes bladeHeight, in metres, bladeColour, in linear light, bladeTipColour, the tip’s colour in linear light, and bladeRootColour, the root’s, each of which left alone follows bladeColour by the material’s ramp, and bladeDryness, 0 to 1, how far its dry patch turned it, which turns a tip left alone to straw and dulls its reflection: a shape that repaints a dry blade sets it to 0. |
uniforms? |
Record<string, ShaderValue | IUniform<ShaderValue>> |
Uniforms by name, each declared ahead of functions: a number, a Vector2, a Vector3, a Color or a Texture, read once, or a three.js uniform, { value }, which the blades share, so a frame that sets its value moves the grass, such as a season’s colour. |