{
 "id": "neural-cellular-automata-textures",
 "title": "Neural Cellular Automata for Textures",
 "aliases": [
  "Self-organising textures",
  "NCA textures"
 ],
 "domain": "genai",
 "subdomain": "learned local-rule texture synthesis",
 "stage": "generation",
 "realtime": "realtime",
 "platforms": [
  "webgl2",
  "python"
 ],
 "year_introduced": 2021,
 "inputs": [
  "ldr-image"
 ],
 "outputs": [
  "texture"
 ],
 "style": "both",
 "dynamic": "dynamic",
 "summary": "A pixel-grid automaton whose update rule is a tiny CNN, trained so the grid self-organises into a target texture; it runs in real time on a GPU shader and heals when damaged.",
 "how_it_works": "Each pixel is a cell with a small state vector. The update step is: apply fixed filters (identity, Sobel gradients, Laplacian) to build a perception vector, pass it through a small MLP to produce an increment, and add it to the cell state with a random fire rate so updates stay asynchronous. The rule is trained by unrolling many steps and minimising a style loss (Gram matrices of pretrained-network features) against an exemplar, so the pattern is not copied but has the same statistics. Since the rule is local and tiny, it can be turned into a fragment shader, runs on any resolution, and the pattern regrows after you erase part of it.",
 "when_to_use": "Choose it for animated, procedural-looking tiling textures with a small weights budget and interactive behaviour. Prefer `mesh-neural-cellular-automata` to run on mesh vertices, and a classic noise or `syncmvd`-style generation when you need a single prompt-specific texture rather than a reusable rule.",
 "cost": {
  "class": "cheap",
  "notes": "Rule is a few thousand weights; qualitative GPU cost is low per step."
 },
 "failure_modes": [
  "Struggles with long-range structure and semantic layouts",
  "Training per texture and sensitivity to hyperparameters",
  "Patterns can drift or diverge when stepped far beyond the trained horizon",
  "Style loss gives statistically similar rather than pixel-exact results"
 ],
 "sources": [
  {
   "role": "primary",
   "key": "arxiv:2105.07299",
   "type": "paper",
   "title": "Texture Generation with Neural Cellular Automata",
   "authors": [
    "Alexander Mordvintsev",
    "Eyvind Niklasson",
    "Ettore Randazzo"
   ],
   "year": 2021,
   "venue": "arXiv preprint (cs.AI)",
   "url": "https://arxiv.org/abs/2105.07299",
   "ids": {
    "arxiv": "2105.07299"
   },
   "license": null,
   "extra": {
    "arxiv_version": "1",
    "category": "cs.AI"
   },
   "provenance": {
    "title": {
     "authority": "arxiv",
     "endpoint": "https://export.arxiv.org/api/query?id_list=2105.07299",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "authors": {
     "authority": "arxiv",
     "endpoint": "https://export.arxiv.org/api/query?id_list=2105.07299",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "year": {
     "authority": "arxiv",
     "endpoint": "https://export.arxiv.org/api/query?id_list=2105.07299",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "venue": {
     "authority": "arxiv",
     "endpoint": "https://export.arxiv.org/api/query?id_list=2105.07299",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "url": {
     "authority": "arxiv",
     "endpoint": "https://export.arxiv.org/api/query?id_list=2105.07299",
     "checked_at": "2026-11-29T15:51:27.588Z"
    }
   },
   "status": "verified",
   "checked_at": "2026-11-29T15:51:27.588Z",
   "title_sim": 1,
   "__bib": "mordvintsev2021texture"
  },
  {
   "role": "implementation",
   "key": "gh:google-research/self-organising-systems",
   "type": "code",
   "title": "google-research/self-organising-systems",
   "description": "",
   "authors": [
    "google-research"
   ],
   "year": 2020,
   "venue": "GitHub",
   "url": "https://github.com/google-research/self-organising-systems",
   "ids": {
    "repo": "google-research/self-organising-systems"
   },
   "license": "Apache-2.0",
   "extra": {
    "stars": 479,
    "stars_checked": "2026-11-29",
    "archived": false,
    "fork": false,
    "pushed_at": "2026-01-09T22:24:38Z",
    "language": "Jupyter Notebook",
    "homepage": null,
    "license_name": "Apache License 2.0"
   },
   "provenance": {
    "title": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/google-research/self-organising-systems",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "authors": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/google-research/self-organising-systems",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "year": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/google-research/self-organising-systems",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "venue": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/google-research/self-organising-systems",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "url": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/google-research/self-organising-systems",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "license": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/google-research/self-organising-systems",
     "checked_at": "2026-11-29T15:51:27.588Z"
    }
   },
   "status": "verified",
   "checked_at": "2026-11-29T15:51:27.588Z",
   "title_sim": null,
   "__bib": "googleresearch2020google"
  }
 ],
 "presets": [
  {
   "id": "neural-cellular-automata-textures-live",
   "title": "Neural Cellular Automata — noisy perception seed (left) vs self-organized living texture (right)",
   "runtime": "glsl-fragment",
   "params": {
    "P_GROWTH_T": 0.78,
    "P_KERNEL_FREQ": 6.5,
    "P_MORPH_MIX": 0.55,
    "P_SPLIT": 0.44
   },
   "basis": "original",
   "license_note": "MIT — written for this index.",
   "code": "const float P_GROWTH_T = 0.78; // P Growth Steps [0.1, 1.0, 0.02]\nconst float P_KERNEL_FREQ = 6.5; // P Perception Scale [3.0, 12.0, 0.25]\nconst float P_MORPH_MIX = 0.55; // P Morphogen Mix [0.0, 1.0, 0.02]\nconst float P_SPLIT = 0.44; // P Seed / NCA Split [0.0, 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\nfloat vnoise(vec2 p) {\n  vec2 i = floor(p);\n  vec2 f = fract(p);\n  vec2 u = f * f * (3.0 - 2.0 * f);\n  return mix(\n    mix(hash21(i), hash21(i + vec2(1.0, 0.0)), u.x),\n    mix(hash21(i + vec2(0.0, 1.0)), hash21(i + vec2(1.0, 1.0)), u.x),\n    u.y\n  );\n}\n\n// Multi-channel latent state s(x) perturbed by learned Sobel + Laplacian perception updates\nvec4 evalNCAState(vec2 p, float t, float freq, float morph) {\n  vec2 q = p * freq;\n  // Iterative local-neighborhood perception (approximates 4 CNN update steps via curl & Laplacian feedback)\n  for (int i = 0; i < 4; i++) {\n    float fi = float(i) + 1.0;\n    float e = 0.14 / fi;\n    float c0 = vnoise(q + vec2(t * 0.12, -t * 0.09));\n    float cx = vnoise(q + vec2(e, 0.0) + vec2(t * 0.12, -t * 0.09)) - vnoise(q - vec2(e, 0.0) + vec2(t * 0.12, -t * 0.09));\n    float cy = vnoise(q + vec2(0.0, e) + vec2(t * 0.12, -t * 0.09)) - vnoise(q - vec2(0.0, e) + vec2(t * 0.12, -t * 0.09));\n    float lap = vnoise(q + vec2(e, 0.0)) + vnoise(q - vec2(e, 0.0)) + vnoise(q + vec2(0.0, e)) + vnoise(q - vec2(0.0, e)) - 4.0 * c0;\n    // Anisotropic Sobel curl + reaction-diffusion update\n    vec2 grad = vec2(cx, cy) * (1.8 + morph * 1.4);\n    q += vec2(-grad.y, grad.x) * 0.38 + vec2(lap * 0.45, -lap * 0.35);\n  }\n  float ridgeA = sin(q.x * 2.4 + cos(q.y * 2.1 + t * 0.45));\n  float ridgeB = cos(q.y * 2.7 - sin(q.x * 2.3 - t * 0.35));\n  float activator = smoothstep(-0.35, 0.65, ridgeA * 0.55 + ridgeB * 0.45);\n  float inhibitor = smoothstep(-0.2, 0.8, sin(length(q - floor(q + 0.5)) * 6.2831853));\n  float vein = exp(-abs(ridgeA + ridgeB * 0.65) * 4.2);\n  float hidden = vnoise(q * 1.6);\n  return vec4(activator, inhibitor, vein, hidden);\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 screenX = fragCoord.x / max(iResolution.x, 1.0);\n  float split = clamp(P_SPLIT, 0.0, 1.0);\n  float growth = clamp(P_GROWTH_T, 0.05, 1.0);\n  float freq = clamp(P_KERNEL_FREQ, 2.5, 14.0);\n  float morph = clamp(P_MORPH_MIX, 0.0, 1.0);\n\n  // Regeneration wave pulsing outward from two living seeds\n  float rSeed1 = length(uv - vec2(-0.18, 0.08));\n  float rSeed2 = length(uv - vec2(0.24, -0.14));\n  float rMin = min(rSeed1, rSeed2);\n  float front = fract(iTime * 0.14) * 1.15 + growth * 0.65;\n  float alive = smoothstep(front + 0.14, front - 0.06, rMin);\n\n  vec4 st = evalNCAState(uv, iTime * 0.55, freq, morph);\n  // Compute surface normal from finite difference of activator channel for tactile depth\n  float eps = 0.008;\n  float hC = st.x * 0.65 + st.z * 0.45;\n  float hX = evalNCAState(uv + vec2(eps, 0.0), iTime * 0.55, freq, morph).x * 0.65;\n  float hY = evalNCAState(uv + vec2(0.0, eps), iTime * 0.55, freq, morph).x * 0.65;\n  vec3 n = normalize(vec3((hC - hX) * 14.0, (hC - hY) * 14.0, 1.0));\n\n  vec3 lDir = normalize(vec3(0.55, 0.68, 0.72));\n  float diff = max(dot(n, lDir), 0.0);\n  float spec = pow(max(dot(n, normalize(lDir + vec3(0.0, 0.0, 1.0))), 0.0), 36.0);\n\n  // Organic living coral/malachite palette driven by 4 hidden NCA channels\n  vec3 deep = vec3(0.03, 0.10, 0.14);\n  vec3 teal = vec3(0.08, 0.58, 0.54);\n  vec3 amber = vec3(0.95, 0.58, 0.16);\n  vec3 ivory = vec3(0.96, 0.91, 0.78);\n  vec3 ncaCol = mix(deep, teal, st.x);\n  ncaCol = mix(ncaCol, amber, st.z * (0.45 + 0.55 * morph));\n  ncaCol = mix(ncaCol, ivory, smoothstep(0.62, 0.95, st.z * st.y) * 0.65);\n  ncaCol = ncaCol * (0.38 + 0.78 * diff) + vec3(0.85, 0.94, 0.98) * spec * 0.35;\n\n  // Highlight active self-organization wave front\n  float waveRing = exp(-abs(rMin - front) * 28.0) * 0.45;\n  ncaCol += vec3(0.25, 0.95, 0.85) * waveRing;\n  ncaCol = mix(vec3(0.04, 0.06, 0.09) + vec3(0.05) * hash21(floor(fragCoord * 0.25)), ncaCol, clamp(alive + 0.28, 0.0, 1.0));\n\n  // Left side: raw quantized seed grid & Sobel perception kernel overlay\n  vec2 cell = floor(uv * 28.0);\n  vec2 cf = fract(uv * 28.0);\n  float seedVal = hash21(cell + floor(iTime * 0.8) * 0.07);\n  float gridLine = smoothstep(0.08, 0.02, min(cf.x, cf.y));\n  vec3 seedCol = mix(vec3(0.04, 0.06, 0.10), vec3(0.18, 0.46, 0.62), seedVal * 0.8);\n  seedCol += vec3(0.12, 0.22, 0.30) * gridLine;\n  // Visualize 3x3 Sobel perception rings around the two seeds\n  float kernelVis = exp(-abs(rMin - 0.16) * 45.0) + exp(-abs(rMin - 0.08) * 65.0) * 0.6;\n  seedCol += vec3(0.98, 0.66, 0.20) * kernelVis;\n  seedCol = mix(seedCol, ncaCol, smoothstep(0.22, 0.03, rMin) * 0.9);\n\n  vec3 col = (screenX < split) ? seedCol : ncaCol;\n  float sep = smoothstep(0.0035, 0.0008, abs(screenX - split));\n  col = mix(col, vec3(0.95, 0.97, 1.0), sep);\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": "neural-cellular-automata-textures",
     "runtime": "glsl-fragment",
     "checked_at": "2026-11-30T20:35:54.000Z",
     "renderer": "Headless EGL Tesla T4/PCIe/SSE2, OpenGL 3.30 Core, 512×512, iTime=1.5",
     "stats": {
      "mean": 0.6449,
      "std": 0.1393,
      "min": 0.1993,
      "max": 0.9126
     },
     "image": "/specimens/neural-cellular-automata-textures-live.webp",
     "reason": null
    }
   }
  }
 ],
 "related": [
  "mesh-neural-cellular-automata"
 ],
 "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/genai/neural-cellular-automata-textures.json"
 },
 "solves": [
  "generate tileable textures from a small learned model",
  "texture that grows and regenerates itself",
  "synthesize textures with tiny network and low memory",
  "animated organic patterns from local rules"
 ],
 "authority": "Mordvintsev et al., 2021",
 "url": "https://texelatlas.vercel.app/t/neural-cellular-automata-textures/",
 "execution_fidelity": "conceptual-diagram",
 "fidelity_label": "Visual Diagram",
 "benchmark_eligible": false,
 "gpu_weight": {
  "weight_x": 112.74,
  "tier": "extreme",
  "p50_ms": 3.7093,
  "p95_ms": 4.0252,
  "baseline_p50_ms": 0.0329,
  "gpu": "Tesla T4/PCIe/SSE2",
  "resolution": "1920x1080",
  "method": "opengl-timer-query",
  "frames": 32,
  "preset_id": "neural-cellular-automata-textures-live",
  "execution_fidelity": "conceptual-diagram",
  "fidelity_label": "Visual Diagram",
  "benchmark_eligible": false,
  "generated_at": "2026-11-30T21:07:47Z",
  "l4": {
   "weight_x": 103.3,
   "tier": "extreme",
   "p50_ms": 1.6425,
   "p95_ms": 1.6748,
   "speedup_x": 2.26,
   "gpu": "NVIDIA L4/PCIe/SSE2",
   "resolution": "1920x1080",
   "baseline_p50_ms": 0.0159
  },
  "a100": {
   "weight_x": 81.46,
   "tier": "extreme",
   "p50_ms": 2.346,
   "p95_ms": 2.346,
   "speedup_x": 1.58,
   "gpu": "NVIDIA A100-SXM4-40GB/PCIe/SSE2",
   "resolution": "1920x1080",
   "baseline_p50_ms": 0.0288
  }
 }
}