Feature Library

Trees grown in compute

1.65 GPU · 0.35 CPU ms
A still of the Trees grown in compute demo
Still
The live demo starts when it’s in view.Click a crown to strike it (its limbs swing away from you) · drag to orbit · try Season, Play the year and Grow · Branch physics · Show a forest

A broadleaf tree, a spruce and a flowering bush grown on the GPU.

What it costs a frame

1.65 ms
0.35 ms
GPU
1.65 ms
CPU, median
0.35 ms
CPU, 95th pct
0.92 ms
Draw calls
4
Compute passes
3
Weight
Moderate

Measured 11 November 2026 on RTX 4060 Laptop, 13th Gen Intel(R) Core(TM) i9-13900H, Chrome 157, 1920×1080 at 1×. 600 frames × 3 rounds, median kept. What ran: Three plants and the grass tufts in a 6 m/s gusty wind, summer, the whole scene in view, the broadleaf shaken every 3 s: per plant six compute passes a frame (bend, move, reset, list branches, list leaves, clamp) and four to six indirect draws. Phones: tiers are being measured next.

On every machine it was measured on
MachineGPU msCPU msCPU p95
RTX 4060 Laptop · 13th Gen Intel(R) Core(TM) i9-13900Hreference · measuring tool1.650.350.92
apple · Apple A19 Proin a browser tab · 16 November 20268.730.140.20
Intel Arc 140V (Xe2-LPG) · Intel Core Ultra 7 258Vin a browser tab · 15 November 202615.91.462.10

Bars against one 16.7 ms frame. A browser-tab run is timed in a visible tab without the tool’s scripted input, so read it as close, not exact.

What it needs

Renders with
WebGPUNeeds WebGPU: current Chrome and Edge, Safari 26+, Firefox 141+ on Windows.
Your browser
Checking…Looking for WebGPU
Depends on
three.js 0.187.0No other packages

What it’s for

  1. Trees and bushes in games and configurators
  2. Gardens, parks and landscapes
  3. Seasonal scenes and time-lapses
  4. Growth ceremonies and title moments
  5. Architectural visualisation
  6. Forests and woods of hundreds of trees in games and walk-throughs
  7. Baking a live simulated object into cheap instanced copies with a live one near the camera
  8. Trees that react when a player brushes past or strikes them
  9. Gusts you can watch roll across a garden

Pitfalls, in brief

  1. The demo needs WebGPU: the plant is grown, bent by the wind, culled and shaded in compute (space colonisation with integer atomics in a spatial hash, the joints’ springs, a leaf-area grid, indirect draw lists filled with atomics, and readbacks of the grown skeleton), and three’s WebGL2 backend has no compute, no storage buffers to read at random and no indirect draws.
  2. Do not grow every plant before the first frame: the compiles and the growth took 3 to 31 s for three plants in a headless test on a busy machine, all of it a blank stage.
  3. Check a swept tube’s winding against the turn its rings are placed by: turned the wrong way, every branch is inside out and you see the inside of its far wall.
  4. Wrap bark by a frame that holds still on upright wood: a frame whose reference swings from up to sideways as a limb nears vertical turns the bark round a trunk as it sways, and cuts it where two rings meet.
  5. Space colonisation searches every node for every point, every step: on the GPU too that is minutes at 10,000 of each.
29 more in brief
  1. Clamp the turn a step: a shoot continuing its limb turns at most about 28°, a side shoot leaves at 65° at most, and a shoot heading back along its limb is not grown.
  2. Sum the pulls on a node with integer atomics (fixed point): float sums in parallel depend on the order, and the tree would differ run to run.
  3. A lone attraction point far from the rest grows one long bare whip out to it.
  4. The pipe model alone makes long limbs with few tips whip-thin.
  5. Light the twigs from twig density alone when deciding where leaves go.
  6. Fix each leaf’s exposure from the first (summer) bake for its autumn timing.
  7. Wind is a small rotation per joint, summed down to every node: scale it per metre of wood and soften thin wood’s compliance (radius^0.6, capped), or a long twig’s 40 joints curl it into a spiral.
  8. Where a limb bends sharply, do not average the two tubes’ ring directions: the bend opens.
  9. Small shaded twigs that carry no leaves bristle along the limbs like thorns when drawn: shed them in the draw list while the tree is in leaf (not when bare).
  10. TSL: an atomic load used inside an expression (min(atomicLoad(…), …)) as a loop bound generated empty code (“expected a uint”): give it .toVar() first.
  11. Each renderer.compute(node) is its own submit, so a uniform may change between calls (the growth steps rely on it); passes given together as an array all see the same uniforms.
  12. The plant is placed by its position and rotation options, in the shaders: do not move or parent object3D (its meshes stay at the origin, frustumCulled off).
  13. Needle sprays need MSAA for alpha to coverage, and their alpha thins in the smaller mips: the shader lifts it by how far down the mips it reads.
  14. On a weak GPU set tier to low (FOLIAGE_TIER): the light leaf count (about half, drawn larger so the crown keeps its cover), wood round only from 8 px, the coarse leaf mesh past 9 m, leaves thinned from 20 m and none past 80 m.
  15. A rebake (light through the crown, the ground shadow) costs about half a millisecond a plant: it runs when the season, the growth or the sun moves on, a few times a second at most, never every frame.
  16. A forest is not a few hundred live plants (six compute passes a frame each): capture a few grown ones and bake them into instanced variants.
  17. Let the crowns cast from their lightest level only, on a layer only the sun’s shadow camera draws, and the leaves seen cast nothing: with every level casting, HaTac_FP’s forest drew 7 M triangles and 3.2–4.5 ms of GPU; this way 2.3 M and 1.75–2.0 ms.
  18. Draw only the trees in a cone 20° wider than the view, and every tree within 14 m (a trunk can be in view when its crown is not); plan again when the view turns 8° or moves 4 m.
  19. A hero tree keeps its spot until another of its kind is 6 m nearer: without the margin, a camera between two spots swaps the live tree back and forth.
  20. Moving a live plant (moveTo) must not bake: run without waiting, the bake left every leaf unlit (black crowns); waited on, it stalled a frame.
  21. A baked tree’s light is for the sun it was captured under, so an instance cannot be turned: bake each plant at a few turns instead (turns; four plants at three turns read as twelve trees), size and lean the instances, and let a live hero take only a spot where its plant stands as it grew.
  22. Compile a forest by showing each mesh only for the moment its compileAsync starts, then hide it: left showing while the compile ran, the frames drawn meanwhile drew it and built every shader on the spot (26 stalls, and a tree showed in the garden it was not part of).
  23. Compile a plant’s compute passes ahead (compileComputeAsync, through the shared queue): grown after load, each pass built its pipeline on its first dispatch, 28 stalls a plant.
  24. three r187 has dropped PCFSoftShadowMap: compileAsync switches the renderer to PCFShadowMap with a warning, and every material that samples a shadow builds again.
  25. The environment’s sunShade (cloud shadows) is read as each material is built: set it before the first plant, and drive it with your own uniforms rather than replacing it.
  26. Pull each branch spring toward the wind’s own bend, not toward rest with the wind as a force: then a plant at rest in a steady wind stands exactly where the springs-off wind draws it, switching them on or off does not show, and a captured or baked tree matches its live hero.
  27. Step the springs in two half-frame substeps and hold a frame to 1/30 s: a stiff thin twig (2.5 × 1.9 sways a second) is then stable at 20 fps, and a hitch does not fling the crown.
  28. Spring the bends, not the positions: a joint’s spring is a small rotation, and every node still moves by the sum of the rotations below it, so a kicked trunk carries its limbs and limbs keep their lengths.
  29. The springs and the analytic wind are the same formulas twice: branch-springs.ts (tested) and the bend pass in wind.ts.
34 pitfalls in full, the hook-up guide, the module source and its tests come with the part.

Also as

Where it comes from

Written for the library. Fully custom code.

Adam Runions, Brendan Lane and Przemyslaw Prusinkiewicz, “Modeling Trees with a Space Colonization Algorithm” (2007): The broadleaf’s and the bush’s growth: attraction points, influence and kill distances, one segment a step. Here on the GPU, with a spatial hash and integer atomics.

Jason Weber and Joseph Penn, “Creation and Rendering of Realistic Trees” (SIGGRAPH 1995): The spruce’s whorls of branches by rule along a leader, shorter up the cone, drooping and turning up at the tips.

Kichiro Shinozaki et al., the pipe model theory (1964); Leonardo da Vinci’s rule of branching: A node’s radius from the tips it carries (radius ∝ tips^(1/n)).

Masami Monsi and Toshiro Saeki, light extinction in plant canopies (1953): Light through the crown falls off as exp(−G × leaf area along the ray), G = 0.5 for leaves facing every way.

Owner’s HaTac branch springs (2026): A spring per node pulled toward the analytic sway’s own bend, so springs and sway agree at rest; gust fronts as solved fronts rolling downwind; semi-implicit Euler in two substeps a frame.

Tiago Sousa, “Vegetation Procedural Animation and Shading in Crysis”, GPU Gems 3, ch. 16 (2007): Wind as main bending, branch detail and leaf flutter with phases per branch. Here per joint of a real skeleton, summed down each limb.

Robert L. Cook, John Halstead, Maxwell Planck and David Ryu, “Stochastic Simplification of Aggregate Detail” (SIGGRAPH 2007): Far leaves: a share kept, enlarged so the crown keeps its cover.

Helmut Vogel, “A better way to construct the sunflower head” (1979): The golden angle (137.5°) between successive leaves round a twig.

Mark Jarzynski and Marc Olano, “Hash Functions for GPU Rendering” (JCGT 2020): The PCG hash: written from the paper for the CPU side; the GPU side uses three’s own `hash` node (imported, MIT).

Tomas Möller and Ben Trumbore, fast ray–triangle intersection (1997): envelopeFromMesh counts crossings to sample a mesh’s volume.

Zina Cigolle et al., “A Survey of Efficient Representations for Independent Unit Vectors” (JCGT 2014): The octahedral encoding that packs a crown normal into one float.

Edwin Catmull and Raphael Rom, “A Class of Local Interpolating Splines” (1974): The baked wood’s tubes run along a uniform Catmull–Rom curve through each limb’s nodes.

Ken Perlin, improved noise (2002): The bark’s lichen and the demo’s meadow read three’s MaterialX noise node (mx_noise_float): imported, not copied.

treesfoliagevegetationspace colonisationpipe modelcomputeindirect drawlodwindseasonsfalling leavestranslucencyself-shadowingsnowtslforestinstancingbaked variantshero objectshysteresisshadow layercloud shadowsbranch physicssprings

Near it in the frame