{
 "id": "procedural-city-roads",
 "title": "Procedural City Generation (L-system Road Networks)",
 "aliases": [
  "Parish and Müller city generation",
  "CityEngine road growth"
 ],
 "domain": "procgen",
 "subdomain": "buildings and cities",
 "stage": "procedural",
 "realtime": "interactive",
 "platforms": [
  "cpu",
  "houdini",
  "blender",
  "unity",
  "unreal"
 ],
 "year_introduced": 2001,
 "inputs": [
  "heightfield",
  "texture"
 ],
 "outputs": [
  "graph",
  "layout",
  "mesh"
 ],
 "style": "photoreal",
 "dynamic": "static",
 "summary": "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.",
 "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_use": "Choose it to generate road graphs and block structure for settlements that respond to terrain and density maps. Prefer `cga-shape-grammar` for the building detail pass, `voronoi-lloyd-relaxation` for organic block subdivision, `poisson-disk-sampling` for scattering trees or props in the blocks, and `bsp-dungeon-generation` for interior or room layouts.",
 "cost": {
  "class": "medium",
  "notes": "Road growth and lot subdivision are fast; building mesh generation dominates for large cities."
 },
 "failure_modes": [
  "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"
 ],
 "sources": [
  {
   "role": "primary",
   "key": "doi:10.1145/383259.383292",
   "type": "paper",
   "title": "Procedural modeling of cities",
   "authors": [
    "Yoav I. H. Parish",
    "Pascal Müller"
   ],
   "year": 2001,
   "venue": "Proceedings of the 28th annual conference on Computer graphics and interactive techniques",
   "url": "https://doi.org/10.1145/383259.383292",
   "ids": {
    "doi": "10.1145/383259.383292"
   },
   "license": null,
   "extra": {
    "csl_type": "proceedings-article"
   },
   "provenance": {
    "title": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/383259.383292",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "authors": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/383259.383292",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "year": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/383259.383292",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "venue": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/383259.383292",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "url": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/383259.383292",
     "checked_at": "2026-11-29T15:51:27.588Z"
    }
   },
   "status": "verified",
   "checked_at": "2026-11-29T15:51:27.588Z",
   "title_sim": 1,
   "__bib": "parish2001procedural"
  },
  {
   "role": "implementation",
   "key": "gh:probabletrain/mapgenerator",
   "type": "code",
   "title": "ProbableTrain/MapGenerator",
   "description": "ProcGen American City Maps",
   "authors": [
    "ProbableTrain"
   ],
   "year": 2020,
   "venue": "GitHub",
   "url": "https://github.com/ProbableTrain/MapGenerator",
   "ids": {
    "repo": "ProbableTrain/MapGenerator"
   },
   "license": "LGPL-3.0",
   "extra": {
    "stars": 1492,
    "stars_checked": "2026-11-29",
    "archived": false,
    "fork": false,
    "pushed_at": "2024-05-09T21:32:30Z",
    "language": "TypeScript",
    "homepage": "https://maps.probabletrain.com",
    "license_name": "GNU Lesser General Public License v3.0"
   },
   "provenance": {
    "title": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/ProbableTrain/MapGenerator",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "authors": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/ProbableTrain/MapGenerator",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "year": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/ProbableTrain/MapGenerator",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "venue": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/ProbableTrain/MapGenerator",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "url": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/ProbableTrain/MapGenerator",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "license": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/ProbableTrain/MapGenerator",
     "checked_at": "2026-11-29T15:51:27.588Z"
    }
   },
   "status": "verified",
   "checked_at": "2026-11-29T15:51:27.588Z",
   "title_sim": null,
   "__bib": "probabletrain2020probabletrain"
  }
 ],
 "presets": [
  {
   "id": "procedural-city-roads-live",
   "title": "Procedural city roads — tensor-guided arterials, parcel blocks & night traffic streams",
   "runtime": "glsl-fragment",
   "params": {
    "P_GRID_SCALE": 5.2,
    "P_CURVATURE": 0.75,
    "P_TRAFFIC_SPEED": 1,
    "P_BLOCK_DENSITY": 0.82
   },
   "basis": "original",
   "license_note": "Original interactive WebGL2 fragment shader written for Texel Atlas (MIT).",
   "code": "const float P_GRID_SCALE = 5.2; // P District Scale [2.5, 9.0, 0.2]\nconst float P_CURVATURE = 0.75; // P Tensor Warp [0.0, 1.6, 0.05]\nconst float P_TRAFFIC_SPEED = 1.0; // P Traffic Flow [0.0, 2.5, 0.05]\nconst float P_BLOCK_DENSITY = 0.82; // P Building Density [0.2, 1.0, 0.02]\n\nfloat hash21(vec2 p) {\n  p = fract(p * vec2(127.1, 311.7));\n  p += dot(p, p + 34.5);\n  return fract(p.x * p.y);\n}\n\n// Smooth urban tensor-field coordinate warp (curves streets along river & ring roads)\nvec2 cityWarp(vec2 p, float curv) {\n  vec2 w = vec2(\n    0.26 * sin(p.y * 0.55 + 0.4) + 0.14 * cos(p.x * 0.35 - p.y * 0.45),\n    0.24 * cos(p.x * 0.52 - 0.3) + 0.12 * sin(p.x * 0.42 + p.y * 0.38)\n  );\n  return p + w * curv;\n}\n\nvec3 aces(vec3 x) {\n  x = max(x, 0.0);\n  return (x * (2.51 * x + 0.03)) / (x * (2.43 * x + 0.59) + 0.14);\n}\n\nvoid mainImage(out vec4 fragColor, in vec2 fragCoord) {\n  vec2 uv = (fragCoord - 0.5 * iResolution.xy) / iResolution.y;\n  float px = 1.0 / iResolution.y;\n\n  float scale = clamp(P_GRID_SCALE, 2.0, 10.0);\n  float curv = clamp(P_CURVATURE, 0.0, 1.8);\n  float spd = max(P_TRAFFIC_SPEED, 0.0);\n  float bDens = clamp(P_BLOCK_DENSITY, 0.15, 1.0);\n\n  vec2 pan = vec2(iTime * 0.12, iTime * 0.06);\n  vec2 p = uv * scale + pan;\n\n  // Winding river channel cutting across the city\n  float riverCenter = 0.55 * sin(p.x * 0.48 + 0.6) - 0.25 * cos(p.x * 0.95);\n  float dRiver = abs(p.y - riverCenter);\n  float isWater = smoothstep(0.44, 0.36, dRiver);\n  float riverBank = smoothstep(0.54, 0.42, dRiver) * (1.0 - isWater);\n\n  // Tensor-warped street lattice\n  vec2 wp = cityWarp(p, curv);\n\n  // Level 1: Primary arterial boulevards (coarse grid)\n  vec2 artCell = floor(wp * 0.5);\n  vec2 artF = abs(fract(wp * 0.5 + 0.5) - 0.5);\n  float dArt = min(artF.x, artF.y);\n  float isArterial = smoothstep(0.055, 0.032, dArt);\n  float artCenter = smoothstep(0.012, 0.003, dArt);\n\n  // Level 2: Secondary avenues (subdivision per district)\n  vec2 secF = abs(fract(wp * 1.5 + 0.5) - 0.5);\n  float dSec = min(secF.x, secF.y);\n  float isSecondary = smoothstep(0.068, 0.038, dSec) * (1.0 - isWater);\n\n  // Level 3: Local residential streets & building parcels\n  vec2 blkId = floor(wp * 1.5);\n  float blkRand = hash21(blkId);\n  float subDiv = mix(3.0, 4.5, step(0.45, blkRand));\n  vec2 locF = abs(fract(wp * subDiv) - 0.5);\n  vec2 parcelId = floor(wp * subDiv);\n  float pRand = hash21(parcelId + blkId * 17.0);\n  float dLoc = min(locF.x, locF.y);\n  float isLocal = smoothstep(0.085, 0.045, dLoc) * (1.0 - isWater);\n\n  // Base urban night map: dark slate blocks + landscaped parks\n  float isPark = step(bDens, blkRand) * (1.0 - isWater);\n  vec3 blockCol = mix(vec3(0.045, 0.055, 0.075), vec3(0.055, 0.12, 0.085), isPark);\n\n  // Illuminated architectural building footprints inside non-park parcels\n  float pad = 0.14 + 0.10 * pRand;\n  float bldg = smoothstep(0.5 - pad + 0.03, 0.5 - pad - 0.02, max(locF.x, locF.y));\n  bldg *= (1.0 - isPark) * (1.0 - isWater) * step(0.18, pRand);\n  float height = 0.35 + 0.65 * hash21(parcelId * 3.1 + 7.2);\n  vec3 bldgCol = mix(vec3(0.09, 0.12, 0.18), vec3(0.22, 0.28, 0.38), height);\n  // Warm window perimeter glow\n  float winEdge = smoothstep(0.5 - pad - 0.08, 0.5 - pad - 0.02, max(locF.x, locF.y)) * bldg;\n  bldgCol += vec3(0.95, 0.68, 0.28) * winEdge * (0.35 + 0.65 * step(0.52, pRand));\n\n  vec3 col = mix(blockCol, bldgCol, bldg);\n\n  // River water with subtle moonlight shimmer\n  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));\n  col = mix(col, vec3(0.08, 0.15, 0.12), riverBank * 0.7);\n  col = mix(col, waterCol, isWater);\n\n  // Composite road hierarchy (arterials bridge cleanly over the river!)\n  vec3 locRoad = vec3(0.13, 0.16, 0.22);\n  vec3 secRoad = vec3(0.24, 0.29, 0.38);\n  vec3 artRoad = vec3(0.32, 0.36, 0.44);\n\n  col = mix(col, locRoad, isLocal * 0.85);\n  col = mix(col, secRoad, isSecondary * 0.92);\n  col = mix(col, artRoad, isArterial);\n\n  // Glowing golden arterial centerlines & moving traffic light pulses\n  float laneX = smoothstep(0.032, 0.008, artF.y);\n  float laneY = smoothstep(0.032, 0.008, artF.x);\n  float carsX = pow(0.5 + 0.5 * sin(wp.x * 11.0 - iTime * 3.4 * spd + artCell.y * 4.0), 10.0) * laneX;\n  float carsY = pow(0.5 + 0.5 * sin(wp.y * 11.0 + iTime * 2.9 * spd + artCell.x * 5.0), 10.0) * laneY;\n  float secCars = pow(0.5 + 0.5 * sin((wp.x + wp.y) * 18.0 - iTime * 2.4 * spd), 12.0) * isSecondary;\n\n  col += vec3(1.0, 0.74, 0.26) * artCenter * 0.55;\n  col += vec3(1.4, 0.92, 0.42) * carsX * 1.15;\n  col += vec3(0.35, 0.88, 1.25) * carsY * 1.05;\n  col += vec3(1.0, 0.45, 0.35) * secCars * 0.55;\n\n  // Intersection nodes glow warmly\n  float inter = smoothstep(0.075, 0.015, length(artF));\n  col += vec3(1.15, 0.82, 0.38) * inter * 0.65;\n\n  // Blueprint framing vignette\n  col *= 1.0 - 0.22 * dot(uv, uv) + 0.0 * px;\n  fragColor = vec4(pow(clamp(aces(col), 0.0, 1.0), vec3(1.0 / 2.2)), 1.0);\n}",
   "execution_fidelity": "faithful-pass",
   "proof": {
    "kind": "rendered",
    "label": "rendered 2026-11-30",
    "ok": true,
    "proof": {
     "ok": true,
     "technique": "procedural-city-roads",
     "runtime": "glsl-fragment",
     "checked_at": "2026-11-30T16:50:13.852Z",
     "renderer": "Chromium 145.0.7632.6 headless, WebGL2 via ANGLE/SwiftShader, 512×512, iTime=1.5",
     "stats": {
      "mean": 0.519,
      "std": 0.1996,
      "unique_colors": 485
     },
     "image": "/specimens/procedural-city-roads-live.webp",
     "reason": null
    }
   }
  }
 ],
 "related": [
  "cga-shape-grammar",
  "l-systems",
  "voronoi-lloyd-relaxation",
  "poisson-disk-sampling"
 ],
 "extends": [
  "l-systems"
 ],
 "supersedes": [],
 "combines_with": [],
 "provenance": {
  "prose": "original text written for this index (research draft, editorially reviewed)",
  "sources_verified_at": "2026-11-29T15:51:27.588Z",
  "draft": "data/drafts/procgen/procedural-city-roads.json"
 },
 "solves": [
  "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"
 ],
 "authority": "Parish & Müller, 2001",
 "url": "https://texelatlas.vercel.app/t/procedural-city-roads/",
 "execution_fidelity": "faithful-pass",
 "fidelity_label": "Faithful Pass",
 "benchmark_eligible": true,
 "gpu_weight": {
  "weight_x": 7.16,
  "tier": "moderate",
  "p50_ms": 0.2354,
  "p95_ms": 0.2419,
  "baseline_p50_ms": 0.0329,
  "gpu": "Tesla T4/PCIe/SSE2",
  "resolution": "1920x1080",
  "method": "opengl-timer-query",
  "frames": 40,
  "preset_id": "procedural-city-roads-live",
  "execution_fidelity": "faithful-pass",
  "fidelity_label": "Faithful Pass",
  "benchmark_eligible": true,
  "generated_at": "2026-11-30T21:07:47Z",
  "l4": {
   "weight_x": 5.45,
   "tier": "light",
   "p50_ms": 0.0866,
   "p95_ms": 0.0874,
   "speedup_x": 2.72,
   "gpu": "NVIDIA L4/PCIe/SSE2",
   "resolution": "1920x1080",
   "baseline_p50_ms": 0.0159
  },
  "a100": {
   "weight_x": 4.42,
   "tier": "light",
   "p50_ms": 0.1273,
   "p95_ms": 0.1277,
   "speedup_x": 1.85,
   "gpu": "NVIDIA A100-SXM4-40GB/PCIe/SSE2",
   "resolution": "1920x1080",
   "baseline_p50_ms": 0.0288
  }
 }
}