GameNGen diffusion game engine
A diffusion model that acts as a game engine: it predicts the next frame from past frames and player actions, running interactively on one accelerator without explicit geometry, physics or game logic.
Also known as GameNGen, Diffusion Models Are Real-Time Game Engines
In the family Generative & learned 3D, neural game simulation
Where it runs
Built inOfficial add-onPluginNone foundNot researched
| Engine | Support | How |
|---|---|---|
| three.js r187 | None found | |
| Babylon.js 9.38.0 | None found | |
| Godot 4.7 | None found | |
| Unity | None found | |
| Unreal 5.7 | None found | Research model; no engine feature. |
| Blender 5.2 | None found | Research model; no Blender feature. |
| WebGPU W3C | None found | |
| Metal | None found |
How it works
Training happens in two phases. First, an RL agent plays the target game (Doom in the paper) while frames, actions and the game state are recorded as a large dataset. Second, a pretrained text-to-image latent diffusion model is fine-tuned to generate the next frame conditioned on a window of previous frames and actions; action tokens replace the text conditioning, and previous frames enter as latent channels concatenated to the noisy latent. To stop autoregressive drift over long play, the training adds noise augmentation to the context frames with the noise level provided to the model, so it learns to correct accumulated errors. At inference only a few denoising steps are used, and the decoder is fine-tuned to improve small details such as the heads-up display. The result plays like the original at interactive rates but has no persistent world state beyond its context window.
When to choose it
Reach for it when
- can a neural network replace the game engine rendering loop
- want a playable neural simulation from recorded gameplay
- predict next frame from player actions with diffusion
- need real time interactive video generation
- generated game world forgets what was behind me
Study it when exploring neural simulators and world models as an alternative to a hand-built renderer, for games that already have lots of recorded play. Prefer Genie 2 and Genie 3 (interactive world models) for learned, action-controllable environments from unlabelled video, Marble (World Labs multimodal world model) for persistent 3D generation, and a conventional engine plus Neural Radiance Caching-style learned shading when determinism and editing matter.
Field marks
- Loss of long-term consistency: items, enemy positions and map layout drift beyond the context window
- Accumulating autoregressive error causes colour drift, blur or hallucination over long sessions
- No exact game rules: health, ammo and physics are approximated visually
- Training needs a large, action-labelled gameplay dataset per game
- Latency and hardware requirements far above the original engine
Presets
GameNGen — DDIM denoising latent frame (left) vs synthesized playable corridor engine (right)
{
"P_NOISE_LVL": 0.45,
"P_WALK_SPEED": 1,
"P_NEON_GAIN": 1.15,
"P_SPLIT": 0.46
}Show GLSL (133 lines)
const float P_NOISE_LVL = 0.45; // P Diffusion Noise [0.05, 0.95, 0.02]
const float P_WALK_SPEED = 1.0; // P Corridor Speed [0.0, 2.5, 0.05]
const float P_NEON_GAIN = 1.15; // P Corridor Glow [0.3, 2.0, 0.05]
const float P_SPLIT = 0.46; // P Latent / Frame Split [0.0, 1.0, 0.02]
float hash21(vec2 p) {
p = fract(p * vec2(127.1, 311.7));
p += dot(p, p + 34.5);
return fract(p.x * p.y);
}
// First-person sci-fi/retro FPS corridor SDF for neural game engine synthesis
vec2 mapCorridor(vec3 p) {
float floorD = p.y + 0.88;
float ceilD = 0.92 - p.y;
float wallD = 1.22 - abs(p.x);
// Repeating structural ribs along Z
float rz = mod(p.z + 1.0, 2.0) - 1.0;
float ribX = 1.02 - abs(p.x);
float ribZ = abs(rz) - 0.14;
float rib = max(ribX, ribZ);
float d = min(min(floorD, ceilD), min(wallD, rib));
float mat = 1.0;
if (abs(d - floorD) < 0.002) mat = 2.0;
else if (abs(d - rib) < 0.002) mat = 3.0;
else if (abs(d - ceilD) < 0.002) mat = 4.0;
return vec2(d, mat);
}
vec3 calcNormal(vec3 p) {
vec2 e = vec2(0.003, 0.0);
return normalize(vec3(
mapCorridor(p + e.xyy).x - mapCorridor(p - e.xyy).x,
mapCorridor(p + e.yxy).x - mapCorridor(p - e.yxy).x,
mapCorridor(p + e.yyx).x - mapCorridor(p - e.yyx).x
));
}
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 screenY = fragCoord.y / max(iResolution.y, 1.0);
float split = clamp(P_SPLIT, 0.0, 1.0);
float noiseLvl = clamp(P_NOISE_LVL, 0.05, 0.95);
float speed = max(P_WALK_SPEED, 0.0);
float neon = clamp(P_NEON_GAIN, 0.2, 2.2);
// Subtle head-bob walking motion
float bob = sin(iTime * 5.2 * speed) * 0.03;
vec3 ro = vec3(sin(iTime * 0.65 * speed) * 0.18, bob, -iTime * 2.1 * speed);
vec3 rd = normalize(vec3(uv.x, uv.y, -1.25));
vec3 col = vec3(0.04, 0.03, 0.05);
float t = 0.05;
vec2 hit = vec2(1e5, 0.0);
for (int i = 0; i < 52; i++) {
vec2 h = mapCorridor(ro + rd * t);
if (h.x < 0.004) { hit = vec2(t, h.y); break; }
t += h.x;
if (t > 14.0) break;
}
if (hit.x < 1e4) {
vec3 p = ro + rd * hit.x;
vec3 n = calcNormal(p);
// Periodic ceiling/wall corridor lights
float lz = floor((p.z + 1.0) / 2.0) * 2.0;
vec3 lPos = vec3(0.0, 0.72, lz);
vec3 toL = lPos - p;
float dL = length(toL);
vec3 lDir = toL / max(dL, 1e-4);
float atten = 1.0 / (1.0 + 0.38 * dL * dL);
float diff = max(dot(n, lDir), 0.0);
vec3 alb = vec3(0.32, 0.30, 0.28);
if (hit.y > 1.5 && hit.y < 2.5) {
// Industrial tiled metal floor
vec2 tile = step(0.06, fract(p.xz * 1.5));
alb = mix(vec3(0.16, 0.18, 0.22), vec3(0.34, 0.36, 0.40), tile.x * tile.y);
} else if (hit.y > 2.5 && hit.y < 3.5) {
alb = vec3(0.46, 0.24, 0.18);
} else if (hit.y > 3.5) {
alb = vec3(0.22, 0.24, 0.28);
}
vec3 lightCol = mix(vec3(1.0, 0.62, 0.26), vec3(0.24, 0.88, 1.0), 0.5 + 0.5 * sin(lz * 0.7));
col = alb * (0.14 + 1.25 * diff * atten * lightCol);
// Emissive wall strip + ceiling strip
float strip = exp(-abs(p.y + 0.10) * 24.0) * step(0.85, abs(n.x));
float ceilGlow = exp(-abs(p.x) * 6.0) * step(0.85, -n.y) * smoothstep(0.35, 0.10, abs(mod(p.z + 1.0, 2.0) - 1.0));
col += lightCol * (strip * 0.85 + ceilGlow * 1.45) * neon;
// Distance atmospheric haze
float fog = 1.0 - exp(-hit.x * 0.16);
col = mix(col, vec3(0.08, 0.05, 0.09), fog);
}
// Retro FPS HUD bar along bottom + center crosshair
if (screenY < 0.14) {
float bar = smoothstep(0.14, 0.132, screenY);
vec3 hud = vec3(0.12, 0.13, 0.16);
float hp = step(abs(screenX - 0.25), 0.10) * step(abs(screenY - 0.07), 0.025);
float ammo = step(abs(screenX - 0.75), 0.10) * step(abs(screenY - 0.07), 0.025);
hud = mix(hud, vec3(0.95, 0.24, 0.18), hp);
hud = mix(hud, vec3(0.96, 0.78, 0.22), ammo);
col = mix(col, hud, bar * 0.92);
}
float crossH = smoothstep(0.005, 0.001, abs(uv.y)) * smoothstep(0.032, 0.024, abs(uv.x));
float crossV = smoothstep(0.005, 0.001, abs(uv.x)) * smoothstep(0.032, 0.024, abs(uv.y));
col = mix(col, vec3(0.95, 0.98, 0.85), max(crossH, crossV) * 0.75);
// Left side: Intermediate DDIM diffusion denoising step (noisy latent patches + denoising scan)
if (screenX < split) {
vec2 patchCell = floor(fragCoord / 6.0);
float n1 = hash21(patchCell + floor(iTime * 12.0) * 0.31);
float n2 = hash21(patchCell * 1.37 + floor(iTime * 12.0) * 0.19);
float n3 = hash21(patchCell * 1.91 + floor(iTime * 12.0) * 0.43);
vec3 epsNoise = vec3(n1, n2, n3) - 0.5;
float alphaBar = 1.0 - noiseLvl * 0.72;
col = sqrt(alphaBar) * col + sqrt(1.0 - alphaBar) * (0.45 + epsNoise * 0.95);
}
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.
Measured GPU weight & timing
| Preset | GPU | Weight / p50 / p95 | Method |
|---|---|---|---|
| gamengen-live | Tesla T4 1920x1080 | 13.1× baseline (moderate) · 0.430 ms / 0.447 ms | opengl-timer-query · 32 frames · GPU Weight Atlas · Colab T4 sweep |
| gamengen-live | NVIDIA L4 1920x1080 | 11.8× baseline (moderate) · 0.187 ms / 0.190 ms · 2.3× faster on L4 | opengl-timer-query · Cross-architecture validation |
| gamengen-live | NVIDIA A100-SXM4-40GB 1920x1080 | 8.30× baseline (moderate) · 0.239 ms / 0.243 ms · 1.8× faster on A100 | opengl-timer-query · Cross-architecture validation |
Lineage
From the citation graph (Crossref reference lists): its primary source cites 3D Gaussian Splatting.
Crosses
- Genie 2 and Genie 3 (interactive world models): Latent-action models can supply control labels that a GameNGen-style next-frame diffusion model would otherwise need from game logs.
Sources
- primaryDani Valevski, Yaniv Leviathan, Moab Arar, Shlomi Fruchter (2024). Diffusion Models Are Real-Time Game Engines. arXiv preprint (cs.LG).Verified via arxiv · 2026-11-29arXiv:2408.14837
- tutorialValevski, Leviathan, Arar, Fruchter. Diffusion Models Are Real-Time Game Engines (project page). gamengen.github.io.Verified via live page · 2026-11-29