Procedural City Generation (L-system Road Networks)
Generate a city by growing a street network with an extended L-system that responds to population-density and terrain maps, then subdividing the blocks into lots and extruding buildings.
Also known as Parish and Müller city generation, CityEngine road growth
In the family Procedural generation, buildings and cities
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 procedural L-system city road generator. |
| Unity | None found | |
| Unreal 5.7 | None found | |
| Blender 5.2 | None found | |
| WebGPU W3C | None found | |
| Metal | None found |
How it works
The pipeline starts from input maps (elevation, water, population density). An extended L-system grows the road network: each road segment either continues or branches, with parameters adjusted by the local maps and by local constraints such as avoiding water or slopes, and segments snap to nearby intersections to form a connected graph. Road patterns (grid, radial, organic) are set per region. The enclosed regions between roads are extracted as blocks and recursively subdivided into building lots, and buildings are generated per lot (originally with a lot-specific L-system, later with CGA-style grammars). Textured facades then dress the geometry.
When to choose it
Reach for it when
- generate a believable street network automatically
- road layouts should follow terrain and population
- want city roads with highways and local streets
- fill a large world with plausible urban layout
Choose it to generate road graphs and block structure for settlements that respond to terrain and density maps. Prefer CGA Shape Grammar (Procedural Buildings) for the building detail pass, Voronoi Diagrams and Lloyd Relaxation for organic block subdivision, Poisson Disk Sampling (Bridson) for scattering trees or props in the blocks, and BSP Dungeon Generation for interior or room layouts.
Field marks
- Road graphs get dead ends, tiny blocks or non-planar crossings unless snapping and cleanup rules are applied
- Lots with unusual shapes cannot hold buildings and are left empty or filled with bad footprints
- Growth near water or slopes may violate constraints without careful cost functions
- Parameter interplay is non-obvious, so tuning city 'feel' is trial and error
Presets
Procedural city roads — tensor-guided arterials, parcel blocks & night traffic streams
{
"P_GRID_SCALE": 5.2,
"P_CURVATURE": 0.75,
"P_TRAFFIC_SPEED": 1,
"P_BLOCK_DENSITY": 0.82
}Show GLSL (118 lines)
const float P_GRID_SCALE = 5.2; // P District Scale [2.5, 9.0, 0.2]
const float P_CURVATURE = 0.75; // P Tensor Warp [0.0, 1.6, 0.05]
const float P_TRAFFIC_SPEED = 1.0; // P Traffic Flow [0.0, 2.5, 0.05]
const float P_BLOCK_DENSITY = 0.82; // P Building Density [0.2, 1.0, 0.02]
float hash21(vec2 p) {
p = fract(p * vec2(127.1, 311.7));
p += dot(p, p + 34.5);
return fract(p.x * p.y);
}
// Smooth urban tensor-field coordinate warp (curves streets along river & ring roads)
vec2 cityWarp(vec2 p, float curv) {
vec2 w = vec2(
0.26 * sin(p.y * 0.55 + 0.4) + 0.14 * cos(p.x * 0.35 - p.y * 0.45),
0.24 * cos(p.x * 0.52 - 0.3) + 0.12 * sin(p.x * 0.42 + p.y * 0.38)
);
return p + w * curv;
}
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 px = 1.0 / iResolution.y;
float scale = clamp(P_GRID_SCALE, 2.0, 10.0);
float curv = clamp(P_CURVATURE, 0.0, 1.8);
float spd = max(P_TRAFFIC_SPEED, 0.0);
float bDens = clamp(P_BLOCK_DENSITY, 0.15, 1.0);
vec2 pan = vec2(iTime * 0.12, iTime * 0.06);
vec2 p = uv * scale + pan;
// Winding river channel cutting across the city
float riverCenter = 0.55 * sin(p.x * 0.48 + 0.6) - 0.25 * cos(p.x * 0.95);
float dRiver = abs(p.y - riverCenter);
float isWater = smoothstep(0.44, 0.36, dRiver);
float riverBank = smoothstep(0.54, 0.42, dRiver) * (1.0 - isWater);
// Tensor-warped street lattice
vec2 wp = cityWarp(p, curv);
// Level 1: Primary arterial boulevards (coarse grid)
vec2 artCell = floor(wp * 0.5);
vec2 artF = abs(fract(wp * 0.5 + 0.5) - 0.5);
float dArt = min(artF.x, artF.y);
float isArterial = smoothstep(0.055, 0.032, dArt);
float artCenter = smoothstep(0.012, 0.003, dArt);
// Level 2: Secondary avenues (subdivision per district)
vec2 secF = abs(fract(wp * 1.5 + 0.5) - 0.5);
float dSec = min(secF.x, secF.y);
float isSecondary = smoothstep(0.068, 0.038, dSec) * (1.0 - isWater);
// Level 3: Local residential streets & building parcels
vec2 blkId = floor(wp * 1.5);
float blkRand = hash21(blkId);
float subDiv = mix(3.0, 4.5, step(0.45, blkRand));
vec2 locF = abs(fract(wp * subDiv) - 0.5);
vec2 parcelId = floor(wp * subDiv);
float pRand = hash21(parcelId + blkId * 17.0);
float dLoc = min(locF.x, locF.y);
float isLocal = smoothstep(0.085, 0.045, dLoc) * (1.0 - isWater);
// Base urban night map: dark slate blocks + landscaped parks
float isPark = step(bDens, blkRand) * (1.0 - isWater);
vec3 blockCol = mix(vec3(0.045, 0.055, 0.075), vec3(0.055, 0.12, 0.085), isPark);
// Illuminated architectural building footprints inside non-park parcels
float pad = 0.14 + 0.10 * pRand;
float bldg = smoothstep(0.5 - pad + 0.03, 0.5 - pad - 0.02, max(locF.x, locF.y));
bldg *= (1.0 - isPark) * (1.0 - isWater) * step(0.18, pRand);
float height = 0.35 + 0.65 * hash21(parcelId * 3.1 + 7.2);
vec3 bldgCol = mix(vec3(0.09, 0.12, 0.18), vec3(0.22, 0.28, 0.38), height);
// Warm window perimeter glow
float winEdge = smoothstep(0.5 - pad - 0.08, 0.5 - pad - 0.02, max(locF.x, locF.y)) * bldg;
bldgCol += vec3(0.95, 0.68, 0.28) * winEdge * (0.35 + 0.65 * step(0.52, pRand));
vec3 col = mix(blockCol, bldgCol, bldg);
// River water with subtle moonlight shimmer
vec3 waterCol = vec3(0.025, 0.065, 0.12) + vec3(0.04, 0.11, 0.18) * (0.5 + 0.5 * sin(p.x * 6.0 + p.y * 8.0 - iTime * 1.4));
col = mix(col, vec3(0.08, 0.15, 0.12), riverBank * 0.7);
col = mix(col, waterCol, isWater);
// Composite road hierarchy (arterials bridge cleanly over the river!)
vec3 locRoad = vec3(0.13, 0.16, 0.22);
vec3 secRoad = vec3(0.24, 0.29, 0.38);
vec3 artRoad = vec3(0.32, 0.36, 0.44);
col = mix(col, locRoad, isLocal * 0.85);
col = mix(col, secRoad, isSecondary * 0.92);
col = mix(col, artRoad, isArterial);
// Glowing golden arterial centerlines & moving traffic light pulses
float laneX = smoothstep(0.032, 0.008, artF.y);
float laneY = smoothstep(0.032, 0.008, artF.x);
float carsX = pow(0.5 + 0.5 * sin(wp.x * 11.0 - iTime * 3.4 * spd + artCell.y * 4.0), 10.0) * laneX;
float carsY = pow(0.5 + 0.5 * sin(wp.y * 11.0 + iTime * 2.9 * spd + artCell.x * 5.0), 10.0) * laneY;
float secCars = pow(0.5 + 0.5 * sin((wp.x + wp.y) * 18.0 - iTime * 2.4 * spd), 12.0) * isSecondary;
col += vec3(1.0, 0.74, 0.26) * artCenter * 0.55;
col += vec3(1.4, 0.92, 0.42) * carsX * 1.15;
col += vec3(0.35, 0.88, 1.25) * carsY * 1.05;
col += vec3(1.0, 0.45, 0.35) * secCars * 0.55;
// Intersection nodes glow warmly
float inter = smoothstep(0.075, 0.015, length(artF));
col += vec3(1.15, 0.82, 0.38) * inter * 0.65;
// Blueprint framing vignette
col *= 1.0 - 0.22 * dot(uv, uv) + 0.0 * px;
fragColor = vec4(pow(clamp(aces(col), 0.0, 1.0), vec3(1.0 / 2.2)), 1.0);
}Attribution: Original interactive WebGL2 fragment shader written for Texel Atlas (MIT).
Measured GPU weight & timing
| Preset | GPU | Weight / p50 / p95 | Method |
|---|---|---|---|
| procedural-city-roads-live | Tesla T4 1920x1080 | 7.16× baseline (moderate) · 0.235 ms / 0.242 ms | opengl-timer-query · 40 frames · GPU Weight Atlas · Colab T4 sweep |
| procedural-city-roads-live | NVIDIA L4 1920x1080 | 5.45× baseline (light) · 0.087 ms / 0.087 ms · 2.7× faster on L4 | opengl-timer-query · Cross-architecture validation |
| procedural-city-roads-live | NVIDIA A100-SXM4-40GB 1920x1080 | 4.42× baseline (light) · 0.127 ms / 0.128 ms · 1.9× faster on A100 | opengl-timer-query · Cross-architecture validation |
Lineage
From the citation graph (Crossref reference lists): its primary source cites Catmull-Clark Subdivision, Plant Ecosystem Distribution Simulation; cited by CGA Shape Grammar (Procedural Buildings), Model Synthesis.
Crosses
- Cities wired by slime mould: Road networks that emerge from transport demand between settlements instead of hand-tuned growth rules. A slime-mould agent simulation links points of interest with efficient, redundant trails, which steer a street generator whose lots become buildings.
Sources
- primaryYoav I. H. Parish, Pascal Müller (2001). Procedural modeling of cities. Proceedings of the 28th annual conference on Computer graphics and interactive techniques.Verified via crossref · 2026-11-29doi:10.1145/383259.383292
- implementationProbableTrain (2020). ProbableTrain/MapGenerator. ProcGen American City MapsGitHub API · license LGPL-3.0 · 2026-11-29