Weber and Penn parametric tree generation
Grows a tree from a few dozen species parameters that control trunk taper, branch splitting, curvature, and recursion over several levels, then skins the stems and adds leaves.
Also known as Weber-Penn, Sapling tree generator
In the family Procedural generation, parametric botany
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 | |
| Unity | None found | |
| Unreal 5.7 | None found | Procedural Vegetation Editor is a different method. |
| Blender 5.2 | Official add-on | Install Sapling Tree Gen from extensions.blender.org docs Extension; no longer bundled with Blender. |
| WebGPU W3C | None found | |
| Metal | None found |
How it works
A tree is described by up to four recursion levels: trunk, branches, sub-branches, twigs. Each level has parameters for length, radius ratio, number of children, their spacing along the parent, downward and rotational angles, curvature, and random variation. The generator walks the stem as a sequence of segments, bending each by the level's curve parameters, and places children at positions along the parent derived from the child count and spacing, with each child's angle relative to the parent and a spiral phase. Clones at the segment level can split stems into forks. Trunk flare and radius taper follow a profile function. Leaves attach at the last level. Output is a skeleton of curves with radii that you skin into a mesh and instance leaves onto; species presets are simply parameter sets, which is why it is so easy to ship with a UI.
When to choose it
Reach for it when
- need many varied tree species from sliders
- generate a realistic tree mesh from parameters
- blender sapling style procedural trees
- want branching with taper curvature and splits
Choose it when you want controllable, species-like trees from a small parameter set, or a classic baseline with a known preset library. Prefer L-Systems for grammar-driven plants where topology rules matter more than botany sliders, Space Colonization Tree Modeling when branches should fill a given crown envelope or react to obstacles, and Interactive Climbing Plant Modeling for plants that interact with surfaces.
Field marks
- Parameters interact non-intuitively, so tuning a new species by hand takes many iterations
- Branches ignore each other and light, so crowns interpenetrate and look uniformly dense unlike real, light-seeking trees
- Branch-to-trunk joins show seams or pinching unless the skinning blends radii at junctions
- Random variation makes results non-reproducible unless the seed is stored with the parameters
Presets
Weber & Penn Tree Generation — multi-level parametric branch skeleton (left) vs skinned bark & backlit foliage canopy (right)
{
"P_SPLIT_ANGLE": 0.52,
"P_CURVATURE": 0.38,
"P_CANOPY_DENS": 1,
"P_SPLIT": 0.48
}Show GLSL (214 lines)
const float P_SPLIT_ANGLE = 0.52; // P Branch Split Angle [0.22, 0.85, 0.03]
const float P_CURVATURE = 0.38; // P Phototropism Curve [0.05, 0.75, 0.03]
const float P_CANOPY_DENS = 1.00; // P Canopy Fullness [0.4, 1.5, 0.05]
const float P_SPLIT = 0.48; // P Skeleton / Tree Split [0.0, 1.0, 0.02]
float hash31(vec3 p) {
p = fract(p * vec3(127.1, 311.7, 74.7));
p += dot(p, p.yzx + 19.19);
return fract((p.x + p.y) * p.z);
}
float noise3(vec3 p) {
vec3 i = floor(p);
vec3 f = fract(p);
f = f * f * (3.0 - 2.0 * f);
return mix(
mix(mix(hash31(i), hash31(i + vec3(1.0, 0.0, 0.0)), f.x),
mix(hash31(i + vec3(0.0, 1.0, 0.0)), hash31(i + vec3(1.0, 1.0, 0.0)), f.x), f.y),
mix(mix(hash31(i + vec3(0.0, 0.0, 1.0)), hash31(i + vec3(1.0, 0.0, 1.0)), f.x),
mix(hash31(i + vec3(0.0, 1.0, 1.0)), hash31(i + vec3(1.0, 1.0, 1.0)), f.x), f.y),
f.z
);
}
// Tapered capsule segment from a (radius ra) to b (radius rb)
float sdTaperCapsule(vec3 p, vec3 a, vec3 b, float ra, float rb) {
vec3 ba = b - a;
vec3 pa = p - a;
float h = clamp(dot(pa, ba) / max(dot(ba, ba), 1e-5), 0.0, 1.0);
return length(pa - ba * h) - mix(ra, rb, h);
}
// Evaluate Weber-Penn 3-level recursive tree SDF: returns vec2(distance, matId)
// matId: 1 = L0 Trunk, 2 = L1 Primary Limbs, 3 = L2 Secondary Boughs, 4 = Leaf Canopy, 5 = Ground
vec2 mapTree(vec3 p, float splitAng, float curveK, float canDens, bool includeLeaves) {
float dGround = p.y + 0.68 - 0.06 * cos(length(p.xz) * 1.4);
vec2 res = vec2(dGround, 5.0);
// Level 0: Tapered slightly curved main trunk with buttress flare at base
vec3 t0 = vec3(0.0, -0.70, 0.0);
vec3 t1 = vec3(0.04 * curveK, -0.05, 0.0);
vec3 t2 = vec3(-0.03 * curveK, 0.42, 0.02 * curveK);
float dL0 = min(
sdTaperCapsule(p, t0, t1, 0.115, 0.072),
sdTaperCapsule(p, t1, t2, 0.072, 0.040)
);
if (dL0 < res.x) res = vec2(dL0, 1.0);
// Level 1 (5 primary limbs) + Level 2 (2 secondary boughs each = 10 twigs) + Leaf clusters at tips
float dL1 = 1e5;
float dL2 = 1e5;
float dLeaf = 1e5;
for (int i = 0; i < 5; i++) {
float fi = float(i);
float az = fi * 1.256637 + 0.35;
float hStart = -0.06 + fi * 0.105;
vec3 bStart = mix(t1, t2, clamp((hStart + 0.05) / 0.47, 0.0, 1.0));
// Weber-Penn down-angle + upward phototropism bend
float elev = 1.15 - splitAng * 0.72 + curveK * 0.35;
vec3 dir1 = normalize(vec3(cos(az) * sin(elev), cos(elev) + 0.35 + curveK * 0.35, sin(az) * sin(elev)));
float len1 = (0.58 - fi * 0.045) * (0.85 + 0.25 * splitAng);
vec3 bMid = bStart + dir1 * (len1 * 0.55);
vec3 bEnd = bMid + normalize(dir1 + vec3(0.0, curveK * 0.95, 0.0)) * (len1 * 0.52);
float r1 = 0.042 - fi * 0.004;
dL1 = min(dL1, sdTaperCapsule(p, bStart, bMid, r1, r1 * 0.68));
dL1 = min(dL1, sdTaperCapsule(p, bMid, bEnd, r1 * 0.68, r1 * 0.36));
// Two Level-2 secondary boughs splitting off each primary limb
for (int j = 0; j < 2; j++) {
float side = (j == 0) ? -1.0 : 1.0;
float az2 = az + side * (0.55 + splitAng * 0.45);
vec3 dir2 = normalize(vec3(cos(az2), 0.58 + curveK * 0.65, sin(az2)));
vec3 sStart = mix(bMid, bEnd, float(j) * 0.45 + 0.25);
vec3 sEnd = sStart + dir2 * (0.34 - fi * 0.02);
dL2 = min(dL2, sdTaperCapsule(p, sStart, sEnd, r1 * 0.42, 0.010));
if (includeLeaves) {
float clR = (0.24 + 0.04 * sin(fi * 2.1 + side)) * canDens;
float dC = length(p - sEnd) - clR;
if (dC < 0.12) {
float leafN = noise3(p * 11.0 + vec3(iTime * 0.35, 0.0, 0.0)) - 0.5;
dC += leafN * 0.095;
}
dLeaf = min(dLeaf, dC);
}
}
if (includeLeaves) {
float tipR = 0.25 * canDens;
float dTip = length(p - bEnd) - tipR;
if (dTip < 0.12) {
dTip += (noise3(p * 11.0 + vec3(iTime * 0.35, 1.7, 0.0)) - 0.5) * 0.095;
}
dLeaf = min(dLeaf, dTip);
}
}
// Crown apex cluster
if (includeLeaves) {
vec3 apex = t2 + vec3(0.0, 0.28 + curveK * 0.14, 0.0);
float dApex = length(p - apex) - 0.27 * canDens;
if (dApex < 0.12) dApex += (noise3(p * 11.0 + vec3(iTime * 0.35, 3.1, 0.0)) - 0.5) * 0.095;
dLeaf = min(dLeaf, dApex);
}
if (dL1 < res.x) res = vec2(dL1, 2.0);
if (dL2 < res.x) res = vec2(dL2, 3.0);
if (includeLeaves && dLeaf < res.x) res = vec2(dLeaf, 4.0);
return res;
}
vec3 calcNormal(vec3 p, float splitAng, float curveK, float canDens, bool includeLeaves) {
vec2 e = vec2(0.003, 0.0);
return normalize(vec3(
mapTree(p + e.xyy, splitAng, curveK, canDens, includeLeaves).x - mapTree(p - e.xyy, splitAng, curveK, canDens, includeLeaves).x,
mapTree(p + e.yxy, splitAng, curveK, canDens, includeLeaves).x - mapTree(p - e.yxy, splitAng, curveK, canDens, includeLeaves).x,
mapTree(p + e.yyx, splitAng, curveK, canDens, includeLeaves).x - mapTree(p - e.yyx, splitAng, curveK, canDens, includeLeaves).x
));
}
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 sx = fragCoord.x / max(iResolution.x, 1.0);
float split = clamp(P_SPLIT, 0.0, 1.0);
bool showFoliage = sx >= split;
float splitAng = clamp(P_SPLIT_ANGLE, 0.15, 0.95);
float curveK = clamp(P_CURVATURE, 0.0, 0.85);
float canDens = clamp(P_CANOPY_DENS, 0.3, 1.6);
float orb = iTime * 0.28 + 0.4;
vec3 ro = vec3(2.45 * sin(orb), 0.34, 2.45 * cos(orb));
vec3 ta = vec3(0.0, 0.10, 0.0);
vec3 fw = normalize(ta - ro);
vec3 ri = normalize(cross(fw, vec3(0.0, 1.0, 0.0)));
vec3 up = cross(ri, fw);
vec3 rd = normalize(fw * 1.44 + ri * uv.x + up * uv.y);
vec3 sunDir = normalize(vec3(0.62, 0.76, 0.48));
vec3 sky = mix(vec3(0.76, 0.84, 0.94), vec3(0.18, 0.40, 0.76), smoothstep(-0.08, 0.58, rd.y));
vec3 col = showFoliage ? sky : mix(vec3(0.05, 0.07, 0.11), vec3(0.12, 0.16, 0.24), smoothstep(-0.2, 0.6, rd.y));
float t = 0.08;
float hitId = 0.0;
for (int i = 0; i < 64; i++) {
vec2 h = mapTree(ro + rd * t, splitAng, curveK, canDens, showFoliage);
if (h.x < 0.0028) { hitId = h.y; break; }
t += h.x * 0.82;
if (t > 9.0) break;
}
if (hitId > 0.5) {
vec3 p = ro + rd * t;
vec3 n = calcNormal(p, splitAng, curveK, canDens, showFoliage);
float ndl = max(dot(n, sunDir), 0.0);
// Quick soft canopy shadow
float sh = 1.0;
float ts = 0.06;
for (int s = 0; s < 14; s++) {
float ds = mapTree(p + sunDir * ts, splitAng, curveK, canDens, showFoliage).x;
if (ds < 0.004) { sh = 0.18; break; }
sh = min(sh, 5.0 * ds / max(ts, 1e-4) + 0.18);
ts += max(ds, 0.05);
if (ts > 2.4) break;
}
sh = clamp(sh, 0.18, 1.0);
if (!showFoliage) {
// Left: Color-coded Weber-Penn parametric recursion hierarchy (L0 Trunk, L1 Primary, L2 Secondary, Blueprint Ground)
if (hitId > 4.5) {
vec2 g = abs(fract(p.xz * 2.5) - 0.5);
float gl = smoothstep(0.04, 0.01, min(0.5 - g.x, 0.5 - g.y));
col = mix(vec3(0.07, 0.09, 0.13), vec3(0.22, 0.42, 0.58), gl * 0.65) * (0.55 + 0.45 * sh);
} else {
vec3 lvlCol = vec3(0.95, 0.55, 0.22); // L0 Trunk
if (hitId > 1.5 && hitId < 2.5) lvlCol = vec3(0.22, 0.88, 0.98); // L1 Primary limbs
else if (hitId > 2.5) lvlCol = vec3(0.32, 0.96, 0.48); // L2 Secondary twigs
col = lvlCol * (0.35 + 0.85 * ndl) + vec3(0.9) * pow(max(dot(n, normalize(sunDir - rd)), 0.0), 24.0) * 0.25;
}
} else {
// Right: Full skinned bark & backlit translucent green foliage canopy!
vec3 skyAmb = mix(vec3(0.16, 0.22, 0.18), vec3(0.34, 0.48, 0.72), 0.5 + 0.5 * n.y);
if (hitId > 4.5) {
vec3 grass = mix(vec3(0.18, 0.34, 0.14), vec3(0.28, 0.44, 0.18), noise3(p * 3.5));
col = grass * (vec3(1.32, 1.22, 0.98) * ndl * sh + skyAmb * 0.52);
col = mix(col, sky, 1.0 - exp(-t * 0.09));
} else if (hitId < 3.5) {
float bark = 0.75 + 0.25 * sin(atan(p.z, p.x) * 18.0 + p.y * 12.0);
vec3 barkAlb = vec3(0.28, 0.20, 0.13) * bark;
col = barkAlb * (vec3(1.25, 1.12, 0.92) * ndl * sh + skyAmb * 0.48);
} else {
// Lush sunlit leaves with warm yellow-green subsurface translucency
float leafVar = noise3(p * 14.0);
vec3 leafAlb = mix(vec3(0.10, 0.32, 0.10), vec3(0.26, 0.52, 0.14), leafVar);
float sss = pow(max(dot(rd, sunDir), 0.0), 3.0) * 0.55 + 0.25 * max(dot(-n, sunDir), 0.0);
col = leafAlb * (vec3(1.42, 1.28, 0.96) * ndl * sh + skyAmb * 0.58)
+ vec3(0.58, 0.82, 0.18) * sss * (0.4 + 0.6 * sh);
}
}
}
float sep = smoothstep(0.0035, 0.0008, abs(sx - 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 |
|---|---|---|---|
| weber-penn-tree-generation-live | Tesla T4 1920x1080 | 643× baseline (extreme) · 21.1 ms / 21.7 ms | opengl-timer-query · 16 frames · GPU Weight Atlas · Colab T4 sweep |
| weber-penn-tree-generation-live | NVIDIA L4 1920x1080 | 563× baseline (extreme) · 8.96 ms / 9.06 ms · 2.4× faster on L4 | opengl-timer-query · Cross-architecture validation |
| weber-penn-tree-generation-live | NVIDIA A100-SXM4-40GB 1920x1080 | 447× baseline (extreme) · 12.9 ms / 12.9 ms · 1.6× faster on A100 | opengl-timer-query · Cross-architecture validation |
Lineage
From the citation graph (Crossref reference lists): cited by Wang Tiles (Aperiodic Tile Synthesis).
Crosses
- Space Colonization Tree Modeling: A Weber–Penn trunk and main branches can seed the crown, and space colonization then fills twig-level detail inside it.
Sources
- primaryJason Weber, Joseph Penn (1995). Creation and rendering of realistic trees. Proceedings of the 22nd annual conference on Computer graphics and interactive techniques - SIGGRAPH '95.Verified via crossref · 2026-11-29doi:10.1145/218380.218427