{
 "id": "voronoi-island-map-generation",
 "title": "Polygon Map Generation (Voronoi Islands)",
 "aliases": [
  "mapgen2",
  "Voronoi island generation"
 ],
 "domain": "procgen",
 "subdomain": "terrain generation",
 "stage": "procedural",
 "realtime": "interactive",
 "platforms": [
  "cpu",
  "webgl2"
 ],
 "year_introduced": 2010,
 "inputs": [
  "point-cloud"
 ],
 "outputs": [
  "graph",
  "heightfield",
  "layout"
 ],
 "style": "stylized",
 "dynamic": "static",
 "summary": "Build fantasy-style island maps on a relaxed Voronoi graph: noise or radial shape sets land versus water, elevation grows from the coast, rivers follow downhill edges and moisture picks biomes.",
 "how_it_works": "Place seed points (Poisson or relaxed random), compute the Voronoi/Delaunay graph, and treat each polygon as a map cell. A shape function (radial or noise-based) marks cells as land or water; ocean is flood-filled from the border so lakes remain distinct. Elevation increases with distance from the coast, rivers are traced down steepest edges and accumulate flow, moisture comes from distance to rivers and lakes, and a biome table maps elevation and moisture to colour. The graph is explicit, so cells carry data for gameplay, and the result can be turned into a heightmap or mesh.",
 "when_to_use": "Choose it for game worlds, board-game maps and stylised overworld terrain where graph data (provinces, rivers) matters. Prefer `fractal-brownian-motion` or `stream-power-erosion` for realistic heightfields, `hydrology-terrain-synthesis` when river structure should shape terrain, and `procedural-city-roads` to lay out settlements.",
 "cost": {
  "class": "cheap",
  "notes": "Graph construction and a few linear passes; seconds even for large cell counts."
 },
 "failure_modes": [
  "Voronoi cell edges leave visibly polygonal coastlines unless smoothed or noise-perturbed",
  "River courses are constrained to cell edges, producing zigzag rivers",
  "Elevation from distance-to-coast gives uniform island-like shapes with little variety",
  "Biome tables overfit to Earth-like climates, giving odd maps on non-island layouts"
 ],
 "sources": [
  {
   "role": "primary",
   "key": "url:https://www.redblobgames.com/maps/mapgen2",
   "type": "web",
   "title": "Mapgen2 Procedural Island Map Generator",
   "authors": [
    "Amit Patel"
   ],
   "year": null,
   "venue": "redblobgames.com",
   "url": "https://www.redblobgames.com/maps/mapgen2",
   "ids": {},
   "license": null,
   "extra": {
    "http_status": 200,
    "live": true,
    "archive": {
     "url": "http://web.archive.org/web/20261108184710/https://www.redblobgames.com/maps/mapgen2/",
     "timestamp": "20261108184710"
    },
    "page_title": "Red Blob Games: Mapgen2 Procedural Island Map Generator",
    "host": "redblobgames.com",
    "title_confirmed_by_page": true,
    "title_unconfirmed": false
   },
   "provenance": {
    "title": {
     "authority": "http",
     "endpoint": "GET https://www.redblobgames.com/maps/mapgen2 → 200",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "url": {
     "authority": "http",
     "endpoint": "GET https://www.redblobgames.com/maps/mapgen2 → 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://www.redblobgames.com/maps/mapgen2 → 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.95,
   "__bib": "patelmapgen2"
  },
  {
   "role": "implementation",
   "key": "gh:redblobgames/mapgen2",
   "type": "code",
   "title": "redblobgames/mapgen2",
   "description": "JavaScript version of mapgen2 polygon map generator algorithms",
   "authors": [
    "redblobgames"
   ],
   "year": 2017,
   "venue": "GitHub",
   "url": "https://github.com/redblobgames/mapgen2",
   "ids": {
    "repo": "redblobgames/mapgen2"
   },
   "license": "Apache-2.0",
   "extra": {
    "stars": 454,
    "stars_checked": "2026-11-29",
    "archived": false,
    "fork": false,
    "pushed_at": "2026-03-29T20:53:30Z",
    "language": "JavaScript",
    "homepage": "https://www.redblobgames.com/maps/mapgen2/",
    "license_name": "Apache License 2.0"
   },
   "provenance": {
    "title": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/redblobgames/mapgen2",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "authors": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/redblobgames/mapgen2",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "year": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/redblobgames/mapgen2",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "venue": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/redblobgames/mapgen2",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "url": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/redblobgames/mapgen2",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "license": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/redblobgames/mapgen2",
     "checked_at": "2026-11-29T15:51:27.588Z"
    }
   },
   "status": "verified",
   "checked_at": "2026-11-29T15:51:27.588Z",
   "title_sim": null,
   "__bib": "redblobgames2017redblobgames"
  }
 ],
 "presets": [
  {
   "id": "voronoi-island-map-generation-specimen",
   "title": "Voronoi polygon island map with elevation-based biomes",
   "runtime": "glsl-fragment",
   "params": {
    "CELLS": 12,
    "SEA_LEVEL": 0.32
   },
   "code": "// Polygon island map: Voronoi cells from jittered sites get elevation (noise minus radial falloff) and biome by height.\nconst float CELLS = 12.0;\nconst float SEA_LEVEL = 0.32;\nvec2 hash2(vec2 p) { return fract(sin(vec2(dot(p, vec2(127.1, 311.7)), dot(p, vec2(269.5, 183.3)))) * 43758.5453); }\nfloat vnoise(vec2 p) {\n    vec2 i = floor(p), f = fract(p), u = f * f * (3.0 - 2.0 * f);\n    float a = hash2(i).x, b = hash2(i + vec2(1, 0)).x, c = hash2(i + vec2(0, 1)).x, d = hash2(i + 1.0).x;\n    return mix(mix(a, b, u.x), mix(c, d, u.x), u.y);\n}\nfloat elev(vec2 s) {\n    float n = 0.55 * vnoise(s * 4.0) + 0.3 * vnoise(s * 9.0 + 3.0) + 0.15 * vnoise(s * 19.0 + 9.0);\n    float r = length(s - 0.5) * 2.0;\n    return n * 1.1 - r * r * 0.8 + 0.18;\n}\nvoid mainImage(out vec4 fragColor, in vec2 fragCoord) {\n    vec2 uv = fragCoord / iResolution.xy;\n    vec2 p = uv * CELLS, ip = floor(p);\n    float d1 = 1e9, d2 = 1e9; vec2 best = vec2(0), second = vec2(0);\n    for (int j = -2; j <= 2; j++) for (int i = -2; i <= 2; i++) {\n        vec2 c = ip + vec2(i, j);\n        vec2 s = c + 0.15 + 0.7 * hash2(c);\n        float d = distance(p, s);\n        if (d < d1) { d2 = d1; second = best; d1 = d; best = s; } else if (d < d2) { d2 = d; second = s; }\n    }\n    float e = elev(best / CELLS);\n    vec3 col;\n    if (e < SEA_LEVEL) col = mix(vec3(0.05, 0.12, 0.3), vec3(0.15, 0.35, 0.55), smoothstep(-0.3, SEA_LEVEL, e));\n    else if (e < SEA_LEVEL + 0.04) col = vec3(0.85, 0.78, 0.55);\n    else if (e < 0.55) col = mix(vec3(0.3, 0.55, 0.25), vec3(0.15, 0.4, 0.2), (e - SEA_LEVEL) / 0.25);\n    else if (e < 0.7) col = mix(vec3(0.45, 0.4, 0.33), vec3(0.6, 0.57, 0.52), (e - 0.55) / 0.15);\n    else col = vec3(0.95);\n    float edge = (d2 - d1);\n    col *= 0.78 + 0.22 * smoothstep(0.0, 0.14, edge);\n    float es = elev(second / CELLS);\n    if ((e >= SEA_LEVEL) != (es >= SEA_LEVEL)) col = mix(col, vec3(0.1, 0.08, 0.05), smoothstep(0.1, 0.0, edge) * 0.8);\n    fragColor = vec4(pow(col, vec3(0.8)), 1.0);\n}\n",
   "basis": "original",
   "license_note": "written for this index",
   "execution_fidelity": "faithful-pass",
   "proof": {
    "kind": "rendered",
    "label": "rendered 2026-11-29",
    "ok": true,
    "proof": {
     "ok": true,
     "technique": "voronoi-island-map-generation",
     "runtime": "glsl-fragment",
     "checked_at": "2026-11-29T15:51:50.471Z",
     "renderer": "Chromium 145.0.7632.6 headless, WebGL2 via ANGLE/SwiftShader, 512×512, iTime=1.5",
     "stats": {
      "mean": 0.4215,
      "std": 0.2369,
      "unique_colors": 187
     },
     "image": "/specimens/voronoi-island-map-generation-specimen.webp",
     "reason": null
    }
   }
  }
 ],
 "related": [
  "voronoi-lloyd-relaxation",
  "poisson-disk-sampling",
  "hydrology-terrain-synthesis",
  "fractal-brownian-motion"
 ],
 "extends": [
  "voronoi-lloyd-relaxation"
 ],
 "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/voronoi-island-map-generation.json"
 },
 "solves": [
  "generate fantasy world maps with islands",
  "need game map with biomes and rivers",
  "polygon based terrain for strategy games",
  "noise maps look unnatural for coastlines"
 ],
 "authority": "Patel",
 "url": "https://texelatlas.vercel.app/t/voronoi-island-map-generation/",
 "execution_fidelity": "faithful-pass",
 "fidelity_label": "Faithful Pass",
 "benchmark_eligible": true,
 "gpu_weight": {
  "weight_x": 18.39,
  "tier": "moderate",
  "p50_ms": 0.6051,
  "p95_ms": 0.6312,
  "baseline_p50_ms": 0.0329,
  "gpu": "Tesla T4/PCIe/SSE2",
  "resolution": "1920x1080",
  "method": "opengl-timer-query",
  "frames": 40,
  "preset_id": "voronoi-island-map-generation-specimen",
  "execution_fidelity": "faithful-pass",
  "fidelity_label": "Faithful Pass",
  "benchmark_eligible": true,
  "generated_at": "2026-11-30T21:07:47Z",
  "l4": {
   "weight_x": 18.39,
   "tier": "moderate",
   "p50_ms": 0.2924,
   "p95_ms": 0.2953,
   "speedup_x": 2.07,
   "gpu": "NVIDIA L4/PCIe/SSE2",
   "resolution": "1920x1080",
   "baseline_p50_ms": 0.0159
  },
  "a100": {
   "weight_x": 12.33,
   "tier": "moderate",
   "p50_ms": 0.3552,
   "p95_ms": 0.3553,
   "speedup_x": 1.7,
   "gpu": "NVIDIA A100-SXM4-40GB/PCIe/SSE2",
   "resolution": "1920x1080",
   "baseline_p50_ms": 0.0288
  }
 }
}