voxolith

Rocks

@voxolith/gen-rock: boulders, outcrops and pebbles from fractured, noise-displaced superellipsoids, with strata, cracks, moss, lichen and snow.

The seven rock presets: boulder, sandstone, basalt, limestone, mossy, outcrop and pebbles

@voxolith/gen-rock makes rocks. A rock is a noise-displaced superellipsoid, round, blocky or slab-like, cleaved along a few fracture planes, with a surface pass that hands out mottled tones, sedimentary strata on a tilted bedding plane, cracks, moss on the upward faces, lichen, a damp band at the base and optional snow. outcrop tumbles smaller rocks against a main mass, kept as one connected piece.

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

const { entity, stats } = generateRock(PRESETS.boulder, seededRandom(42));
// stats.rocks, stats.moss, stats.cracks; the anchor is the base centre, raised by shape.sink

It is the template for every solid-mass generator: see writing a generator.

How it works

Mass. The main rock is a blob with half-extents from size, aspect (height) and elongation (depth). exponent picks the family: 2 round, 4 a rounded block, 8 nearly cubic. roughness and detail set the bumps; grit adds a voxel or so of fine texture, which breaks the contour terraces bumps leave on shallow slopes.

Fractures. facet cleaves the mass along facets planes, each removing up to facetDepth of it. A lumpy ellipsoid reads as a potato; flat breaks meeting at hard edges read as stone. 0 leaves a water-worn cobble. The voxels on each fracture face are tagged, so each break can take one even tone.

Extras. With cluster above 0, smaller rocks (clusterScale of the main one, with a random spread) are placed touching it on the same floor, so the group reads as fallen together. Each rock is shaped and fractured in its own scratch volume and then unioned in, so one rock's planes never slice its neighbour, and the overlap keeps the whole one piece.

Surface. Every surface voxel is given a role from a snapshot, so no decision reads a neighbour already repainted: light, mid and dark tones from two scales of value noise (mottle), one tone per fracture face a notch lighter than weathered stone, darker undersides and crevices, strata bands along a plane tilted by strataTiltDeg, thin cracks where a signed noise field crosses zero, a damp band at the base (wet), lichen patches (lichen), moss on upward faces, denser low down (moss), and snow on top faces with clear sky above (snow).

Anchor at the bottom centre, raised by sink of the height from the rock's real bottom, so the rock sits in the ground rather than on it. The interior stays the mid tone: the renderer never sees it, but a game that breaks a rock open will.

Parameters split into shape (which voxels exist) and look (which role each surface voxel gets). The stone skin (species: granite, sandstone, basalt, limestone or slate) only changes the default colours of the ten roles, so the same shape restyles by palette without regenerating.

Presets

Boulder, outcrop and basalt, three seeds each
presetcharacter
bouldergranite, rounded, nine fractures, some moss and lichen
sandstonebedded and blocky, weathered flat, with strong strata
basaltangular and near-cubic, many sharp fractures, little life
limestonepale, pitted and heavily cracked
mossya low granite boulder under thick moss, with a damp base
outcropa slate mass with five smaller rocks tumbled against it, on a steep bedding plane
pebblesa small group of water-worn cobbles, no fractures, sunk into the ground

Finer scales

At 20, 50 and 100 voxels per metre the rock is refined with the smooth rule: it rounds off its voxel steps and takes a rough, grainy surface, the mid tone breaks into light and dark speckle, hairline cracks a voxel deep run across the faces, and moss and lichen become ragged patches. It has no loose roles. See scales and refinement.

Development

bun run --cwd generators/rock verify            # connectivity, determinism, knobs, share codes
bun run --cwd generators/rock preview species   # contact sheets into previews/ (also: seeds, roughness, angularity)
bun run --cwd generators/rock gen               # bake .vox files into out/

Rock

voxolith/rock starts from the boulder preset.

Id
voxolith/rock
Version
0.2.1
Scales
10, 20, 50, 100 voxels per metre

Parameters

Shape

ParameterPathRangeDefault
Size
longest horizontal extent of the main rock, in voxels (10 per metre)
shape.size8 to 16048
Height ratio
height as a fraction of size: 1 is as tall as wide, 0.4 a slab
shape.aspect0.2 to 1.4, step 0.050.8
Depth ratio
depth as a fraction of size; below 1 the footprint is an oval
shape.elongation0.4 to 1.4, step 0.050.85
Angularity
2 is round, 4 a rounded block, 8 nearly cubic
shape.exponent1.6 to 9, step 0.12.6
Roughness
surface displacement as a fraction of radius; higher is lumpier
shape.roughness0 to 0.4, step 0.010.08
Bump size
bumps per radius: low is a few great lumps, high many finer ones
shape.detail0.5 to 5, step 0.11.6
Fractures
flat broken faces; 0 is a water-worn cobble
shape.facets0 to 209
Fracture depth
most of the rock one fracture can shear away, as a fraction; higher cuts deeper faces
shape.facetDepth0.08 to 0.5, step 0.010.32
Grit
fine surface texture; breaks up terracing
shape.grit0 to 2.5, step 0.10.3
Extra rocks
smaller rocks nestled against the main one, overlapping so the whole stays one piece
shape.cluster0 to 100
Extra size
size of the extra rocks as a fraction of the main one
shape.clusterScale0.15 to 0.9, step 0.010.45
Sink
fraction of the height buried: the anchor sits this far up the rock
shape.sink0 to 0.5, step 0.010.12

Look

ParameterPathRangeDefault
Stone
stone colouring: granite, sandstone, basalt, limestone or slate
speciesgranite, sandstone, basalt, limestone, slategranite
Mottle
contrast between the light and dark tones across the surface
look.mottle0 to 1, step 0.050.5
Strata bands
bedding bands per rock height; 0 disables banding
look.strata0 to 12, step 0.50
Strata tilt
tilt of the bedding planes in degrees
look.strataTiltDeg-45 to 45, step 10
Cracks
dark cracks over the surface; higher widens them, 0 for none
look.cracks0 to 1, step 0.050.25
Moss
moss cover on upward-facing surfaces
look.moss0 to 1, step 0.050.35
Lichen
pale lichen patches on any face
look.lichen0 to 1, step 0.050.2
Wet base
height of the dark damp band at the base, as a fraction of height
look.wet0 to 0.5, step 0.010.12
Snow
snow cover on upward-facing surfaces
look.snow0 to 1, step 0.050

Presets

Parameterbouldersandstonebasaltlimestonemossyoutcroppebbles
Size48484848486422
Height ratio0.80.550.90.80.70.60.65
Depth ratio0.850.850.850.850.850.70.85
Angularity2.6432.22.63.22.6
Roughness0.080.060.040.140.10.080.1
Bump size1.62.432.81.61.61.6
Fractures961485110
Fracture depth0.320.320.380.320.220.320.32
Grit0.30.250.150.60.30.30.5
Extra rocks0000057
Extra size0.450.450.450.450.450.420.7
Sink0.120.120.120.120.120.120.2
Stonegranitesandstonebasaltlimestonegraniteslategranite
Mottle0.50.50.30.350.50.50.5
Strata bands0500070
Strata tilt08000220
Cracks0.250.150.40.550.250.250.1
Moss0.350.050.080.20.850.30.15
Lichen0.20.10.150.350.30.20.1
Wet base0.120.120.120.120.250.120.12
Snow0000000

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.

  • 1Rock light rock.light
  • 2Rock mid rock.mid
  • 3Rock dark rock.dark
  • 4Strata strata
  • 5Crack crack
  • 6Moss moss
  • 7Moss dark moss.dark
  • 8Lichen lichen
  • 9Wet base wet
  • 10Snow snow

Outcrop

voxolith/outcrop is the same generator starting from the outcrop preset.

Id
voxolith/outcrop
Version
0.2.1
Scales
10, 20, 50, 100 voxels per metre

Parameters

Shape

ParameterPathRangeDefault
Size
longest horizontal extent of the main rock, in voxels (10 per metre)
shape.size8 to 16064
Height ratio
height as a fraction of size: 1 is as tall as wide, 0.4 a slab
shape.aspect0.2 to 1.4, step 0.050.6
Depth ratio
depth as a fraction of size; below 1 the footprint is an oval
shape.elongation0.4 to 1.4, step 0.050.7
Angularity
2 is round, 4 a rounded block, 8 nearly cubic
shape.exponent1.6 to 9, step 0.13.2
Roughness
surface displacement as a fraction of radius; higher is lumpier
shape.roughness0 to 0.4, step 0.010.08
Bump size
bumps per radius: low is a few great lumps, high many finer ones
shape.detail0.5 to 5, step 0.11.6
Fractures
flat broken faces; 0 is a water-worn cobble
shape.facets0 to 2011
Fracture depth
most of the rock one fracture can shear away, as a fraction; higher cuts deeper faces
shape.facetDepth0.08 to 0.5, step 0.010.32
Grit
fine surface texture; breaks up terracing
shape.grit0 to 2.5, step 0.10.3
Extra rocks
smaller rocks nestled against the main one, overlapping so the whole stays one piece
shape.cluster0 to 105
Extra size
size of the extra rocks as a fraction of the main one
shape.clusterScale0.15 to 0.9, step 0.010.42
Sink
fraction of the height buried: the anchor sits this far up the rock
shape.sink0 to 0.5, step 0.010.12

Look

ParameterPathRangeDefault
Stone
stone colouring: granite, sandstone, basalt, limestone or slate
speciesgranite, sandstone, basalt, limestone, slateslate
Mottle
contrast between the light and dark tones across the surface
look.mottle0 to 1, step 0.050.5
Strata bands
bedding bands per rock height; 0 disables banding
look.strata0 to 12, step 0.57
Strata tilt
tilt of the bedding planes in degrees
look.strataTiltDeg-45 to 45, step 122
Cracks
dark cracks over the surface; higher widens them, 0 for none
look.cracks0 to 1, step 0.050.25
Moss
moss cover on upward-facing surfaces
look.moss0 to 1, step 0.050.3
Lichen
pale lichen patches on any face
look.lichen0 to 1, step 0.050.2
Wet base
height of the dark damp band at the base, as a fraction of height
look.wet0 to 0.5, step 0.010.12
Snow
snow cover on upward-facing surfaces
look.snow0 to 1, step 0.050

Presets

Parameterbouldersandstonebasaltlimestonemossyoutcroppebbles
Size48484848486422
Height ratio0.80.550.90.80.70.60.65
Depth ratio0.850.850.850.850.850.70.85
Angularity2.6432.22.63.22.6
Roughness0.080.060.040.140.10.080.1
Bump size1.62.432.81.61.61.6
Fractures961485110
Fracture depth0.320.320.380.320.220.320.32
Grit0.30.250.150.60.30.30.5
Extra rocks0000057
Extra size0.450.450.450.450.450.420.7
Sink0.120.120.120.120.120.120.2
Stonegranitesandstonebasaltlimestonegraniteslategranite
Mottle0.50.50.30.350.50.50.5
Strata bands0500070
Strata tilt08000220
Cracks0.250.150.40.550.250.250.1
Moss0.350.050.080.20.850.30.15
Lichen0.20.10.150.350.30.20.1
Wet base0.120.120.120.120.250.120.12
Snow0000000

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.

  • 1Rock light rock.light
  • 2Rock mid rock.mid
  • 3Rock dark rock.dark
  • 4Strata strata
  • 5Crack crack
  • 6Moss moss
  • 7Moss dark moss.dark
  • 8Lichen lichen
  • 9Wet base wet
  • 10Snow snow

See the API reference for generateRock and the parameter types.

On this page