{
 "id": "reaction-diffusion-textures",
 "title": "Reaction-Diffusion Textures (Turk)",
 "aliases": [
  "Gray-Scott",
  "Turing patterns",
  "reaction-diffusion"
 ],
 "domain": "procgen",
 "subdomain": "pattern synthesis",
 "stage": "procedural",
 "realtime": "interactive",
 "platforms": [
  "webgl2",
  "webgpu",
  "desktop-gpu",
  "cpu",
  "python",
  "houdini",
  "blender"
 ],
 "year_introduced": 1991,
 "inputs": [
  "mesh",
  "texture"
 ],
 "outputs": [
  "texture",
  "uv-atlas"
 ],
 "style": "both",
 "dynamic": "dynamic",
 "summary": "Simulate two interacting chemicals that diffuse at different rates to produce spots, stripes, labyrinths and other organic patterns, either in texture space or directly over a mesh surface.",
 "how_it_works": "Two scalar fields A and B evolve by dA/dt = Da*laplacian(A) - A*B^2 + f(1-A) and dB/dt = Db*laplacian(B) + A*B^2 - (k+f)B (Gray-Scott), where diffusion rates differ and feed f and kill k select the pattern regime: spots, worms, mazes, solitons. Turk's contribution is running the simulation on arbitrary surfaces: generate a uniform point mesh over the surface, compute Laplacians in that mesh, and render the chemical concentration as a texture, so patterns follow the geometry without UV distortion. Alternatively, the simulation runs on a 2D grid in texture space, as ping-pong render targets in a fragment shader. Anisotropic diffusion or spatially varying f and k create stripes oriented along a direction field or patterns that change across a surface.",
 "when_to_use": "Choose it for animal-coat patterns, corals, organic bump or colour maps and growth effects that should feel emergent. Prefer `domain-warping` for cheaper swirled textures without simulation, `perlin-noise` family for stateless patterns, and `wang-tiles` when you need tileable texture synthesis from a source.",
 "cost": {
  "class": "medium",
  "notes": "A few texture passes per simulation step; thousands of steps required for patterns to emerge, so interactive on GPU but seeded offline for bakes."
 },
 "failure_modes": [
  "Pattern depends on seed and parameters in a narrow regime: slightly off f,k values die out to a flat field or blow up",
  "Texture-space simulation shows distortion and seams on UV-mapped meshes",
  "Time step too large makes explicit Euler integration unstable (checkerboard or NaNs)",
  "Result is not tileable unless the grid wraps",
  "Mesh-based versions need uniformly sampled vertices; irregular meshes produce directional artifacts"
 ],
 "sources": [
  {
   "role": "primary",
   "key": "doi:10.1145/122718.122749",
   "type": "paper",
   "title": "Generating textures on arbitrary surfaces using reaction-diffusion",
   "authors": [
    "Greg Turk"
   ],
   "year": 1991,
   "venue": "Proceedings of the 18th annual conference on Computer graphics and interactive techniques",
   "url": "https://doi.org/10.1145/122718.122749",
   "ids": {
    "doi": "10.1145/122718.122749"
   },
   "license": null,
   "extra": {
    "csl_type": "proceedings-article"
   },
   "provenance": {
    "title": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/122718.122749",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "authors": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/122718.122749",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "year": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/122718.122749",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "venue": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/122718.122749",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "url": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/122718.122749",
     "checked_at": "2026-11-29T15:51:27.588Z"
    }
   },
   "status": "verified",
   "checked_at": "2026-11-29T15:51:27.588Z",
   "title_sim": 1,
   "__bib": "turk1991generating"
  },
  {
   "role": "tutorial",
   "key": "url:https://www.karlsims.com/rd.html",
   "type": "tutorial",
   "title": "Reaction-Diffusion Tutorial",
   "authors": [
    "Karl Sims"
   ],
   "year": null,
   "venue": "karlsims.com",
   "url": "https://www.karlsims.com/rd.html",
   "ids": {},
   "license": null,
   "extra": {
    "http_status": 200,
    "live": true,
    "archive": {
     "url": "http://web.archive.org/web/20261030072101/https://www.karlsims.com/rd.html",
     "timestamp": "20261030072101"
    },
    "page_title": "Reaction-Diffusion Tutorial",
    "host": "karlsims.com",
    "title_confirmed_by_page": true,
    "title_unconfirmed": false
   },
   "provenance": {
    "title": {
     "authority": "http",
     "endpoint": "GET https://www.karlsims.com/rd.html → 200",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "url": {
     "authority": "http",
     "endpoint": "GET https://www.karlsims.com/rd.html → 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.karlsims.com/rd.html → 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": 1,
   "__bib": "simsreaction"
  }
 ],
 "presets": [
  {
   "id": "reaction-diffusion-textures-specimen",
   "title": "Toy Turing-pattern look (plane-wave approximation, not a simulation)",
   "runtime": "glsl-fragment",
   "params": {
    "WAVES": 6,
    "WAVELENGTH": 0.07,
    "BLEND": 0.6
   },
   "code": "// Toy: Turing-style spots/stripes/labyrinth via superposed plane waves at one wavelength (the linear-regime look of reaction-diffusion), not a simulation.\nconst int WAVES = 6;\nconst float WAVELENGTH = 0.07;\nconst float BLEND = 0.6;   // 0 = spots-like, 1 = labyrinth-like threshold shift\nfloat h(float n) { return fract(sin(n * 91.345) * 43758.5453); }\nvoid mainImage(out vec4 fragColor, in vec2 fragCoord) {\n    vec2 uv = fragCoord / iResolution.xy;\n    vec2 p = uv + 0.03 * vec2(sin(uv.y * 9.0 + iTime * 0.2), cos(uv.x * 8.0));\n    float s = 0.0;\n    for (int i = 0; i < WAVES; i++) {\n        float a = 3.14159 * (float(i) + 0.3 * h(float(i))) / float(WAVES);\n        vec2 k = vec2(cos(a), sin(a)) * 6.2831 / WAVELENGTH;\n        s += cos(dot(k, p) + 6.2831 * h(float(i) + 3.0));\n    }\n    s /= float(WAVES) * 0.5;\n    // regime sweep: top of the image has spots (offset threshold), bottom has stripes/labyrinth\n    float thr = mix(0.9, 0.0, smoothstep(0.1, 0.9, uv.y) * BLEND + (1.0 - BLEND) * 0.0 + 0.4 * smoothstep(0.1, 0.9, uv.y));\n    float u = smoothstep(thr - 0.12, thr + 0.12, s);\n    vec3 col = mix(vec3(0.95, 0.9, 0.75), vec3(0.12, 0.1, 0.3), u);\n    col = mix(col, vec3(0.8, 0.3, 0.2), smoothstep(0.15, 0.0, abs(s - thr)) * 0.5);\n    fragColor = vec4(pow(col, vec3(0.8)), 1.0);\n}\n",
   "basis": "original",
   "license_note": "written for this index",
   "execution_fidelity": "conceptual-diagram",
   "proof": {
    "kind": "rendered",
    "label": "rendered 2026-11-29",
    "ok": true,
    "proof": {
     "ok": true,
     "technique": "reaction-diffusion-textures",
     "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.7264,
      "std": 0.3067,
      "unique_colors": 62
     },
     "image": "/specimens/reaction-diffusion-textures-specimen.webp",
     "reason": null
    }
   }
  }
 ],
 "related": [
  "domain-warping",
  "perlin-noise",
  "wang-tiles"
 ],
 "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/reaction-diffusion-textures.json"
 },
 "solves": [
  "want organic bump or colour maps like animal skin",
  "need coral, spots and labyrinth textures on a mesh",
  "emergent growth patterns rather than noise",
  "pattern should flow across a surface without uv seams"
 ],
 "authority": "Turk, 1991",
 "url": "https://texelatlas.vercel.app/t/reaction-diffusion-textures/",
 "execution_fidelity": "conceptual-diagram",
 "fidelity_label": "Visual Diagram",
 "benchmark_eligible": false,
 "gpu_weight": {
  "weight_x": 1.92,
  "tier": "feather",
  "p50_ms": 0.0631,
  "p95_ms": 0.065,
  "baseline_p50_ms": 0.0329,
  "gpu": "Tesla T4/PCIe/SSE2",
  "resolution": "1920x1080",
  "method": "opengl-timer-query",
  "frames": 40,
  "preset_id": "reaction-diffusion-textures-specimen",
  "execution_fidelity": "conceptual-diagram",
  "fidelity_label": "Visual Diagram",
  "benchmark_eligible": false,
  "generated_at": "2026-11-30T21:07:47Z",
  "l4": {
   "weight_x": 1.42,
   "tier": "feather",
   "p50_ms": 0.0226,
   "p95_ms": 0.0231,
   "speedup_x": 2.79,
   "gpu": "NVIDIA L4/PCIe/SSE2",
   "resolution": "1920x1080",
   "baseline_p50_ms": 0.0159
  },
  "a100": {
   "weight_x": 1.08,
   "tier": "feather",
   "p50_ms": 0.0312,
   "p95_ms": 0.0312,
   "speedup_x": 2.02,
   "gpu": "NVIDIA A100-SXM4-40GB/PCIe/SSE2",
   "resolution": "1920x1080",
   "baseline_p50_ms": 0.0288
  }
 }
}