{
 "id": "fixed-timestep-integration",
 "title": "Fixed timestep game loop and integration",
 "aliases": [
  "fix your timestep",
  "semi-fixed timestep",
  "accumulator loop"
 ],
 "domain": "simulation",
 "subdomain": "numerical integration",
 "stage": "simulation",
 "realtime": "realtime",
 "platforms": [
  "cpu",
  "webgl2",
  "webgpu",
  "desktop-gpu",
  "unity",
  "unreal",
  "godot",
  "python"
 ],
 "year_introduced": 2004,
 "inputs": [
  "particles"
 ],
 "outputs": [
  "particles",
  "animation"
 ],
 "style": "both",
 "dynamic": "dynamic",
 "summary": "Advance physics in constant-size steps from a time accumulator, then interpolate rendered state between the last two steps so simulation stays deterministic while display frame rate varies.",
 "how_it_works": "The loop measures wall-clock time per rendered frame, clamps it to a maximum (to avoid the spiral of death where slow frames demand more steps that make the next frame slower), and adds it to an accumulator. While the accumulator holds at least one step dt, the simulation advances by exactly dt and dt is subtracted. Because every step has identical length, results do not depend on frame rate, integrators such as semi-implicit Euler, Verlet or RK4 keep their stability limits, and recorded inputs replay identically. After stepping, the leftover fraction alpha = accumulator / dt describes how far the display time is between the previous and current states. The renderer blends those two stored states with alpha, which removes the temporal stutter that a fixed step otherwise causes when it does not divide the display rate. Variants run several substeps inside each step, or drive the simulation from the audio or network clock.",
 "when_to_use": "Choose it for any physics, particle or gameplay simulation where stability, determinism or networking replay matter. Prefer plain variable-dt stepping only for purely visual effects that tolerate drift, such as small `particle-systems` updates. It underpins `verlet-integration-constraints`, `xpbd`, `sequential-impulses` and `position-based-dynamics`, whose stiffness and iteration counts are tuned for a fixed dt. Use substepping (as in `xpbd` small-step solvers) instead of a smaller global step when only the solver needs more resolution.",
 "cost": {
  "class": "cheap",
  "notes": "Overhead is negligible; total cost is steps per frame times the cost of one simulation step."
 },
 "failure_modes": [
  "Spiral of death when a step costs more than dt of real time, unless frame time is clamped",
  "Temporal aliasing and judder if the render state is not interpolated and dt does not divide the display period",
  "Interpolating between states lags rendering by up to one step, which matters for input latency in competitive games",
  "Interpolation of rotations or wrapped values needs slerp or angle handling, not component-wise lerp",
  "Floating-point accumulation in the accumulator drifts if stored as float seconds over long sessions"
 ],
 "sources": [
  {
   "role": "primary",
   "key": "url:https://gafferongames.com/post/fix_your_timestep",
   "type": "web",
   "title": "Fix Your Timestep!",
   "authors": [
    "Glenn Fiedler"
   ],
   "year": null,
   "venue": "gafferongames.com",
   "url": "https://gafferongames.com/post/fix_your_timestep",
   "ids": {},
   "license": null,
   "extra": {
    "http_status": 200,
    "live": true,
    "archive": null,
    "page_title": "Fix Your Timestep! | Gaffer On Games",
    "host": "gafferongames.com",
    "title_confirmed_by_page": true,
    "title_unconfirmed": false
   },
   "provenance": {
    "title": {
     "authority": "http",
     "endpoint": "GET https://gafferongames.com/post/fix_your_timestep → 200",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "url": {
     "authority": "http",
     "endpoint": "GET https://gafferongames.com/post/fix_your_timestep → 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://gafferongames.com/post/fix_your_timestep → 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": "fiedleryour"
  },
  {
   "role": "tutorial",
   "key": "url:https://gafferongames.com/post/integration_basics",
   "type": "tutorial",
   "title": "Integration Basics",
   "authors": [
    "Glenn Fiedler"
   ],
   "year": null,
   "venue": "gafferongames.com",
   "url": "https://gafferongames.com/post/integration_basics",
   "ids": {},
   "license": null,
   "extra": {
    "http_status": 200,
    "live": true,
    "archive": {
     "url": "http://web.archive.org/web/20261022023400/https://gafferongames.com/post/integration_basics/",
     "timestamp": "20261022023400"
    },
    "page_title": "Integration Basics | Gaffer On Games",
    "host": "gafferongames.com",
    "title_confirmed_by_page": true,
    "title_unconfirmed": false
   },
   "provenance": {
    "title": {
     "authority": "http",
     "endpoint": "GET https://gafferongames.com/post/integration_basics → 200",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "url": {
     "authority": "http",
     "endpoint": "GET https://gafferongames.com/post/integration_basics → 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://gafferongames.com/post/integration_basics → 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": "fiedlerintegration"
  }
 ],
 "presets": [
  {
   "id": "fixed-timestep-60hz",
   "title": "60 Hz physics step with frame clamp",
   "runtime": "json-params",
   "params": {
    "dt": 0.016667,
    "max_frame_time": 0.25,
    "max_steps_per_frame": 5,
    "interpolate_render_state": true
   },
   "basis": "original",
   "license_note": "written for this index",
   "execution_fidelity": "parameter-only",
   "proof": {
    "kind": "parameter",
    "label": "parameter preset",
    "ok": true,
    "proof": null
   }
  }
 ],
 "related": [
  "verlet-integration-constraints",
  "xpbd",
  "sequential-impulses",
  "position-based-dynamics",
  "quaternion-slerp-interpolation"
 ],
 "extends": [],
 "supersedes": [],
 "combines_with": [
  {
   "id": "quaternion-slerp-interpolation",
   "why": "Render-state interpolation between the last two fixed steps blends orientations with slerp rather than component-wise lerp."
  },
  {
   "id": "xpbd",
   "why": "A fixed dt makes constraint compliance and iteration counts mean the same thing every frame."
  }
 ],
 "provenance": {
  "prose": "original text written for this index (research draft, editorially reviewed)",
  "sources_verified_at": "2026-11-29T15:51:27.588Z",
  "draft": "data/drafts/simulation/fixed-timestep-integration.json"
 },
 "solves": [
  "physics behaves differently at different frame rates",
  "simulation explodes when a frame takes too long",
  "motion judders even though physics runs at fixed rate",
  "need deterministic stepping so replays match exactly"
 ],
 "authority": "Fiedler",
 "url": "https://texelatlas.vercel.app/t/fixed-timestep-integration/",
 "execution_fidelity": "parameter-only",
 "fidelity_label": "Parameter Preset",
 "benchmark_eligible": false
}