voxolith

Grass

@voxolith/gen-grass: ground cover (grass, meadow with flowers, reeds with seed heads, arching ferns, dry grass) as blades that each reach the ground.

The five grass presets: grass, meadow, reeds, fern and dry

@voxolith/gen-grass makes patches of ground cover. A patch is many independent blades, not one connected object: tufts scatter over a disc, each tuft fans a handful of blades out of the ground, and every blade is a single stem one voxel thick that bends under its own weight.

import { seededRandom } from "@voxolith/renderer/core";
import { generateGrass, PRESETS } from "@voxolith/gen-grass";

const { entity, stats } = generateGrass(PRESETS.meadow, seededRandom(42));
// entity.kind === "groundcover"; stats.blades, stats.flowers, stats.seedHeads

Unlike a tree, the result is deliberately many pieces. The guarantee is that every blade reaches the ground, which is what the contract's grounding check asks.

How it works

Tufts. Tuft centres scatter over a disc of radius footprint, with a square-rooted radius so the scatter is even rather than bunched at the centre. Each tuft fans its blades out of a small base at fanDeg from vertical, at lengths between lengthMin and 1 of height.

Blades. Every blade is a level-0 stem grown by growBranches with no trunk rigidity: gravity (arc) is the whole silhouette, from standing straight up to arching right over. A fern adds one level of children in pairs down both sides of the midrib: its leaflets.

Rasterise, recording which blade wrote each voxel. Blades under a voxel radius are DDA lines, 6-connected by construction.

Colour along each blade, dark at the base to light at the tip, per blade rather than per patch. Whole blades dry off, never individual voxels: speckling reads as noise rather than as a dry season.

Heads on the tips of whole blades: flower heads in three colours (flowers) or elongated seed heads (seedHeads). In winter, snow dusts the top faces.

Prune whatever does not reach the ground, flooding from the whole ground plane rather than from one point, since the blades are independent.

The look comes almost entirely from three things: how far blades splay from vertical (fanDeg), how hard they arc over (arc), and the gradient along each blade. Voxel values are tuned for a 24-tall patch and scale with shape.height.

Presets

presetcharacter
grassa patch of lawn-like tufts
meadowtaller, more tufts, with flower heads and a few dry blades
reedstall, upright, barely fanned, with seed heads
fernarching fronds carrying leaflets down both sides of a midrib
dryshort, heavily arched, mostly dried off, with small seed heads

Finer scales

At 20, 50 and 100 voxels per metre the blades are redrawn from the skeleton as thin rods a voxel or two across, rooted and arching like the coarse ones and shaded base to tip from them; flowers become small petal discs and seed heads stay compact. Flowers, seed heads and snow are loose roles. See scales and refinement.

Development

bun run --cwd generators/grass verify           # every blade reaches the ground, budget, determinism
bun run --cwd generators/grass preview species  # contact sheets into previews/ (also: seeds, seasons)
bun run --cwd generators/grass gen              # bake .vox files into out/

Grass

voxolith/grass starts from the grass preset.

Id
voxolith/grass
Version
0.1.0
Scales
10, 20, 50, 100 voxels per metre

Parameters

Shape

ParameterPathRangeDefault
Blade length
length of the tallest blade in voxels (10 per metre); shorter blades are a fraction of it
shape.height4 to 8024
Patch radius
radius of the disc the tufts are scattered over, in voxels
shape.footprint2 to 48, step 111
Fan
how far blades splay from vertical, in degrees; 0 stands them upright
shape.fanDeg0 to 60, step 113
Arc
downward bend per voxel of blade; 0 is straight, high values arch right over
shape.arc0 to 0.12, step 0.0020.012
Blade thickness
blade radius in voxels; below 1 a blade is a clean one-voxel line
shape.radius0.3 to 2, step 0.050.6

Look

ParameterPathRangeDefault
Season
blade colours; winter also dusts the upper faces with snow
look.seasonspring, summer, autumn, wintersummer
Dry blades
fraction of whole blades that have dried off to straw
look.dry0 to 1, step 0.020.1
Flowers
fraction of blades ending in a flower head, in three colours
look.flowers0 to 0.6, step 0.010
Seed heads
fraction of blades ending in a seed head, as on reeds and cereals
look.seedHeads0 to 1, step 0.020

Presets

Parametergrassmeadowreedsferndry
Blade length2430563422
Patch radius1115141211
Fan131673022
Arc0.0120.0140.0040.010.032
Blade thickness0.60.60.650.70.6
Seasonsummersummersummersummersummer
Dry blades0.10.080.180.10.75
Flowers00.14000
Seed heads000.300.2

Roles

Voxel values are these roles, in this order (value 1 is the first). The colours are the defaults; a host maps each role to a palette slot and can restyle it.

  • 1Blade base blade.lo
  • 2Blade mid blade.mid
  • 3Blade tip blade.hi
  • 4Dry blade blade.dry
  • 5Stalk stalk
  • 6Seed head seed · may float when refined
  • 7Flower A flower.a · may float when refined
  • 8Flower B flower.b · may float when refined
  • 9Flower C flower.c · may float when refined
  • 10Snow snow · may float when refined

Meadow

voxolith/meadow starts from the meadow preset.

Id
voxolith/meadow
Version
0.1.0
Scales
10, 20, 50, 100 voxels per metre

Parameters

Shape

ParameterPathRangeDefault
Blade length
length of the tallest blade in voxels (10 per metre); shorter blades are a fraction of it
shape.height4 to 8030
Patch radius
radius of the disc the tufts are scattered over, in voxels
shape.footprint2 to 48, step 115
Fan
how far blades splay from vertical, in degrees; 0 stands them upright
shape.fanDeg0 to 60, step 116
Arc
downward bend per voxel of blade; 0 is straight, high values arch right over
shape.arc0 to 0.12, step 0.0020.014
Blade thickness
blade radius in voxels; below 1 a blade is a clean one-voxel line
shape.radius0.3 to 2, step 0.050.6

Look

ParameterPathRangeDefault
Season
blade colours; winter also dusts the upper faces with snow
look.seasonspring, summer, autumn, wintersummer
Dry blades
fraction of whole blades that have dried off to straw
look.dry0 to 1, step 0.020.08
Flowers
fraction of blades ending in a flower head, in three colours
look.flowers0 to 0.6, step 0.010.14
Seed heads
fraction of blades ending in a seed head, as on reeds and cereals
look.seedHeads0 to 1, step 0.020

Presets

Parametergrassmeadowreedsferndry
Blade length2430563422
Patch radius1115141211
Fan131673022
Arc0.0120.0140.0040.010.032
Blade thickness0.60.60.650.70.6
Seasonsummersummersummersummersummer
Dry blades0.10.080.180.10.75
Flowers00.14000
Seed heads000.300.2

Roles

Voxel values are these roles, in this order (value 1 is the first). The colours are the defaults; a host maps each role to a palette slot and can restyle it.

  • 1Blade base blade.lo
  • 2Blade mid blade.mid
  • 3Blade tip blade.hi
  • 4Dry blade blade.dry
  • 5Stalk stalk
  • 6Seed head seed · may float when refined
  • 7Flower A flower.a · may float when refined
  • 8Flower B flower.b · may float when refined
  • 9Flower C flower.c · may float when refined
  • 10Snow snow · may float when refined

Fern

voxolith/fern starts from the fern preset. Its leaflets are a branch level in the preset, not a parameter, so a share code carries the fern's shape by its generator id.

Id
voxolith/fern
Version
0.1.0
Scales
10, 20, 50, 100 voxels per metre

Parameters

Shape

ParameterPathRangeDefault
Blade length
length of the tallest blade in voxels (10 per metre); shorter blades are a fraction of it
shape.height4 to 8034
Patch radius
radius of the disc the tufts are scattered over, in voxels
shape.footprint2 to 48, step 112
Fan
how far blades splay from vertical, in degrees; 0 stands them upright
shape.fanDeg0 to 60, step 130
Arc
downward bend per voxel of blade; 0 is straight, high values arch right over
shape.arc0 to 0.12, step 0.0020.01
Blade thickness
blade radius in voxels; below 1 a blade is a clean one-voxel line
shape.radius0.3 to 2, step 0.050.7

Look

ParameterPathRangeDefault
Season
blade colours; winter also dusts the upper faces with snow
look.seasonspring, summer, autumn, wintersummer
Dry blades
fraction of whole blades that have dried off to straw
look.dry0 to 1, step 0.020.1
Flowers
fraction of blades ending in a flower head, in three colours
look.flowers0 to 0.6, step 0.010
Seed heads
fraction of blades ending in a seed head, as on reeds and cereals
look.seedHeads0 to 1, step 0.020

Presets

Parametergrassmeadowreedsferndry
Blade length2430563422
Patch radius1115141211
Fan131673022
Arc0.0120.0140.0040.010.032
Blade thickness0.60.60.650.70.6
Seasonsummersummersummersummersummer
Dry blades0.10.080.180.10.75
Flowers00.14000
Seed heads000.300.2

Roles

Voxel values are these roles, in this order (value 1 is the first). The colours are the defaults; a host maps each role to a palette slot and can restyle it.

  • 1Blade base blade.lo
  • 2Blade mid blade.mid
  • 3Blade tip blade.hi
  • 4Dry blade blade.dry
  • 5Stalk stalk
  • 6Seed head seed · may float when refined
  • 7Flower A flower.a · may float when refined
  • 8Flower B flower.b · may float when refined
  • 9Flower C flower.c · may float when refined
  • 10Snow snow · may float when refined

See the API reference for generateGrass and the parameter types.

On this page