---
id: "mesh-neural-cellular-automata"
title: "Mesh Neural Cellular Automata (MeshNCA)"
aliases: [MeshNCA]
domain: "genai"
stage: "generation"
realtime: "interactive"
platforms: [cuda, python, webgl2]
year_introduced: 2024
inputs: [mesh, ldr-image, text-prompt]
outputs: [texture]
style: "both"
dynamic: "dynamic"
cost: "heavy"
authority: "Pajouheshgar et al., 2023"
url: "https://texelatlas.vercel.app/t/mesh-neural-cellular-automata/"
sources_verified_at: "2026-11-29"
---
# Mesh Neural Cellular Automata (MeshNCA) (Pajouheshgar et al., 2023)

> Runs a tiny learned update rule on the vertices of a mesh, so a texture grows from local neighbour communication and can be evaluated in real time on any triangulation.

## Reach for it when

- grow textures directly on arbitrary 3d meshes
- texture synthesis should work on any mesh topology
- want self-organizing patterns across a surface
- avoid uv seams when painting procedural patterns

## How it works

Every vertex carries a hidden state vector. At each step it perceives neighbours through learned differential-style filters adapted to mesh connectivity (gradient and Laplacian proxies) and applies a small MLP to update its state, with stochastic update masks. The rule is trained once per target appearance (an exemplar image or text prompt via image-model losses) by unrolling steps and comparing multi-view renders against the style target. Because the rule is local and mesh-agnostic, the same trained automaton produces a texture on unseen meshes and keeps working under deformation or vertex insertion, with cheap per-step cost.

## When to use it

Choose it for dynamic, self-organising textures on meshes of any topology (including animated or edited meshes) where the pattern is a repetitive style, not a unique image. Prefer [Neural Cellular Automata for Textures](https://texelatlas.vercel.app/t/neural-cellular-automata-textures.md) for the 2D predecessor, and [SyncMVD](https://texelatlas.vercel.app/t/syncmvd.md), [Text2Tex](https://texelatlas.vercel.app/t/text2tex.md) or [Paint3D](https://texelatlas.vercel.app/t/paint3d.md) when you need one-off prompt-specific textures.

## Cost

heavy — Per-step compute is small; training per style takes minutes to hours.
Measured GPU Weight: 15.73× baseline (moderate) — 0.5175 ms median / 0.5446 ms p95 on Tesla T4/PCIe/SSE2 @ 1920x1080 (opengl-timer-query).
Ada L4 scaling: 13.07× baseline (moderate) — 0.2078 ms median (2.49× faster on L4).
Ampere A100 scaling: 10.56× baseline (moderate) — 0.3042 ms median (1.7× faster on A100).

## Failure modes

- Only suited to stationary, texture-like patterns; no semantic layouts or large-scale structure
- Resolution is tied to vertex density, so coarse meshes give coarse textures
- Training can be unstable and one rule only covers one style
- Artifacts on very irregular triangulations with extreme valence

## Dataflow

- Inputs: mesh, ldr-image, text-prompt
- Outputs: texture
- Platforms: cuda, python, webgl2

## Presets

### MeshNCA — base mesh & geodesic neighborhood (left) vs growing surface NCA pattern (right) (glsl-fragment; rendered 2026-11-30)

```json
{
  "P_GROWTH": 0.82,
  "P_CELL_FREQ": 7,
  "P_ROT_SPEED": 0.65,
  "P_SPLIT": 0.46
}
```

```glsl
const float P_GROWTH = 0.82; // P NCA Growth [0.1, 1.0, 0.02]
const float P_CELL_FREQ = 7.0; // P Pattern Freq [3.0, 12.0, 0.25]
const float P_ROT_SPEED = 0.65; // P Orbit Speed [0.0, 2.2, 0.05]
const float P_SPLIT = 0.46; // P Base Mesh / MeshNCA [0.0, 1.0, 0.02]

mat2 rot2(float a) { float c = cos(a), s = sin(a); return mat2(c, -s, s, c); }

// 3D sculpted organic manifold (multi-lobed torus-sphere) for MeshNCA vertex updates
float mapMesh(vec3 p, float spin) {
  vec3 q = p;
  q.xz = rot2(spin * 0.48) * q.xz;
  q.yz = rot2(0.32) * q.yz;
  float dSph = length(q) - 0.66;
  vec2 qt = vec2(length(q.xz) - 0.56, q.y);
  float dTor = length(qt) - 0.24;
  // Smooth blend between core orb and equatorial ring
  float h = clamp(0.5 + 0.5 * (dTor - dSph) / 0.22, 0.0, 1.0);
  float d = mix(dTor, dSph, h) - 0.22 * h * (1.0 - h);
  d += 0.03 * sin(q.x * 7.0) * cos(q.y * 7.0) * sin(q.z * 7.0);
  return d * 0.82;
}

vec3 calcNormal(vec3 p, float spin) {
  vec2 e = vec2(0.0025, 0.0);
  return normalize(vec3(
    mapMesh(p + e.xyy, spin) - mapMesh(p - e.xyy, spin),
    mapMesh(p + e.yxy, spin) - mapMesh(p - e.yxy, spin),
    mapMesh(p + e.yyx, spin) - mapMesh(p - e.yyx, spin)
  ));
}

// Evaluate intrinsic 3D manifold NCA pattern using tangent-plane geodesic frequencies
vec3 evalMeshNCA(vec3 objP, float t, float freq, float growth) {
  vec3 q = objP * freq;
  for (int i = 0; i < 3; i++) {
    vec3 w = sin(q.yzx * 1.35 + vec3(0.0, 1.7, 3.1) + t * 0.28);
    q += w * 0.42;
  }
  float g1 = sin(q.x + cos(q.y * 1.2 + q.z));
  float g2 = cos(q.y - sin(q.z * 1.15 - q.x));
  float spot = smoothstep(-0.25, 0.65, g1 * g2);
  float vein = exp(-abs(g1 + g2 * 0.55) * 4.5);

  // Geodesic growth front spreading from north pole seed
  float geoDist = length(objP - vec3(0.0, 0.68, 0.0));
  float mask = smoothstep(growth * 1.85 + 0.12, growth * 1.85 - 0.14, geoDist);
  float front = exp(-abs(geoDist - growth * 1.85) * 18.0);

  vec3 base = vec3(0.06, 0.13, 0.22);
  vec3 teal = vec3(0.10, 0.72, 0.68);
  vec3 gold = vec3(0.98, 0.68, 0.20);
  vec3 pat = mix(base, teal, spot);
  pat = mix(pat, gold, vein * 0.88);
  pat += vec3(0.35, 0.98, 0.90) * front * 0.55;
  return mix(vec3(0.32, 0.35, 0.40), pat, mask);
}

vec3 aces(vec3 x) {
  x = max(x, 0.0);
  return (x * (2.51 * x + 0.03)) / (x * (2.43 * x + 0.59) + 0.14);
}

void mainImage(out vec4 fragColor, in vec2 fragCoord) {
  vec2 uv = (fragCoord - 0.5 * iResolution.xy) / iResolution.y;
  float screenX = fragCoord.x / max(iResolution.x, 1.0);
  float split = clamp(P_SPLIT, 0.0, 1.0);
  float spin = iTime * max(P_ROT_SPEED, 0.0);
  float freq = clamp(P_CELL_FREQ, 2.5, 14.0);
  float growth = clamp(P_GROWTH, 0.08, 1.0);

  vec3 ro = vec3(0.0, 0.12, 2.35);
  vec3 rd = normalize(vec3(uv, -1.55));

  vec3 col = mix(vec3(0.025, 0.034, 0.056), vec3(0.065, 0.088, 0.135), smoothstep(-0.55, 0.55, uv.y));

  float t = 0.0;
  bool hit = false;
  for (int i = 0; i < 56; i++) {
    float d = mapMesh(ro + rd * t, spin);
    if (d < 0.0025) { hit = true; break; }
    t += d;
    if (t > 5.0) break;
  }

  if (hit) {
    vec3 p = ro + rd * t;
    vec3 n = calcNormal(p, spin);
    vec3 objP = p;
    objP.xz = rot2(spin * 0.48) * objP.xz;
    objP.yz = rot2(0.32) * objP.yz;

    vec3 l1 = normalize(vec3(0.62, 0.78, 0.55));
    vec3 l2 = normalize(vec3(-0.72, -0.25, 0.45));
    float diff1 = max(dot(n, l1), 0.0);
    float diff2 = max(dot(n, l2), 0.0);
    float fres = pow(1.0 - max(dot(n, -rd), 0.0), 3.0);
    float spec = pow(max(dot(n, normalize(l1 - rd)), 0.0), 36.0);

    // Intrinsic triangulated mesh wireframe via spherical coordinates
    vec3 dn = normalize(objP + vec3(1e-5));
    vec2 sp = vec2(atan(dn.z, dn.x) / 3.14159265, asin(clamp(dn.y, -0.999, 0.999)) / 1.5707963);
    vec2 g = sp * vec2(22.0, 12.0);
    vec2 f = fract(g);
    float diag = abs(f.x - f.y);
    float edge = min(min(f.x, 1.0 - f.x), min(min(f.y, 1.0 - f.y), diag * 0.707));
    float wire = smoothstep(0.055, 0.015, edge);

    if (screenX < split) {
      // Left: Base mesh topology + 1-ring geodesic neighborhood stencil highlight
      vec3 clay = vec3(0.34, 0.39, 0.46) * (0.28 + 0.75 * diff1 + 0.25 * diff2);
      clay = mix(clay, vec3(0.16, 0.68, 0.88), wire * 0.55);
      float seedRing = exp(-abs(length(objP - vec3(0.0, 0.68, 0.0)) - 0.22) * 32.0);
      clay += vec3(0.98, 0.65, 0.18) * seedRing * 1.1;
      clay += vec3(0.24, 0.52, 0.76) * fres * 0.4;
      col = clay;
    } else {
      // Right: MeshNCA surface state with tactile specular sheen
      vec3 ncaAlbedo = evalMeshNCA(objP, iTime, freq, growth);
      col = ncaAlbedo * (0.30 + 0.82 * diff1 + 0.28 * diff2)
          + vec3(0.92, 0.97, 1.0) * spec * 0.42
          + vec3(0.22, 0.84, 0.86) * fres * 0.45;
      col = mix(col, vec3(0.06, 0.12, 0.18), wire * 0.16);
    }
  }

  float sep = smoothstep(0.0035, 0.0008, abs(screenX - split));
  col = mix(col, vec3(0.95, 0.97, 1.0), sep);

  fragColor = vec4(pow(clamp(aces(col), 0.0, 1.0), vec3(1.0 / 2.2)), 1.0);
}
```

Attribution: MIT — written for this index.

## Sources

1. [primary] Ehsan Pajouheshgar, Yitao Xu, Alexander Mordvintsev, Eyvind Niklasson, Tong Zhang, Sabine Süsstrunk (2023) Mesh Neural Cellular Automata. ACM Transactions on Graphics (TOG), Volume 43, Issue 4 Article No.: 122, Pages 1 - 16; 19 July 2024. https://arxiv.org/abs/2311.02820 (verified via arxiv on 2026-11-29)
2. [primary] Ehsan Pajouheshgar, Yitao Xu, Alexander Mordvintsev, Eyvind Niklasson, Tong Zhang, Sabine Süsstrunk (2024) Mesh Neural Cellular Automata. ACM Transactions on Graphics. https://doi.org/10.1145/3658127 (verified via crossref on 2026-11-29)
3. [implementation] IVRL (2024) IVRL/MeshNCA. https://github.com/IVRL/MeshNCA (verified via github on 2026-11-29)

## Cite this entry

Texel. "Mesh Neural Cellular Automata (MeshNCA)." https://texelatlas.vercel.app/t/mesh-neural-cellular-automata/ (accessed 2026-12-01).
