{
 "id": "greebling",
 "title": "Greebling",
 "aliases": [
  "greebles",
  "kitbashing detail",
  "surface detail scattering"
 ],
 "domain": "procgen",
 "subdomain": "hard-surface detail",
 "stage": "procedural",
 "realtime": "offline",
 "platforms": [
  "blender",
  "houdini",
  "cpu",
  "python"
 ],
 "year_introduced": 1977,
 "inputs": [
  "mesh"
 ],
 "outputs": [
  "mesh"
 ],
 "style": "both",
 "dynamic": "static",
 "summary": "Adds small, plausible-looking mechanical detail (boxes, pipes, panels, vents) over large hard-surface forms so a flat hull or wall reads as complex, engineered scale.",
 "how_it_works": "The base mesh is analysed for face regions: large planar quads are split into panels by recursive subdivision (often along their longer axis), and each resulting panel is displaced by a small random depth or extruded into a block, with sizes sampled from a distribution that mimics real manufacturing detail. Greeble kits are libraries of small modules (vents, hatches, pipes) scattered onto panels with instancing, with size and density tied to distance from edges or to a mask. Rules can enforce orientation, spacing (blue noise) and no-intersection tests. The effect is mostly additive geometry or normal-map detail, giving high visual complexity at low authoring cost.",
 "when_to_use": "Choose it for spaceships, sci-fi walls and machinery, where the silhouette and secondary detail sell scale. Prefer `cga-shape-grammar` for architectural facades with consistent structure, `procedural-kit-modeling` when parts must be parametric, watertight and collision-verified, and `poisson-disk-sampling` for the placement of modules.",
 "cost": {
  "class": "offline",
  "notes": "Mesh generation with many instances; real-time use relies on instancing, normal maps or baked detail."
 },
 "failure_modes": [
  "Random uniform detail looks noisy without hierarchy: real structures have large, medium and small elements",
  "Overlapping or floating modules because placement ignores neighbour geometry",
  "Scale confusion: wrong module size relative to implied human scale breaks the sense of size",
  "Triangle counts balloon quickly if the splits are not limited"
 ],
 "sources": [
  {
   "role": "primary",
   "key": "url:https://en.wikipedia.org/wiki/Greeble",
   "type": "web",
   "title": "Greeble",
   "authors": [
    "Wikipedia"
   ],
   "year": null,
   "venue": "en.wikipedia.org",
   "url": "https://en.wikipedia.org/wiki/Greeble",
   "ids": {},
   "license": null,
   "extra": {
    "http_status": 200,
    "live": true,
    "archive": {
     "url": "http://web.archive.org/web/20261030174100/https://en.wikipedia.org/wiki/Greeble",
     "timestamp": "20261030174100"
    },
    "page_title": "Greeble - Wikipedia",
    "host": "en.wikipedia.org",
    "title_confirmed_by_page": true,
    "title_unconfirmed": false
   },
   "provenance": {
    "title": {
     "authority": "http",
     "endpoint": "GET https://en.wikipedia.org/wiki/Greeble → 200",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "url": {
     "authority": "http",
     "endpoint": "GET https://en.wikipedia.org/wiki/Greeble → 200",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "authors": {
     "authority": "research-draft",
     "endpoint": "title_hint/author_hint, checked against page title where available",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "venue": {
     "authority": "http",
     "endpoint": "GET https://en.wikipedia.org/wiki/Greeble → 200",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "year": {
     "authority": "research-draft",
     "endpoint": "title_hint/author_hint, checked against page title where available",
     "checked_at": "2026-11-29T15:51:27.588Z"
    }
   },
   "status": "verified",
   "checked_at": "2026-11-29T15:51:27.588Z",
   "title_sim": 0.9,
   "__bib": "wikipediagreeble"
  }
 ],
 "presets": [
  {
   "id": "greebling-live",
   "title": "Hierarchical sci-fi hull greebling — recursive panel subdivision, extruded blocks, vents and lights",
   "runtime": "glsl-fragment",
   "params": {
    "SCALE": 3.2,
    "DEPTH": 0.16,
    "PANEL_DETAIL": 4,
    "LIGHT_DENSITY": 0.28
   },
   "basis": "original",
   "license_note": "MIT — written for this index",
   "code": "const float SCALE = 3.2; // P\nconst float DEPTH = 0.16; // P\nconst int PANEL_DETAIL = 4; // P\nconst float LIGHT_DENSITY = 0.28; // P\n\nfloat hash21(vec2 p) {\n  vec3 q = fract(vec3(p.xyx) * vec3(0.1031, 0.1030, 0.0973));\n  q += dot(q, q.yzx + 33.33);\n  return fract((q.x + q.y) * q.z);\n}\n\n// Multi-level recursive quad-panel greeble heightfield (large hull plates -> modules -> vents/pipes)\nvec3 evalGreeble(vec2 p, out float lightMask, out float seamMask) {\n  int levels = clamp(PANEL_DETAIL, 1, 5);\n  float h = 0.0;\n  float matTone = 0.5;\n  lightMask = 0.0;\n  seamMask = 0.0;\n\n  vec2 q = p * max(SCALE, 0.5);\n  float amp = 1.0;\n  for (int lv = 0; lv < 5; lv++) {\n    if (lv >= levels) break;\n    vec2 id = floor(q);\n    vec2 f = fract(q);\n    float r1 = hash21(id + float(lv) * 19.7);\n    float r2 = hash21(id + float(lv) * 43.3 + 7.1);\n\n    // Split panel along alternating aspect ratios for authentic engineered hierarchy\n    vec2 edge = min(f, 1.0 - f);\n    float border = min(edge.x, edge.y);\n    float bevel = smoothstep(0.025, 0.075, border);\n    seamMask = max(seamMask, smoothstep(0.06, 0.015, border) * amp);\n\n    float blockH = (0.25 + 0.75 * r1) * bevel;\n    // Louver cooling vents on ~22% of mid-level panels\n    if (lv >= 1 && r2 > 0.76) {\n      float louver = 0.5 + 0.5 * sin(f.y * 37.7);\n      blockH *= 0.65 + 0.35 * step(0.45, louver);\n    }\n    // Recessed cylindrical conduit pipes on ~18% of panels\n    if (lv == 1 && r2 < 0.20) {\n      float pipe = smoothstep(0.16, 0.04, abs(f.x - 0.5));\n      blockH = mix(blockH * 0.4, 0.95, pipe);\n    }\n    h += blockH * amp;\n    matTone = mix(matTone, 0.28 + 0.52 * r2, amp * 0.45);\n\n    // Tiny glowing viewport slits on fine panels\n    if (lv >= 2 && r1 < clamp(LIGHT_DENSITY, 0.0, 1.0)) {\n      float win = smoothstep(0.18, 0.10, abs(f.y - 0.5)) * smoothstep(0.36, 0.28, abs(f.x - 0.5));\n      lightMask = max(lightMask, win * (r2 > 0.5 ? 1.0 : 2.0));\n    }\n\n    // Subdivide selectively based on cell hash so large plates coexist with dense clusters\n    float sub = (r1 > 0.35) ? 2.0 : 1.0;\n    q = fract(q) * sub + floor(q) * 2.0 + vec2(r2 * 1.3, r1 * 2.1);\n    amp *= 0.52;\n  }\n  return vec3(h * max(DEPTH, 0.01), matTone, 0.0);\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 camTilt = 0.28;\n  if (iMouse.z > 0.5 || length(iMouse.xy) > 1.0) {\n    camTilt = clamp((iMouse.y / iResolution.y) * 0.65 + 0.05, 0.05, 0.72);\n  }\n  vec3 ro = vec3(0.0, 1.35, -iTime * 0.35);\n  vec3 rd = normalize(vec3(uv.x, uv.y - camTilt - 0.32, -1.25));\n\n  // Raymarch perspective hull heightfield y = greeble(xz)\n  float t = 0.4, maxT = 16.0;\n  bool hit = false;\n  float lm = 0.0, sm = 0.0;\n  vec3 gVal = vec3(0.0);\n  for (int i = 0; i < 64; i++) {\n    vec3 p = ro + rd * t;\n    gVal = evalGreeble(p.xz, lm, sm);\n    float d = p.y - gVal.x;\n    if (d < 0.004) { hit = true; break; }\n    t += max(d * 0.55, 0.025 + t * 0.012);\n    if (t > maxT) break;\n  }\n\n  vec3 sky = mix(vec3(0.02, 0.04, 0.08), vec3(0.10, 0.16, 0.28), clamp(uv.y + 0.5, 0.0, 1.0));\n  vec3 col = sky;\n  if (hit) {\n    vec3 p = ro + rd * t;\n    float e = 0.008 + 0.003 * t;\n    float l0, s0;\n    float hx = evalGreeble(p.xz + vec2(e, 0.0), l0, s0).x - gVal.x;\n    float hz = evalGreeble(p.xz + vec2(0.0, e), l0, s0).x - gVal.x;\n    vec3 n = normalize(vec3(-hx, e, -hz));\n\n    vec3 keyDir = normalize(vec3(0.72, 0.58, 0.38));\n    vec3 rimDir = normalize(vec3(-0.75, 0.35, -0.55));\n    float nl = max(dot(n, keyDir), 0.0);\n    float rim = max(dot(n, rimDir), 0.0);\n    vec3 H = normalize(keyDir - rd);\n    float spec = pow(max(dot(n, H), 0.0), 36.0);\n\n    float ao = clamp(0.32 + 0.68 * (gVal.x / max(DEPTH * 1.4, 0.01)), 0.22, 1.0) * (1.0 - sm * 0.48);\n    vec3 hullAlb = mix(vec3(0.16, 0.19, 0.24), vec3(0.46, 0.50, 0.55), gVal.y);\n    col = hullAlb * ao * (vec3(0.08, 0.13, 0.22) + vec3(1.65, 1.48, 1.25) * nl + vec3(0.28, 0.52, 0.85) * rim * 0.65);\n    col += vec3(0.95, 0.90, 0.82) * spec * ao * 0.55;\n\n    // Emissive hull viewport lights (amber & cyan)\n    if (lm > 0.05) {\n      vec3 eCol = (lm > 1.5) ? vec3(0.35, 1.65, 2.4) : vec3(2.4, 1.35, 0.35);\n      col += eCol * smoothstep(0.05, 0.9, fract(lm + 0.999));\n    }\n    col = mix(col, sky, 1.0 - exp(-0.085 * t));\n  }\n  fragColor = vec4(pow(clamp(aces(col), 0.0, 1.0), vec3(1.0 / 2.2)), 1.0);\n}",
   "execution_fidelity": "conceptual-diagram",
   "proof": {
    "kind": "rendered",
    "label": "rendered 2026-11-30",
    "ok": true,
    "proof": {
     "ok": true,
     "technique": "greebling",
     "runtime": "glsl-fragment",
     "checked_at": "2026-11-30T16:15:34.232Z",
     "renderer": "Chromium 145.0.7632.6 headless, WebGL2 via ANGLE/SwiftShader, 512×512, iTime=1.5",
     "stats": {
      "mean": 0.6422,
      "std": 0.1545,
      "unique_colors": 378
     },
     "image": "/specimens/greebling-live.webp",
     "reason": null
    }
   }
  }
 ],
 "related": [
  "cga-shape-grammar",
  "procedural-kit-modeling",
  "poisson-disk-sampling"
 ],
 "extends": [],
 "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/greebling.json"
 },
 "solves": [
  "flat spaceship hull looks empty and scale-less",
  "sci-fi wall needs fine mechanical detail fast",
  "large surfaces read as toy-like without small details",
  "automatically scatter pipes, panels and vents",
  "make machinery look engineered and huge"
 ],
 "authority": "Wikipedia",
 "url": "https://texelatlas.vercel.app/t/greebling/",
 "execution_fidelity": "conceptual-diagram",
 "fidelity_label": "Visual Diagram",
 "benchmark_eligible": false,
 "gpu_weight": {
  "weight_x": 155.45,
  "tier": "extreme",
  "p50_ms": 5.1144,
  "p95_ms": 5.175,
  "baseline_p50_ms": 0.0329,
  "gpu": "Tesla T4/PCIe/SSE2",
  "resolution": "1920x1080",
  "method": "opengl-timer-query",
  "frames": 40,
  "preset_id": "greebling-live",
  "execution_fidelity": "conceptual-diagram",
  "fidelity_label": "Visual Diagram",
  "benchmark_eligible": false,
  "generated_at": "2026-11-30T21:07:47Z",
  "l4": {
   "weight_x": 129.42,
   "tier": "extreme",
   "p50_ms": 2.0577,
   "p95_ms": 2.0951,
   "speedup_x": 2.49,
   "gpu": "NVIDIA L4/PCIe/SSE2",
   "resolution": "1920x1080",
   "baseline_p50_ms": 0.0159
  },
  "a100": {
   "weight_x": 102.19,
   "tier": "extreme",
   "p50_ms": 2.943,
   "p95_ms": 2.9537,
   "speedup_x": 1.74,
   "gpu": "NVIDIA A100-SXM4-40GB/PCIe/SSE2",
   "resolution": "1920x1080",
   "baseline_p50_ms": 0.0288
  }
 }
}