Add MVFG, a motion-vector frame generator for any GPU #98

Manually merged
github merged 1 commit from github-bot/gh-98 into main 2026-12-05 19:01:24 +00:00 AGit
Owner

@⁠Omnicrash on GitHub · 2026-12-05 18:22 UTC · original
Omnicrash:mvfg-pr → main · +1144 −17 · 13 files · 1 commits · merged 2026-12-05 19:00 UTC

This adds MVFG, a motion-vector frame generator, as a third option next to DLSS FG and FSR FG. It runs on any GPU up to 4x.

The interesting part isn't the generator itself, it's the cleanup. A naive motion-vector FG looks pretty rough in this game, so most of the effort went into hunting down artifacts one by one.

Artifacts it fixes

We originally wrote this for the PS5 version and tuned it there with a small simulator: it rebuilds a real frame from its neighbors and scores the result against the actual frame. Every fix below was checked against that score and in-game.

  • Shadows sliding with the road. The game's shadows and AO don't follow the motion vectors. A car's shadow stays under the car while the vectors move the road, so plain warping smears lit road into the shadow and leaves a dark echo behind the car. When only one frame has a usable sample and the spot looks about the same in both frames, we blend that spot from both instead.
  • Ghosts next to the player when the camera turns. Background that only shows up in the older frame got its motion from the hole fill, which hands it the player's motion. Result: blocky ghosts. We now test a few candidate motions against the older frame's own vectors and take the farthest one that fits.
  • Streaks in the player's colors beside him. Edge pixels carry a mix of the character's motion and the background's, so they landed halfway into the gap. If something clearly farther is within 2 pixels, the edge gets the motion that's most different from it.
  • Thin outline around the player against the sky. The upscaler softens edges, so background pixels right next to him pick up his color. We use the other frame's clean sample instead.
  • Blotches on the road at speed. Road rushing at the camera is a few meters farther away in the older frame, and a fixed depth tolerance rejected it. The tolerance now scales with motion length.
  • A line and a box along the screen edges at speed. Where the scene has left the screen, motion is continued past the edge instead of taking the hole fill's slow background motion. The edge fade is also wider at speed.
  • The car at the screen edge. Where neither frame actually has that spot, and the older one shows something fixed on screen like your car, we keep the same spot.
  • Poles and wires. Thin objects passing through show the background behind them, not smeared copies.
  • Subtitles. They aren't in the UI plane, so text that doesn't move between frames is kept as is.
  • Overlays the vectors don't know about. If the two warped samples disagree but the spot barely changed, we keep the spot.

The HUD and menus are never generated. larp already composites the UI plane on top of every frame, so they stay sharp.

You can turn most fixes off to compare, with LARP_MVFG_OFF= and a comma-separated list:

Flag Turns off
noshade shadows
nogap ghosts
noedge streaks
nofringe outline
nocore the at-speed fixes (road, screen edges), and part of the shadow fix
noboth overlays

The car, poles and subtitles fixes are always on. There's also mvflip, which flips the motion vectors for debugging.

Usage

In the F10 menu, set Frame generator to MVFG and pick 2x, 3x or 4x. Or start with LARP_FRAME_GENERATOR=mvfg.

How it works

Seven compute passes per generated frame:

  1. Clear
  2. Prep: dilate motion by nearest depth (3x3), plus the edge fix
  3. Scatter keys: work out which pixel of the newer frame lands where. Nearest wins, and on a tie the slower pixel wins
  4. Scatter the winners
  5. Pyramid down: each cell takes its farthest valid child
  6. Pyramid up: holes take their parent
  7. Resolve, with all the fixes above

Thresholds use the same units as on the PS5, 0-255 in display encoding (PQ for float HDR), so the tuned numbers carry over as they are.

Files

  • crates/larp-gpu/src/mvfg.rs, mvfg.hlsl: the generator. The shaders compile at runtime with D3DCompile (cs_5_1).
  • crates/larp-gpu/src/dlssfg.rs: hooks MVFG in as a third generator, with up to 3 generated frames.
  • Settings and locales: the new option, and its status line in all 7 languages. Only the English setting description mentions MVFG so far.

Testing

Tested on an RTX 3090 on Windows 11, in Series S mode at 1080p with DLSS Performance: 30 fps with MVFG 2x at 60 locked, in HDR10.

Not tried on PC yet: 3x and 4x, the FSR upscaler, SDR, and float HDR output. The code is there.

**@⁠Omnicrash** on GitHub · 2026-12-05 18:22 UTC · [original](https://github.com/gamingwithhomie/larp/pull/98) `Omnicrash:mvfg-pr` → `main` · +1144 −17 · 13 files · 1 commits · merged 2026-12-05 19:00 UTC This adds MVFG, a motion-vector frame generator, as a third option next to DLSS FG and FSR FG. It runs on any GPU up to 4x. The interesting part isn't the generator itself, it's the cleanup. A naive motion-vector FG looks pretty rough in this game, so most of the effort went into hunting down artifacts one by one. ## Artifacts it fixes We originally wrote this for the PS5 version and tuned it there with a small simulator: it rebuilds a real frame from its neighbors and scores the result against the actual frame. Every fix below was checked against that score and in-game. - **Shadows sliding with the road.** The game's shadows and AO don't follow the motion vectors. A car's shadow stays under the car while the vectors move the road, so plain warping smears lit road into the shadow and leaves a dark echo behind the car. When only one frame has a usable sample and the spot looks about the same in both frames, we blend that spot from both instead. - **Ghosts next to the player when the camera turns.** Background that only shows up in the older frame got its motion from the hole fill, which hands it the player's motion. Result: blocky ghosts. We now test a few candidate motions against the older frame's own vectors and take the farthest one that fits. - **Streaks in the player's colors beside him.** Edge pixels carry a mix of the character's motion and the background's, so they landed halfway into the gap. If something clearly farther is within 2 pixels, the edge gets the motion that's most different from it. - **Thin outline around the player against the sky.** The upscaler softens edges, so background pixels right next to him pick up his color. We use the other frame's clean sample instead. - **Blotches on the road at speed.** Road rushing at the camera is a few meters farther away in the older frame, and a fixed depth tolerance rejected it. The tolerance now scales with motion length. - **A line and a box along the screen edges at speed.** Where the scene has left the screen, motion is continued past the edge instead of taking the hole fill's slow background motion. The edge fade is also wider at speed. - **The car at the screen edge.** Where neither frame actually has that spot, and the older one shows something fixed on screen like your car, we keep the same spot. - **Poles and wires.** Thin objects passing through show the background behind them, not smeared copies. - **Subtitles.** They aren't in the UI plane, so text that doesn't move between frames is kept as is. - **Overlays the vectors don't know about.** If the two warped samples disagree but the spot barely changed, we keep the spot. The HUD and menus are never generated. larp already composites the UI plane on top of every frame, so they stay sharp. You can turn most fixes off to compare, with `LARP_MVFG_OFF=` and a comma-separated list: | Flag | Turns off | |---|---| | `noshade` | shadows | | `nogap` | ghosts | | `noedge` | streaks | | `nofringe` | outline | | `nocore` | the at-speed fixes (road, screen edges), and part of the shadow fix | | `noboth` | overlays | The car, poles and subtitles fixes are always on. There's also `mvflip`, which flips the motion vectors for debugging. ## Usage In the F10 menu, set Frame generator to MVFG and pick 2x, 3x or 4x. Or start with `LARP_FRAME_GENERATOR=mvfg`. ## How it works Seven compute passes per generated frame: 1. Clear 2. Prep: dilate motion by nearest depth (3x3), plus the edge fix 3. Scatter keys: work out which pixel of the newer frame lands where. Nearest wins, and on a tie the slower pixel wins 4. Scatter the winners 5. Pyramid down: each cell takes its farthest valid child 6. Pyramid up: holes take their parent 7. Resolve, with all the fixes above Thresholds use the same units as on the PS5, 0-255 in display encoding (PQ for float HDR), so the tuned numbers carry over as they are. ## Files - `crates/larp-gpu/src/mvfg.rs`, `mvfg.hlsl`: the generator. The shaders compile at runtime with `D3DCompile` (cs_5_1). - `crates/larp-gpu/src/dlssfg.rs`: hooks MVFG in as a third generator, with up to 3 generated frames. - Settings and locales: the new option, and its status line in all 7 languages. Only the English setting description mentions MVFG so far. ## Testing Tested on an RTX 3090 on Windows 11, in Series S mode at 1080p with DLSS Performance: 30 fps with MVFG 2x at 60 locked, in HDR10. Not tried on PC yet: 3x and 4x, the FSR upscaler, SDR, and float HDR output. The code is there.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-05 18:25:19 +00:00
github manually merged commit 09174d6413 into main 2026-12-05 19:01:24 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.