Space Colonization Tree Modeling
Grow a branching skeleton by scattering attractor points in a crown volume. Each branch tip grows toward the average direction of the attractors that choose it, and attractors are deleted when reached.
Also known as space colonization algorithm, venation-inspired branching
In the family Procedural generation, plants and vegetation
Where it runs
Built inOfficial add-onPluginNone foundNot researched
| Engine | Support | How |
|---|---|---|
| three.js r187 | None found | |
| Babylon.js 9.38.0 | None found | |
| Godot 4.7 | None found | No built-in space-colonization procedural tree generator. |
| Unity | None found | |
| Unreal 5.7 | None found | |
| Blender 5.2 | None found | |
| WebGPU W3C | None found | |
| Metal | None found |
How it works
Start with a root node and a cloud of attractor points filling the intended crown volume or shape. In each iteration, every attractor finds its nearest branch node within an influence radius. Nodes that were chosen by at least one attractor grow a new child node in the normalised mean direction toward their attractors. Attractors closer than a kill distance to any node are removed. The loop ends when no attractors remain or no node grows. Competition for space emerges naturally: nodes near each other share attractors, giving self-pruning, gaps and natural-looking crowns. Branch thickness is computed afterwards from the leaf count or pipe model (radius from child radii), and the skeleton is skinned into a mesh. Shape control comes from where attractors are placed; the same algorithm models leaf venation.
When to choose it
Reach for it when
- need trees whose crown fits a given silhouette
- procedural branches look rigid or repetitive
- grow roots, veins or lightning bolts procedurally
- want bushes shaped by a volume
Choose it for trees and bushes where the silhouette matters, shaping crowns to a volume, and for roots, veins or lightning. Prefer L-Systems when you need developmental semantics or perfect repetition, and Interactive Climbing Plant Modeling when growth should follow a surface.
Field marks
- Influence radius too small leaves attractors unreached and branches stall; too large causes straight, bundled branches
- Branches may pass through each other or the trunk because no collision test exists
- Raw skeleton is jagged; meshing needs smoothing and thickness estimation
- Crown shape is entirely determined by the attractor cloud, so poorly sampled volumes make gaps or clumps
Presets
Space Colonization Trees — crown attraction points & skeleton (left) vs pipe-model tree & foliage (right)
{
"P_GROWTH_PROG": 0.9,
"P_CROWN_SPREAD": 1,
"P_BRANCH_THICK": 1,
"P_SPLIT": 0.46
}Show GLSL (130 lines)
const float P_GROWTH_PROG = 0.90; // P Colonization [0.25, 1.0, 0.02]
const float P_CROWN_SPREAD = 1.0; // P Crown Width [0.6, 1.4, 0.04]
const float P_BRANCH_THICK = 1.0; // P Pipe Thickness [0.5, 1.6, 0.05]
const float P_SPLIT = 0.46; // P Attractors / Tree [0.0, 1.0, 0.02]
float sdTaperSeg(vec2 p, vec2 a, vec2 b, float rA, float rB, out float h) {
vec2 pa = p - a, ba = b - a;
h = clamp(dot(pa, ba) / max(dot(ba, ba), 1e-5), 0.0, 1.0);
return length(pa - ba * h) - mix(rA, rB, h);
}
vec2 hash21(float x) {
vec3 p = fract(vec3(x) * vec3(0.1031, 0.1030, 0.0973));
p += dot(p, p.yzx + 33.33);
return fract((p.xx + p.yz) * p.zy);
}
vec3 aces(vec3 x) {
x = max(x, 0.0);
return (x * (2.51 * x + 0.03)) / (x * (2.43 * x + 0.59) + 0.14);
}
void mainImage(out vec4 fragColor, in vec2 fragCoord) {
vec2 uv = (fragCoord - 0.5 * iResolution.xy) / iResolution.y;
float screenX = fragCoord.x / max(iResolution.x, 1.0);
float split = clamp(P_SPLIT, 0.0, 1.0);
bool isAttractorVis = screenX < split;
float prog = clamp(P_GROWTH_PROG, 0.2, 1.0);
float spread = clamp(P_CROWN_SPREAD, 0.5, 1.5);
float thick = clamp(P_BRANCH_THICK, 0.4, 1.8);
// Twilight botanical backdrop
vec3 col = mix(vec3(0.032, 0.044, 0.068), vec3(0.088, 0.125, 0.185), smoothstep(-0.48, 0.52, uv.y));
// Subtle soil ground line
if (uv.y < -0.38) {
col = mix(vec3(0.09, 0.12, 0.08), vec3(0.04, 0.06, 0.05), smoothstep(-0.38, -0.50, uv.y));
}
// Crown envelope bounding ellipse (guides space colonization attraction cloud)
vec2 crownCenter = vec2(0.0, 0.12);
vec2 crownRad = vec2(0.42 * spread, 0.30);
float dCrown = length((uv - crownCenter) / crownRad) - 1.0;
if (isAttractorVis) {
col += vec3(0.14, 0.56, 0.72) * exp(-abs(dCrown) * 32.0) * 0.35;
}
// Animated wind sway
float wind = sin(iTime * 1.15) * 0.018;
// Compute space-colonization branching tree skeleton (trunk -> 3 primary boughs -> 9 secondary -> 18 twigs)
float minTreeD = 1e5;
float branchAge = 0.0;
float hTmp;
vec2 pRoot = vec2(0.0, -0.40);
vec2 pFork = vec2(wind * 0.4, -0.10);
float dTrunk = sdTaperSeg(uv, pRoot, pFork, 0.036 * thick, 0.025 * thick, hTmp);
if (dTrunk < minTreeD) { minTreeD = dTrunk; branchAge = 0.1; }
// 3 main boughs growing into left, center, and right crown zones
for (int i = 0; i < 3; i++) {
float fi = float(i) - 1.0;
vec2 b1 = pFork + vec2((fi * 0.24 * spread) + wind * 0.9, 0.19 + (1.0 - abs(fi)) * 0.07);
vec2 b1Grow = mix(pFork, b1, clamp(prog * 1.6, 0.0, 1.0));
float dB1 = sdTaperSeg(uv, pFork, b1Grow, 0.021 * thick, 0.013 * thick, hTmp);
if (dB1 < minTreeD) { minTreeD = dB1; branchAge = 0.35; }
// 3 secondary branches per main bough pulled toward crown attractor sectors
if (prog > 0.38) {
float p2 = clamp((prog - 0.38) / 0.35, 0.0, 1.0);
for (int j = 0; j < 3; j++) {
float fj = float(j) - 1.0;
vec2 angOff = vec2((fi * 0.11 + fj * 0.13) * spread + wind * 1.5, 0.15 + (1.0 - abs(fj)) * 0.06);
vec2 b2 = b1 + angOff;
vec2 b2Grow = mix(b1, b2, p2);
float dB2 = sdTaperSeg(uv, b1, b2Grow, 0.012 * thick, 0.0065 * thick, hTmp);
if (dB2 < minTreeD) { minTreeD = dB2; branchAge = 0.65; }
// 2 fine terminal twigs reaching remaining attractors
if (prog > 0.66) {
float p3 = clamp((prog - 0.66) / 0.34, 0.0, 1.0);
for (int k = 0; k < 2; k++) {
float fk = (float(k) - 0.5) * 2.0;
vec2 b3 = b2 + vec2((fk * 0.075 + fj * 0.03) * spread + wind * 2.0, 0.085 + 0.02 * cos(fi + fj));
vec2 b3Grow = mix(b2, b3, p3);
float dB3 = sdTaperSeg(uv, b2, b3Grow, 0.0055 * thick, 0.0022 * thick, hTmp);
if (dB3 < minTreeD) { minTreeD = dB3; branchAge = 0.92; }
// Soft foliage cluster on right side around colonized twig tips!
if (!isAttractorVis) {
float dLeaf = length(uv - b3Grow);
float leafMask = smoothstep(0.085 * p3, 0.018, dLeaf);
vec3 leafCol = mix(vec3(0.14, 0.48, 0.22), vec3(0.56, 0.80, 0.24), 0.5 + 0.5 * sin(fi * 2.1 + fj * 3.7 + fk));
// Sunlight gradient on canopy top
leafCol *= (0.68 + 0.48 * smoothstep(-0.05, 0.38, uv.y));
col = mix(col, leafCol, leafMask * 0.78);
}
}
}
}
}
}
// Draw woody bark skeleton (left: glowing vector-growth skeleton; right: shaded bark)
float barkMask = smoothstep(0.004, -0.002, minTreeD);
vec3 barkCol = isAttractorVis
? mix(vec3(0.96, 0.72, 0.28), vec3(0.28, 0.95, 0.86), branchAge)
: mix(vec3(0.32, 0.22, 0.15), vec3(0.48, 0.36, 0.24), branchAge);
col = mix(col, barkCol, barkMask);
// On left side, scatter 28 crown attraction points (glowing cyan dots that vanish once colonized!)
if (isAttractorVis) {
for (int a = 0; a < 28; a++) {
vec2 r = hash21(float(a) * 13.7 + 4.1);
float ang = r.x * 6.2831853;
float rad = sqrt(r.y);
vec2 pt = crownCenter + vec2(cos(ang) * crownRad.x, sin(ang) * crownRad.y) * rad * 0.95;
float dPt = length(uv - pt);
// Outer attractors remain active (bright cyan); inner ones show dim colonized rings
float isActive = smoothstep(0.35 * prog, 0.92 * prog, rad);
vec3 ptCol = mix(vec3(0.22, 0.36, 0.48), vec3(0.20, 0.95, 1.0), isActive);
col += ptCol * exp(-dPt * 95.0) * (0.45 + 0.85 * isActive);
}
}
float sep = smoothstep(0.0035, 0.0008, abs(screenX - split));
col = mix(col, vec3(0.95, 0.97, 1.0), sep);
fragColor = vec4(pow(clamp(aces(col), 0.0, 1.0), vec3(1.0 / 2.2)), 1.0);
}Attribution: MIT — written for this index.
Measured GPU weight & timing
| Preset | GPU | Weight / p50 / p95 | Method |
|---|---|---|---|
| space-colonization-trees-live | Tesla T4 1920x1080 | 18.7× baseline (moderate) · 0.616 ms / 0.649 ms | opengl-timer-query · 32 frames · GPU Weight Atlas · Colab T4 sweep |
| space-colonization-trees-live | NVIDIA L4 1920x1080 | 15.5× baseline (moderate) · 0.246 ms / 0.251 ms · 2.5× faster on L4 | opengl-timer-query · Cross-architecture validation |
| space-colonization-trees-live | NVIDIA A100-SXM4-40GB 1920x1080 | 12.0× baseline (moderate) · 0.345 ms / 0.346 ms · 1.8× faster on A100 | opengl-timer-query · Cross-architecture validation |
Crosses
- Forests that grow into the gaps: Biomes where terrain, plant placement and each tree's shape are linked. Erosion supplies wet valleys and dry ridges, an ecosystem simulation places species by moisture and competition, and every crown grows only into space its neighbours left free.
- Trees grown into a described shape: Describe a silhouette in words and grow a botanically plausible branching structure that fills it. A text-to-point-cloud model's coarse output is exactly what space colonization needs: attractors that mark a volume.
- Poisson Disk Sampling (Bridson): Blue-noise attractor points give evenly spread attractors inside the crown volume.
Sources
- primaryAdam Runions, Brendan Lane, Przemyslaw Prusinkiewicz (2007). Modeling Trees with a Space Colonization Algorithm. Eurographics Workshop on Natural Phenomena.Verified via doi.org · 2026-11-29doi:10.2312/nph/nph07/063-070
- primaryAdam Runions, Brendan Lane, Przemyslaw Prusinkiewicz. Modeling Trees with a Space Colonization Algorithm. algorithmicbotany.org.Verified via live page · 2026-11-29
- implementationdgreenheck (2024). dgreenheck/ez-tree. Procedural tree generator written with JavaScript and Three.jsGitHub API · license MIT · 2026-11-29