Skip to content
Skills Library
Programming · Building & coding

roguesquadron-frame-interpolation

/roguesquadron-frame-interpolation

Use when working on RT64 frame interpolation in RogueSquadron64Recomp - objects jitter, wobble, pulse, smear, flicker or snap at 60/120/144 Hz while the game runs ~30 fps; adding a new geometry path that must interpolate; touching matrixId / TransformGroup / G_EX_ID_* / ROGUESQ_F5_NODE_ID / sprite ids / regrid; or deciding whether interpolation can be enabled by default.

Licence
GPL-3.0
Last repository change
09.11.2026

Assessment and security

100/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
1
Scripts
0
HTML comments
0
URLs in SKILL.md
0
Deprecation

No signals detected. Repository changed on 09.11.2026, without references to retired models or APIs.

Licence

GPL-3.0, otwarta.

What it does and when to use it

Use when working on RT64 frame interpolation in RogueSquadron64Recomp - objects jitter, wobble, pulse, smear, flicker or snap at 60/120/144 Hz while the game runs ~30 fps; adding a new geometry path that must interpolate; touching matrixId / TransformGroup / G_EX_ID_* / ROGUESQ_F5_NODE_ID / sprite ids / regrid; or deciding whether interpolation can be enabled by default.

Original author description

Use when working on RT64 frame interpolation in RogueSquadron64Recomp - objects jitter, wobble, pulse, smear, flicker or snap at 60/120/144 Hz while the game runs ~30 fps; adding a new geometry path that must interpolate; touching matrixId / TransformGroup / G_EX_ID_* / ROGUESQ_F5_NODE_ID / sprite ids / regrid; or deciding whether interpolation can be enabled by default.

How it works

  1. Overview
  2. Enabling
  3. Pipeline (lib/rt64/src)
  4. Identity sources (lib/rt64/src/gbi/rt64gbif3dfactor5.cpp)
  5. Giving new geometry an identity
  6. Diagnosing jitter
  7. Dead ends (do not retry)
  8. Inherent costs
Original SKILL.md headings · 83 lines, 1,666 words
SKILL.md preview
---
name: roguesquadron-frame-interpolation
description: Use when working on RT64 frame interpolation in RogueSquadron64Recomp - objects jitter, wobble, pulse, smear, flicker or snap at 60/120/144 Hz while the game runs ~30 fps; adding a new geometry path that must interpolate; touching matrixId / TransformGroup / G_EX_ID_* / ROGUESQ_F5_NODE_ID / sprite ids / regrid; or deciding whether interpolation can be enabled by default.
---

# Rogue Squadron Frame Interpolation

## Overview

RT64 buffers one real game frame and draws in-between frames by pairing each transform with its previous-frame counterpart and blending prev -> cur. **Pairing quality is everything**: a correct pair looks perfect, a wrong pair smears, a missing pair snaps. Factor 5 has no separate camera: projection is pure perspective, view = identity, every modelview is camera-space. So camera motion only interpolates per object, and an unpaired object stutters against a smooth world.

## Enabling

- `roguesq_video.json`: `"frameInterpolation": true`, `"targetFramerate": 60` ([src/video/video_config.cpp:69](../../../src/video/video_config.cpp)). Code default is OFF ([src/video/rt64_render_context.cpp:210](../../../src/video/rt64_render_context.cpp)); its "effect quads flicker" rationale predates the sprite-id work and is stale.
- Env: `ROGUESQ_RT_INTERP=<hz>` (`0` = off). Deterministic repro: `ROGUESQ_BOOT_TARGET=level:N` (attract demo is too noisy) plus a recorded input replay (`ROGUESQ_INPUT_REPLAY`, files in `tools/debug/recordings/`); mute with `ROGUESQ_NO_AUDIO_UCODE=1`. **Test in the Release build**: Debug adds background work that distorts frame timing.

## Pipeline (lib/rt64/src)

| Stage | Where | Notes |
| --- | --- | --- |
| Rate | `hle/rt64_vi.cpp:193` | Majority vote over the VI factor ring (`ROGUESQ_INTERP_RATE=strict\|<hz>`) |
| Per-frame timing | `hle/rt64_workload_queue.cpp:997` | `ROGUESQ_INTERP_VARIABLE`: each real frame tweens over its own VI count |
| ID pairing | `hle/rt64_game_frame.cpp:359` | Sorted-id merge; `ROGUESQ_INTERP_ID_MAXJUMP` jump guard, default off (it rejected steady close flybys) |
| AUTO pairing | `hle/rt64_game_frame.cpp:595-692` | Hash (combiner, othermode, geomode, **triangleCount**) + greedy nearest; `f5AutoMatchTooFar` 0.2 NDC gate (`:29`) |
| Blend | `hle/rt64_rigid_body.cpp` | Decompose; lerp translation (chord), slerp rotation |
| Draw | `render/rt64_transform_processor.cpp:42-58` | Mapped: `lerp(prev,cur,w)`. **Unmapped: drawn at cur** |

## Identity sources (lib/rt64/src/gbi/rt64_gbi_f3dfactor5.cpp)

| Geometry | ID | Where |
| --- | --- | --- |
| Ships, lasers, rigid objects, menu/overlay models | `0x2xxxxxxx` = scene-node ptr + regrid generation; node recorded by the `traverseSceneGraphRecursive` hook @0x800155E4 -> `rs64_f5_map_node`, for both matrix rings (`0x700000`/`0x710000` flight, `0x770000`/`0x780000` menus/overlays; `f5_ring_buffer`). Id from a node's first frame (`ROGUESQ_F5_NODE_STABLE_ONLY=1` restores waiting a frame) | `f5_map_node_impl` ~381, stamp ~1179 |
| Tow cable segments | `0x1xxxxxxx` = generation + position from the ship end (submit order), from the `addNpcToVisibilityBucket` entry hook -> `rs64_f5_cable_submit(pool, instance, state word 0x8010B6E8)`; only drawn slots count; new generation on a gap, re-fire (phase 3/4 -> 1/2) or falling count; scene node = segment mesh instance + 0x0C; `rs64cable::CableRoles` in `hle/rt64_rs64_cable.h`. Ids by role, not slot: a head-only alias left the previous head unpaired after every advance. Covers the long-tow-cable mod | `f5_cable_submit_impl`, `f5_lookup_node_alias`, alias applied after the node-id block in op_01 |
| Terrain | Root node id; re-centers compensated (`ROGUESQ_F5_REGRID_COMP`) or generation-bumped (`REGRID_SNAP`) | `f5_node_regrid_generation` ~143, `f5_regrid_after_load` ~184 |
| Crosshair rings | `0x80000000` outer / `0x80000001` inner / `0x80000002` Y-wing bomb sight (+0x88, a 32x20 tile drawn tile-height wide). The rings are texrects (no rect interpolation in RT64); a texrect whose upper-left is a shown HUD ring element (`D_8010CA30` +0x28 / +0x58 / +0x88, xy at +0x18) plus (256, 224), size = tile x 1024/dsdx, draws as a camera-space quad with a translation-carrying transform. A ring clamped at the screen edge matches on its far edge. `ROGUESQ_F5_XHAIR_QUAD=0` keeps the texrect | `f5_crosshair_quad`, `hle/rt64_rs64_crosshair.h`, called from `texrectLLE_guarded` |
| 0xBD sprites | `0x6xxxxxxx` face id (renderLitMeshFaceGroup hooks) -> `0x4xxxxxxx` sparse node+ordinal -> `0x5xxxxxxx` world tracker -> AUTO | `f5_face_sprite_id` ~245, `f5_world_sprite_id` ~274, op_bd ~1437 |
| Camera-facing quads (explosion and lava fire, glints) | `0xAxxxxxxx` = face record + generation. The `buildOrientedFaceGeometry` hook @0x80012F14 maps each 0xB4's DL address to its face record (`s3`), whose world position at +8 drives the generation: a new one on a gap or a jump past max(160, 4x speed), a reused pool slot. A record drawn twice in a frame falls back to the position tracker | `f5_oriented_face_id`, `f5_take_mapped_face`, called in `f5_emit_face` |

Nodes get an id from their first frame (`ROGUESQ_F5_NODE_STABLE_ONLY=1` waits a frame); an op_01 without an id resets to `TransformGroup()` (AUTO) so it can't inherit the previous object's group. Taken id prefixes: `0x1` tow cable segments, `0x2` nodes, `0x3` baked faces, `0x4`/`0x5`/`0x6` sprites, `0x7` flattened PRIM faces, `0x8` crosshair rings, `0x9` terrain anchor, `0xA` camera-facing quads. The comment near op_01 ~1274 saying "AUTO alone is best" is stale.

## Giving new geometry an identity

```cpp
state->rsp->matrixId(id, /*push*/false, /*proj*/false, /*decompose*/true,
    G_EX_COMPONENT_INTERPOLATE, G_EX_COMPONENT_INTERPOLATE, G_EX_COMPONENT_INTERPOLATE,  // pos rot scale
    G_EX_COMPONENT_INTERPOLATE, G_EX_COMPONENT_INTERPOLATE,                              // skew persp
    G_EX_COMPONENT_SKIP, G_EX_COMPONENT_SKIP,                                            // vtx pos / texcoord
    G_EX_COMPONENT_AUTO, G_EX_COMPONENT_AUTO, G_EX_ORDER_LINEAR, G_EX_ASPECT_AUTO, G_EX_EDIT_NONE, false, false);
```

The id must be: **the same** for the same logical object across frames; **different** when the slot becomes a different thing (pool reuse, flipbook restart, teleport, grid re-center -> bump a generation); never `0` (IGNORE) or `0xFFFFFFFF` (AUTO); in its own top-nibble namespace. Never derive it from submit order, ring slot, DL address or a bare heap pointer. Unique within a frame. A pushed group (`push=true`, as op_bd does) must be popped after the draw. Use `G_EX_ID_IGNORE` (push) for things that must never blend. Motion must live in the **transform**, not baked into vertices (vertex interp is SKIP).

## Diagnosing jitter

| Symptom | Mechanism | Check / fix |
| --- | --- | --- |
| Object oscillates back and forth along its motion ("jitter in place") | Flips mapped <-> unmapped between frames. Mapped lags up to 1 frame, unmapped is drawn at cur (ahead). Camera-space velocity makes the gap large | Log per-transform mapped state per frame. Measure with `ROGUESQ_LOG_INTERP_PAIR=1`. Flip triggers: `ID_MAXJUMP` guard if enabled, 0.2 NDC auto gate, sprite generation bumps (gap / >4x size jump; a flipbook restart only counts if it also moved >1.5x size; a halving in size only counts off the predicted path) |
| Id-less object pops for one frame when it starts moving or reverses | AUTO position: `RigidBody::updateLinear` disables translation lerp on start-from-rest or >90 deg velocity reversal | Give it an id (INTERPOLATE bypasses the heuristic) |
| Searchlight shafts/glows on structures, explosion and lava fire jitter only while the camera moves | Game bakes their camera-space position into the verts every frame under a static matrix (`0x80037780`, never written in-mission; confirmed with `ROGUESQ_DATA_BP`); vertex interp is SKIP so they step at game rate | `ROGUESQ_F5_BAKED_VTX_INTERP` (default on): per-face id + vertex interpolation for faces under a non-ring, id-less matrix. Find such cases by checking which matrix (`s_mv_last_w1`) an id-less draw sits under. Faces are matched in camera space: the terrain-root world frame jumps and lost every glint on 13% of frames. Faces built by `buildOrientedFaceGeometry` (explosion and lava fire, glints) get `0xAxxxxxxx` ids from their face record instead (`ROGUESQ_F5_ORIENTED_FACE_ID`), so only untagged faces are position-tracked. Measure with the class-3 field of `[pair]` (mapped/total/flips) |
| Glow / light shaft on a structure flickers at 30 Hz; fine on real frames | zSource=PRIM draws use one constant depth from the current frame while the surface under them is drawn at its blended depth (`shaders/RasterVS.hlsl:34`) | `ROGUESQ_F5_SPRITE_PIXEL_Z` and `ROGUESQ_F5_PRIM_FLATTEN` (default on) give these faces per-vertex depth that follows interpolation |
| Growing fire puff pulses while its position is smooth | Sprite size baked into int16 verts, vertex interp SKIP -> size steps at game rate | Build a unit quad and put size in the transform scale (`SPRITE_XFORM` only moves the centre into the transform; size stays in verts) |
| Smear / warp between unrelated objects | Mispair: id reused across instances or AUTO matched the wrong neighbour | Add a generation; tighten id; never loosen the AUTO hash |
| Sprite ids all reset at once | `f5_face_sprite_id` clears its map at >8192 entries (~250) | Bounded-map eviction instead of clear |
| Periodic whole-terrain lurch | Grid re-center tweened | Confirm `REGRID_COMP`/`REGRID_SNAP` on (default) |
| Terrain snaps ahead and back for one frame now and then | The root's id changed: the folded shift L dropping to 0 every 16 cells (now kept, `Workload::rs64Rebase` moves the previous transform; `ROGUESQ_F5_REBASE_INTERP`), or the root losing its learned k when `s_regrid` filled up | Count flips of the root id (`2?392440` on Construction Yards) in `[pair]`: 0 expected |
| Whole-frame lurch / speed spike | Rate dropped or a stretched frame timed as 1 VI | A/B `ROGUESQ_INTERP_RATE=strict` / `ROGUESQ_INTERP_VARIABLE=0` |
| Uneven motion that survives correct pairing | Game-side unevenness (e.g. camera and objects updated on different cadences) or late real frames | Not an interp bug; interpolation shows it faithfully |

**Measuring coverage:** replay a recording (`tools/debug/recordings/`, Release) with `ROGUESQ_LOG_INTERP_PAIR=1` and aggregate `[pair]` per class. `[autodraw]` counts draws made with no id per draw site (tile_quad, tile_grid, sprite, face; every mesh face goes through `f5_emit_face`), and is the real coverage number. AUTO transforms left in `[pair]` are `op_04` vertex-cache loads that are never drawn directly (faces copy them into their own group), so they don't matter. Unpaired id'd transforms are first-frame spawns, which can't pair. Remaining gaps show up as trackers issuing fresh ids; `[facesprite]` and `[baked-miss]` say why.

**First step for jitter:** toggle one path at a time on the same scene (`ROGUESQ_F5_SPRITE_FACE_ID=0`, `ROGUESQ_F5_SPRITE_WORLD_MATCH=0`, `ROGUESQ_INTERP_ID_MAXJUMP=0`, `ROGUESQ_INTERP_AUTO_MAX_SCREEN=0`). `ROGUESQ_F5_SPRITE_XFORM=0` is not a single-path toggle: it also re-enables the dense-sprite no-id path and isolates id-less sprites. `ROGUESQ_LOG_INTERP_PAIR=1` logs per-class paired/total, flips and in-frame duplicate ids (`[pair]`), jump rejects, and face-sprite id outcomes; aggregate it over gameplay frames with awk. Judge fixes by eye on a live A/B (`mcp__windows-screenshot__capture_burst`, title "Rogue Squadron 64 Recompiled"). A higher match rate that visibly warps is a failure.

## Dead ends (do not retry)

- Submit-order / ring-slot ids, address-derived ids, persistent entity-pointer maps: mispair on spawn/despawn.
- Dropping triangleCount from the AUTO hash: wider mispairs, smear.
- Vertex interpolation for terrain: tile vertex sets change per frame, flicker.
- Terrain ids by quantized world cell: no better than the regrid handling, and its `0x6` prefix collided with face-sprite ids.
- Classifying ship vs particle by node fields (owner8, unique drawable): drops formation ships.
- Hardcoding heap address pool ranges: level-fragile.

## Inherent costs

~1 real frame (~33 ms) extra latency; mispairs smear rather than pop; vertex-baked motion and late real frames stay at game rate.

Env var catalog: [docs/engine/debug-trace-env-vars.md](../../../docs/engine/debug-trace-env-vars.md).

Versions

The database has no other skills named roguesquadron-frame-interpolation.

Database snapshot: 13.11.2026 · package version 3ef4277f3d95 (SHA-256 digest of the entire package)

Downloads in the last 30 days: 0 · ranking

: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 100using-metalfx-frame-interpolation
    ALWAYS use to add MetalFX frame interpolation with a dedicated PresentThread for precise dual-frame presentation to a Metal app. Use this skill when the user wants to add frame interpolation, frame generation, double the framerate, or mentions MTLFXFrameInterpolator (Metal 3) or…
  • 100metalfx-game-rendering-workflow
    Guide native Apple-game MetalFX integration for spatial or temporal upscaling, frame interpolation, and temporal denoising. Use when Codex works with MetalFX descriptors, jitter, motion vectors, depth, exposure, history, dynamic resolution, present threads, or MetalFX…
  • 100physics-core
    Use to diagnose general fixed-step physics, collision timing, interpolation, determinism and jitter; not engine-specific joints.
  • 90Game Developer
    Use for game development - game loop and frame timing, fixed timestep and interpolation, entity component systems and data-oriented design, physics and broadphase collision, AI and behavior state machines, rendering and asset pipelines, input handling, animation, audio, object…
  • 85roguesquadron-debug
    Debug and iterate on RogueSquadron64Recomp (the Star Wars Rogue Squadron N64 static-recompilation port; N64Recomp + N64ModernRuntime + RT64, Windows/MSVC-clang) using evidence, not screenshots. Use for ANY crash/hang/freeze/AV triage, for landing a durable game-logic override,…
  • 87roguesquadron-raytracing
    Ray-traced lighting in RogueSquadron64Recomp (RT64's RS64 light pass on top of the game's prelit N64 image). Use for ANY work on RT lights, light presets (roguesq_lights.json, src/video/default_lights.json, the F1 Lights tab), mesh / sprite / level / lamp presets, explosion and…

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.