Shaders: limit highlights on small dust sprites (opt-in VICTORY_PARTICLE_KNEE, port of VIctory-NVIDIA #2156) #444

Closed
notdxbi wants to merge 660 commits from upstream-pr/444 into main
notdxbi commented 2026-11-29 14:08:02 +00:00 (Migrated from github.com)

Imported from TaynanGT/Vice-Tay. Originally posted by notdxbi on 2026-11-29T14:08:02Z.


Brings Yoshi-233's fix for the bright indoor specks (trustno1-coder/VIctory-NVIDIA#695) to Vice-Tay. Their pull request trustno1-coder/VIctory-NVIDIA#2156 is still open there. Authorship is kept (--author Yoshi-233, cherry picked from 8cd858b0). This PR adds a Vice-Tay measurement on Linux.

What it changes

Without ray tracing, one dual-source dust particle pixel shader puts single bright pixels over dark interiors. They look like white "fireflies" on ceilings, walls and cabinets, worst in Jason's house. With VICTORY_PARTICLE_KNEE=<knee> set, the translation of that one program estimates each sprite's screen area from barycentric derivatives. It then puts a soft shoulder on the brightest emission of very small sprites, and restores the matching transmission. The knee is part of the shader cache key. When the variable is unset, the translation is unchanged, so this is opt-in.

One adaptation for Vice-Tay: lower_with_particles passes Lower::new the early_depth argument that Vice-Tay has and VIctory-NVIDIA does not. Nothing else differs from 8cd858b0.

Measurement

Setup. RTX 5060 8 GB (PCIe 3.0 x8), driver 620.70.06; Ryzen 7 5700X; 32 GB. Nobara Linux 44, kernel 7.3.4, GE-Proton11-14-viewtree, outside Steam. Build: main fe7c6e52 + this commit (f123694a), cargo build --locked --profile diag -p victory --features diagnostics, x86_64-pc-windows-gnu. Settings: linux/play.sh's NVIDIA set, play.ps1 -Machine 4070 threads, the #384 8 GB memory values (CARD_BUFFERS_MB=1024, CARD_WINDOWS_MB=512, TEXTURE_ROOM_PERCENT=85), PIPELINE_WAIT_MS=0, BCPack tables (#385), and DLSS Quality. Series S, 1080p output shown at 2560×1440.

Same exe both runs. The 44 launch settings are identical except VICTORY_PARTICLE_KNEE=0.012 in B (A settings, B settings). The scene is the Chapter 1 save ("Gone Fishing"), inside Jason's house, facing the kitchen ceiling, wall and cabinets, hands off the controls. Each recording started only after the pipeline queue was empty (≤ 20 being made), so no draws were missing from a pipeline still being built. Each run has 60 s of video plus 20 lossless 2560×1440 screenshots, all reviewed.

Speck counter (specks.py). A speck is an 8-connected blob of ≤ 25 px whose luminance is ≥ 25 sRGB levels above the median of its 9×9 neighbourhood. It is counted only on dark (median ≤ 60) and smooth (local median range ≤ 12, so object edges are left out) surfaces, outside the overlay and the money HUD. specks_mark.py rings every counted blob.

A: knee unset B: knee 0.012
Ceiling box, 20 lossless frames, specks/frame 40.5 median (p10 33, p90 47) 0 in all 20
Dark flat surfaces, 20 lossless frames, per Mpx 107.6 (p10 101, p90 112) 17.4 (p10 14, p90 20)
Dark flat surfaces, 60 s video at 2 fps (123 / 122 frames), per Mpx 94.0 (p10 86, p90 108) 16.0 (p10 13, p90 18)
Rendered fps while recording (11 log windows each) 2.1 median (1.9–2.3) 2.1 median (2.0–2.3)

In B, the ceiling box has no specks in any frame. The blobs B still counts on the whole frame are object edges the smoothness test doesn't fully catch: leaves through a window, door glass, the edge of the glass case. They are visible in B marked. So the −84% on the full frame is a lower bound for the improvement. The fps is the same in both runs. The low absolute fps (GPU ~280–300 ms a frame) is this 8 GB card on stock main with VRAM full and spilling, and it is the same in both runs.

Ceiling, A vs B, 1:1 crops

Full frames with every counted blob ringed: A · B. One frame every 5 s of each video: A · B. Videos: A · B. Per-frame counts: counts/.

Review of both videos, start to finish. Neither has flicker, HUD damage, colour shifts or other new artifacts. In B the ceiling, walls and cabinets stay free of specks for the whole 60 s. In A they are visible in every sampled frame, and a few drift between frames.

Limits of the comparison.

  • The camera is not identical: B stands further back, facing the same ceiling, wall and cabinets. That is why the table uses specks per area of dark surface, plus a ceiling box in each frame.
  • The in-game clock moved on between the two loads (A in sunset light, B at night).
  • Only this one room was tested. Like Yoshi-233 in #2156, I haven't checked legitimately bright dust from this material in another scene; it may get dimmer.
  • Both runs drop 250–350 draws a frame from the VRAM pressure, the same in both.

Checks

  • cargo test --locked -p victory-shader: 227 passed, 0 failed, 2 ignored.
  • cargo clippy --locked -p victory-shader -p victory-gpu --all-targets --target x86_64-pc-windows-gnu -- -D warnings: clean.
  • Not run here: the full Windows CI matrix and the DXIL validator. The original PR reports 36 programs passing the Windows DXIL validator, and byte-identical output with the knee off.

With #439

This commit conflicts with the draft integration #439 in lower.rs only. Both add a function at the same place, and the fix is to keep both. Branch particle-knee-on-439 is this commit on #439's head (cfd5ebda): victory-shader tests 232 passed. Its Clippy errors are #439's own, the ones #442 fixes.

AI use: Claude Code (Claude Opus 5.5) ported, built, ran the counter and wrote this. The runs were played by hand. Credit for the fix: Yoshi-233.

🤖 Generated with Claude Code

<!-- greyfinch-sync:TaynanGT/Vice-Tay:issue:5551501001 --> Imported from [TaynanGT/Vice-Tay](https://github.com/TaynanGT/Vice-Tay/pull/444). Originally posted by [notdxbi](https://github.com/notdxbi) on 2026-11-29T14:08:02Z. --- Brings Yoshi-233's fix for the bright indoor specks (trustno1-coder/VIctory-NVIDIA#695) to Vice-Tay. Their pull request trustno1-coder/VIctory-NVIDIA#2156 is still open there. Authorship is kept (`--author` Yoshi-233, `cherry picked from 8cd858b0`). This PR adds a Vice-Tay measurement on Linux. ## What it changes Without ray tracing, one dual-source dust particle pixel shader puts single bright pixels over dark interiors. They look like white "fireflies" on ceilings, walls and cabinets, worst in Jason's house. With `VICTORY_PARTICLE_KNEE=<knee>` set, the translation of that one program estimates each sprite's screen area from barycentric derivatives. It then puts a soft shoulder on the brightest emission of very small sprites, and restores the matching transmission. The knee is part of the shader cache key. **When the variable is unset, the translation is unchanged**, so this is opt-in. One adaptation for Vice-Tay: `lower_with_particles` passes `Lower::new` the `early_depth` argument that Vice-Tay has and VIctory-NVIDIA does not. Nothing else differs from 8cd858b0. ## Measurement **Setup.** RTX 5060 8 GB (PCIe 3.0 x8), driver 620.70.06; Ryzen 7 5700X; 32 GB. Nobara Linux 44, kernel 7.3.4, GE-Proton11-14-viewtree, outside Steam. Build: `main` fe7c6e52 + this commit (f123694a), `cargo build --locked --profile diag -p victory --features diagnostics`, x86_64-pc-windows-gnu. Settings: linux/play.sh's NVIDIA set, play.ps1 `-Machine 4070` threads, the #384 8 GB memory values (`CARD_BUFFERS_MB=1024`, `CARD_WINDOWS_MB=512`, `TEXTURE_ROOM_PERCENT=85`), `PIPELINE_WAIT_MS=0`, BCPack tables (#385), and DLSS Quality. Series S, 1080p output shown at 2560×1440. **Same exe both runs.** The 44 launch settings are identical except `VICTORY_PARTICLE_KNEE=0.012` in B ([A settings](https://github.com/notdxbi/Vice-Tay/blob/3c198b8e260777334fedcd47b6c0823c24914b57/evidence/particle-knee/runs/A-settings.txt), [B settings](https://github.com/notdxbi/Vice-Tay/blob/3c198b8e260777334fedcd47b6c0823c24914b57/evidence/particle-knee/runs/B-settings.txt)). The scene is the Chapter 1 save ("Gone Fishing"), inside Jason's house, facing the kitchen ceiling, wall and cabinets, hands off the controls. Each recording started only after the pipeline queue was empty (≤ 20 being made), so no draws were missing from a pipeline still being built. Each run has 60 s of video plus 20 lossless 2560×1440 screenshots, all reviewed. **Speck counter** ([`specks.py`](https://github.com/notdxbi/Vice-Tay/blob/3c198b8e260777334fedcd47b6c0823c24914b57/evidence/particle-knee/tools/specks.py)). A speck is an 8-connected blob of ≤ 25 px whose luminance is ≥ 25 sRGB levels above the median of its 9×9 neighbourhood. It is counted only on dark (median ≤ 60) and smooth (local median range ≤ 12, so object edges are left out) surfaces, outside the overlay and the money HUD. [`specks_mark.py`](https://github.com/notdxbi/Vice-Tay/blob/3c198b8e260777334fedcd47b6c0823c24914b57/evidence/particle-knee/tools/specks_mark.py) rings every counted blob. | | A: knee unset | B: knee 0.012 | |---|---:|---:| | Ceiling box, 20 lossless frames, specks/frame | **40.5** median (p10 33, p90 47) | **0** in all 20 | | Dark flat surfaces, 20 lossless frames, per Mpx | **107.6** (p10 101, p90 112) | **17.4** (p10 14, p90 20) | | Dark flat surfaces, 60 s video at 2 fps (123 / 122 frames), per Mpx | **94.0** (p10 86, p90 108) | **16.0** (p10 13, p90 18) | | Rendered fps while recording (11 log windows each) | 2.1 median (1.9–2.3) | 2.1 median (2.0–2.3) | In B, the ceiling box has no specks in any frame. The blobs B still counts on the whole frame are object edges the smoothness test doesn't fully catch: leaves through a window, door glass, the edge of the glass case. They are visible in [B marked](https://github.com/notdxbi/Vice-Tay/blob/3c198b8e260777334fedcd47b6c0823c24914b57/evidence/particle-knee/frames/B-marked-dark-flat.png). So the −84% on the full frame is a lower bound for the improvement. The fps is the same in both runs. The low absolute fps (GPU ~280–300 ms a frame) is this 8 GB card on stock `main` with VRAM full and spilling, and it is the same in both runs. ![Ceiling, A vs B, 1:1 crops](https://raw.githubusercontent.com/notdxbi/Vice-Tay/3c198b8e260777334fedcd47b6c0823c24914b57/evidence/particle-knee/frames/ceiling-A-vs-B-1to1.png) Full frames with every counted blob ringed: [A](https://github.com/notdxbi/Vice-Tay/blob/3c198b8e260777334fedcd47b6c0823c24914b57/evidence/particle-knee/frames/A-marked-dark-flat.png) · [B](https://github.com/notdxbi/Vice-Tay/blob/3c198b8e260777334fedcd47b6c0823c24914b57/evidence/particle-knee/frames/B-marked-dark-flat.png). One frame every 5 s of each video: [A](https://github.com/notdxbi/Vice-Tay/blob/3c198b8e260777334fedcd47b6c0823c24914b57/evidence/particle-knee/frames/A-video-every-5s.png) · [B](https://github.com/notdxbi/Vice-Tay/blob/3c198b8e260777334fedcd47b6c0823c24914b57/evidence/particle-knee/frames/B-video-every-5s.png). Videos: [A](https://github.com/notdxbi/Vice-Tay/blob/3c198b8e260777334fedcd47b6c0823c24914b57/evidence/particle-knee/video/A-knee-unset.mp4) · [B](https://github.com/notdxbi/Vice-Tay/blob/3c198b8e260777334fedcd47b6c0823c24914b57/evidence/particle-knee/video/B-knee-0.012.mp4). Per-frame counts: [counts/](https://github.com/notdxbi/Vice-Tay/tree/3c198b8e260777334fedcd47b6c0823c24914b57/evidence/particle-knee/counts). **Review of both videos, start to finish.** Neither has flicker, HUD damage, colour shifts or other new artifacts. In B the ceiling, walls and cabinets stay free of specks for the whole 60 s. In A they are visible in every sampled frame, and a few drift between frames. **Limits of the comparison.** - The camera is not identical: B stands further back, facing the same ceiling, wall and cabinets. That is why the table uses specks per area of dark surface, plus a ceiling box in each frame. - The in-game clock moved on between the two loads (A in sunset light, B at night). - Only this one room was tested. Like Yoshi-233 in #2156, I haven't checked legitimately bright dust from this material in another scene; it may get dimmer. - Both runs drop 250–350 draws a frame from the VRAM pressure, the same in both. ## Checks - `cargo test --locked -p victory-shader`: 227 passed, 0 failed, 2 ignored. - `cargo clippy --locked -p victory-shader -p victory-gpu --all-targets --target x86_64-pc-windows-gnu -- -D warnings`: clean. - Not run here: the full Windows CI matrix and the DXIL validator. The original PR reports 36 programs passing the Windows DXIL validator, and byte-identical output with the knee off. ## With #439 This commit conflicts with the draft integration #439 in `lower.rs` only. Both add a function at the same place, and the fix is to keep both. Branch [`particle-knee-on-439`](https://github.com/notdxbi/Vice-Tay/tree/particle-knee-on-439) is this commit on #439's head (cfd5ebda): `victory-shader` tests 232 passed. Its Clippy errors are #439's own, the ones #442 fixes. AI use: Claude Code (Claude Opus 5.5) ported, built, ran the counter and wrote this. The runs were played by hand. Credit for the fix: Yoshi-233. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
TaynanGT commented 2026-11-29 14:39:02 +00:00 (Migrated from github.com)

Imported from TaynanGT/Vice-Tay. Originally posted by TaynanGT on 2026-11-29T14:39:02Z.


I integrated the particle shoulder locally as 761cdb088, retaining the existing geometry lowering and early-depth path, with credit to Yoshi-233 and notdxbi. It remains opt-in. The shader suite is running; the reported speck reduction is promising, but I still need a matched 4K visual comparison before treating it as validated.

<!-- greyfinch-sync:TaynanGT/Vice-Tay:comment:7257468355 --> Imported from [TaynanGT/Vice-Tay](https://github.com/TaynanGT/Vice-Tay/pull/444#issuecomment-7257468355). Originally posted by [TaynanGT](https://github.com/TaynanGT) on 2026-11-29T14:39:02Z. --- I integrated the particle shoulder locally as 761cdb088, retaining the existing geometry lowering and early-depth path, with credit to Yoshi-233 and notdxbi. It remains opt-in. The shader suite is running; the reported speck reduction is promising, but I still need a matched 4K visual comparison before treating it as validated.
Kal0s-design commented 2026-11-29 14:47:11 +00:00 (Migrated from github.com)

Imported from TaynanGT/Vice-Tay. Originally posted by Kal0s-design on 2026-11-29T14:47:11Z.

Review: COMMENTED


Checked this on Windows (f123694), without running the title.

  • cargo test -p victory-shader --lib: 343 passed. cargo clippy --workspace --all-targets -D warnings, with and without --all-features: clean. cargo xtask policy: ok.
  • Translated every shader of a 1.0.2.1 dump (shaders.rpf plus the exe and DLLs) into two empty caches, once with VICTORY_PARTICLE_KNEE unset and once with 0.012. Both runs give 25,788 shaders, 197 that don't translate (the same two reasons) and 0 not cached, so the knee breaks nothing else.
  • Comparing the two caches by content: exactly one translation differs, 25,788 → 26,008 bytes. All the others are byte-identical, so the scope is the one dust program the digest names.

From reading the change: unset, lower_container goes straight to lower(parts), the same path as before. A NaN peak gives max(peak, knee) = knee, so the scale is 1. A degenerate footprint (zero derivatives) gives weight 0, so nothing changes there either. SDiv on float operands is LLVM's fdiv in bitcode, as elsewhere in lower.rs.

One small thing: nothing exercises the knee path in the test suite. The scan above only shows it translates. A test that lowers a small dual-source PS with the knee set and checks the extra fmul on color 0 would keep it from breaking silently. The digest can't match a synthetic program, though, so it would need a way to force the path.

AI-assisted: yes

<!-- greyfinch-sync:TaynanGT/Vice-Tay:review:6103370163 --> Imported from [TaynanGT/Vice-Tay](https://github.com/TaynanGT/Vice-Tay/pull/444#pullrequestreview-6103370163). Originally posted by [Kal0s-design](https://github.com/Kal0s-design) on 2026-11-29T14:47:11Z. **Review:** COMMENTED --- Checked this on Windows (f123694), without running the title. - `cargo test -p victory-shader --lib`: 343 passed. `cargo clippy --workspace --all-targets -D warnings`, with and without `--all-features`: clean. `cargo xtask policy`: ok. - Translated every shader of a 1.0.2.1 dump (`shaders.rpf` plus the exe and DLLs) into two empty caches, once with `VICTORY_PARTICLE_KNEE` unset and once with `0.012`. Both runs give 25,788 shaders, 197 that don't translate (the same two reasons) and 0 not cached, so the knee breaks nothing else. - Comparing the two caches by content: exactly **one** translation differs, 25,788 → 26,008 bytes. All the others are byte-identical, so the scope is the one dust program the digest names. From reading the change: unset, `lower_container` goes straight to `lower(parts)`, the same path as before. A NaN peak gives `max(peak, knee) = knee`, so the scale is 1. A degenerate footprint (zero derivatives) gives weight 0, so nothing changes there either. `SDiv` on float operands is LLVM's `fdiv` in bitcode, as elsewhere in `lower.rs`. One small thing: nothing exercises the knee path in the test suite. The scan above only shows it translates. A test that lowers a small dual-source PS with the knee set and checks the extra `fmul` on color 0 would keep it from breaking silently. The digest can't match a synthetic program, though, so it would need a way to force the path. AI-assisted: yes
TaynanGT commented 2026-11-29 19:03:58 +00:00 (Migrated from github.com)

Imported from TaynanGT/Vice-Tay. Originally posted by TaynanGT on 2026-11-29T19:03:58Z.


Thanks for the native Windows checks and the full shader-cache comparison. The single changed translation is good evidence of the intended scope, not yet of visual correctness. I agree with adding a synthetic dual-source pixel shader test through an internal test-only selector: check the enabled and disabled paths, color 0 scaling, and preservation of the second output. Keep the public digest restriction intact.

<!-- greyfinch-sync:TaynanGT/Vice-Tay:comment:7260978730 --> Imported from [TaynanGT/Vice-Tay](https://github.com/TaynanGT/Vice-Tay/pull/444#issuecomment-7260978730). Originally posted by [TaynanGT](https://github.com/TaynanGT) on 2026-11-29T19:03:58Z. --- Thanks for the native Windows checks and the full shader-cache comparison. The single changed translation is good evidence of the intended scope, not yet of visual correctness. I agree with adding a synthetic dual-source pixel shader test through an internal test-only selector: check the enabled and disabled paths, color 0 scaling, and preservation of the second output. Keep the public digest restriction intact.
TaynanGT commented 2026-11-30 17:06:31 +00:00 (Migrated from github.com)

Imported from TaynanGT/Vice-Tay. Originally posted by TaynanGT on 2026-11-30T17:06:31Z.


main has moved to a new line of the code and everything is now named Vice-Tay, so this PR no longer applies as it is (details in #468). If you'd like this change in, please rebuild it on the current main and open a new PR; I'll review it there.

<!-- greyfinch-sync:TaynanGT/Vice-Tay:comment:7285730627 --> Imported from [TaynanGT/Vice-Tay](https://github.com/TaynanGT/Vice-Tay/pull/444#issuecomment-7285730627). Originally posted by [TaynanGT](https://github.com/TaynanGT) on 2026-11-30T17:06:31Z. --- `main` has moved to a new line of the code and everything is now named Vice-Tay, so this PR no longer applies as it is (details in #468). If you'd like this change in, please rebuild it on the current `main` and open a new PR; I'll review it there.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
TaynanGT/Vice-Tay!444
No description provided.