L-Systems
Parallel string-rewriting grammars whose output symbols are interpreted by a turtle to draw branching structures. Parametric, stochastic and context-sensitive variants model plant development.
Also known as Lindenmayer systems, turtle-graphics plants, parametric L-systems
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 | |
| Unity | None found | |
| Unreal 5.7 | None found | |
| Blender 5.2 | None found | |
| WebGPU W3C | None found | |
| Metal | None found |
How it works
An L-system consists of an alphabet, an axiom and productions applied to every symbol simultaneously in each generation, so growth is parallel like cell division. After n generations the string is interpreted by a turtle: F moves forward and draws a segment, + and - turn, [ and ] push and pop turtle state to create branches. Parametric versions attach numeric parameters (length, thickness, age) to symbols and condition productions on them, stochastic versions pick productions by probability, and context-sensitive versions let neighbours influence a rewrite so signals can travel along the plant. Open L-systems exchange information with an environment, enabling effects like phototropism or pruning. The Algorithmic Beauty of Plants gives the canonical treatment and examples.
When to choose it
Reach for it when
- generate trees and plants procedurally
- need branching structures from simple rewrite rules
- make fractal growth patterns like ferns
- vary vegetation models without modeling each by hand
Choose it for trees, ferns, flowers and fractal curves where the developmental rules are the creative control, and for architecture-style recursion. Prefer Space Colonization Tree Modeling when branches should fill a volume or follow an attractor shape with minimal parameters, Interactive Climbing Plant Modeling for vegetation interacting with geometry, and CGA Shape Grammar (Procedural Buildings) for building facades.
Field marks
- Exponential string growth blows memory and time for deep derivations
- Turtle interpretation produces self-intersecting branches that require explicit collision handling
- Context-free rules look rigidly symmetric unless stochastic or parametric randomness is added
- Tuning production parameters is non-intuitive: tiny changes give wildly different plants
- No built-in environment awareness: trees ignore walls, light and neighbours unless open L-systems are used
Presets
Dragon curve drawn from an L-system rewrite (512 turtle segments)
{
"SEGS": 512,
"UNIT": 0.028
}Show GLSL (30 lines)
// Dragon curve as an L-system (F->F+G, G->F-G), 512 turtle segments; turn direction of step k read off the rewrite by its bit pattern.
const int SEGS = 512;
const float UNIT = 0.028;
const vec2 CENTER = vec2(0.5, 0.5);
float segd(vec2 p, vec2 a, vec2 b) {
vec2 pa = p - a, ba = b - a;
return length(pa - ba * clamp(dot(pa, ba) / dot(ba, ba), 0.0, 1.0));
}
void mainImage(out vec4 fragColor, in vec2 fragCoord) {
vec2 uv = fragCoord / iResolution.xy;
vec2 pos = vec2(0.0), dir = vec2(1.0, 0.0);
vec2 origin = CENTER - UNIT * vec2(8.0, 5.5);
float best = 1e9, bi = 0.0;
vec2 a = origin;
for (int k = 1; k <= SEGS; k++) {
vec2 b = a + dir * UNIT;
float d = segd(uv, a, b);
if (d < best) { best = d; bi = float(k) / float(SEGS); }
a = b;
int m = k;
while ((m & 1) == 0) m >>= 1;
dir = ((m & 3) == 1) ? vec2(-dir.y, dir.x) : vec2(dir.y, -dir.x);
}
vec3 bg = mix(vec3(0.04, 0.05, 0.09), vec3(0.09, 0.08, 0.14), uv.y);
vec3 lc = 0.5 + 0.5 * cos(6.2831 * (bi * 0.9 + vec3(0.0, 0.33, 0.67)));
float w = smoothstep(0.0042, 0.0016, best);
vec3 col = bg + lc * w + lc * 0.12 * smoothstep(0.02, 0.0, best);
fragColor = vec4(pow(col, vec3(0.8)), 1.0);
}
Attribution: written for this index
Measured GPU weight & timing
| Preset | GPU | Weight / p50 / p95 | Method |
|---|---|---|---|
| l-systems-specimen | Tesla T4 1920x1080 | 248× baseline (extreme) · 8.17 ms / 8.19 ms | opengl-timer-query · 40 frames · GPU Weight Atlas · Colab T4 sweep |
| l-systems-specimen | NVIDIA L4 1920x1080 | 241× baseline (extreme) · 3.82 ms / 3.86 ms · 2.1× faster on L4 | opengl-timer-query · Cross-architecture validation |
| l-systems-specimen | NVIDIA A100-SXM4-40GB 1920x1080 | 161× baseline (extreme) · 4.64 ms / 4.64 ms · 1.8× faster on A100 | opengl-timer-query · Cross-architecture validation |
Lineage
Sources
- primaryPrzemyslaw Prusinkiewicz, Aristid Lindenmayer. The Algorithmic Beauty of Plants. algorithmicbotany.org.Verified via live page · 2026-11-29