Builtin Library
- ..
- .metadata17 B
- README.md1.2 KB
- preview.png10.6 KB
- properties.yaml474 B
- shader.wgsl5.0 KB
README.md
grass_material.shader
Grass, shaded root to tip with per-blade colour variation and a soft half-lambert wrap.
The colouring reads uv.y as height along a blade — 0 at the root, 1 at the tip
— and darkens the roots while warming the tips. Per-blade variation comes from a
hash of the fragment's world xz on a 10 cm grid, so every fragment of one blade
shares a seed and neighbouring blades drift apart in hue and brightness. The
lighting is a diffuse half-lambert wrap kept below saturation, so this shader
returns its own final colour instead of a PBR surface.
sway is how far the vertex stage bends each vertex along its blade, and it is
what tells this shader that its mesh is a blade mesh: the bend scales with
uv.y², so a vertex at the root holds still while the tip swings hardest. It
defaults to 0, at which every vertex arrives where the mesh put it — a material
that leaves it there shades a surface without moving it. @builtin::materials.grass
is that ground surface; @builtin::materials.grass_blades sets sway to 1 for a
blade mesh.
Properties
base_color— the grass green the root→tip gradient is built from.sway(0..4, default0) — how far each vertex bends along its blade.