Mirrors: the mirror's view is given the light around (shows with #1541) #1762

Merged
KyleS98 merged 2 commits from upstream-pr/1762 into main 2026-11-29 08:16:56 +00:00
KyleS98 commented 2026-11-28 23:57:40 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by KyleS98 on 2026-11-28T23:57:40Z.


No issue is open for this (searched the issues and pull requests for: mirror, MirrorReflection, bathroom mirror, StencilCulling, PS_MIRROR_PBR).

What it changes

Mirrors. In the first house's bathroom the round mirror over the sink shows the sky instead of the room. Two things are in the way; this pull request is the second one, and it shows only together with the first (#1541).

How the title draws a mirror

Found with VICTORY_CAPTURE pass lists, VICTORY_DUMP_TARGETS and the names in the shader containers:

  1. It draws what the mirror shows as a second view of its own: the scene again from behind the glass (MS_VS_MirrorReflectionTransform*, MSNC_VS_MirrorReflectionPedTransformSkinD, PS_MirrorReflectionDeferred*), into a G-buffer of the picture's size rounded up to 16 (1280x736 on Series S), in a centred rectangle the size of the mirror on screen.
  2. Before those draws, PS_Prepass_StencilCulling marks the mirror's pixels by writing that view's depth image through an unordered-access view, in the same command list.
  3. ps_generate_material_mask turns the view's G-buffer into a material mask (a D16 image), and one full-screen draw for each kind of material (PS_MIRROR_PBR_MATERIAL_*, depth test EQUAL against the mask) lights the view into an R11G11B10 image.
  4. ps_mirror_volumetric_sky and ps_mirror_volumetric_scattering_transmittance draw the sky and the air into that image, ps_mirror_taa_default resolves it, and PS_ResolvePortalReflection (drawn with the mirror's own mesh) puts it where the mirror is.

The two faults

  • The view was empty. Step 2's write stayed in the depth plane's twin until the list closed, so every draw of step 1 tested against the plane as it had been: all the view's images held one colour each at the end of the frame, and the mirror showed the sky. That is what #1541 fixes (and I have nothing to add to its code; the evidence is in a comment there).
  • The view is black once it is drawn. Step 3 takes its indirect light from the probes the title's rays fill. Without the rays the view has the sun's direct light alone: the lit image held a small sunlit patch and nothing else. This pull request.

The change

crates/victory-gpu/src/mirror.rs, hooked in State::prepare_for:

  • Pixel programs get a part by their name in the container, as the compute programs get their role for the stand-in: ps_generate_material_mask and ps_mirror_volumetric_sky. Both run only while a mirror is in the picture.
  • At the mask's draw, the 2D texture of 8 bits a channel among its table views is noted as the view's colour (for that frame only).
  • Right before the sky's draw, a pass of ours adds to that draw's first target, within its scissor, the light around times each texel's own colour: one triangle, additive blend, then State::replay puts the title's state back.
  • The light around is what the stand-in for the indirect light gives the room itself, so a wall in the mirror is about as bright as the wall beside it: the mean of 144 of its points with a fifth of the picture's slow mean, at the stand-in's share (crate::ambient::around, the only addition to that file), or its constant. It has no direction: the view is seen from behind the glass, where the picture's points are not.
  • Where the view drew nothing its colour is black and nothing is added; the sky's draw fills those texels as before.
  • Nothing is added while the stand-in is off or has kept no frame yet, nor while the title's rays run (VICTORY_BVH_BUILDER=1).
  • VICTORY_MIRROR_AMBIENT=<multiple> scales it (default 1); 0 turns it off.

Limits

  • Flat light: faces in the mirror have less shape than on the console.
  • It is as right as the stand-in's light is. When no window is in the picture the stand-in gives the room little light, and the mirror goes dark with it.
  • One room checked by eye. The opening's diner has a mirror view too (the pass runs there); I saw no fault in it, but did not compare it with the console.
  • With the title's rays on nothing is added, and the mirror was dark there in my runs.

How it was tested

  • GPU and profile: RTX 3090 Ti 24 GB (driver 616.92), Ryzen 9 9950X3D, Windows 11 26200. First house from a shared save, bathroom; the save puts the player there in some launches only, and the mirror is in the picture in about half of those, so each result below is from launches repeated until it was. Profiles and settings are named with each result. Ray tracing (the builder) off throughout.

  • This tree: d4b5d517 + this + #1541 (cherry-picked; each applies cleanly on top of the other). Series S, DLSS Quality, builder off, play's defaults. The mirror shows the wall opposite with its hook, the blue tile border and the tiles under it, about as dark as the room was in that view (the camera looked away from the window, where the stand-in gives little light). "Times used before the pass" stayed at 0 over the run, which is #1541's doing, and the pass logged its line with the view's rectangle. The frame rate was not measured there: that build's shader cache was still cold.

  • VIctory-Neo (a fork of this tree from 63b902f; the same mirror.rs, with the depth plane published by a change of my own to the same effect as #1541):

    • before either change the mirror showed the sky (white, a blue band of sea, white);
    • with the depth change alone it was black, and the dump showed the view's G-buffer filled and its lit image empty but for a sunlit patch: that is the second fault;
    • with both, from the doorway, the mirror shows the character's face and shirt and the room behind him, at 1920x1080 on Series S and at 2560x1440 on Series X with DLSS Performance and FSR 3 frame generation.
  • Speed, in Neo with both changes: the prologue's cell ran 32.9 frames a second where the builds before ran 32.3 and 32.5 (Series X, 2560x1440, frame generation), and 38.8 where they ran 39.0 to 39.5 (Series S, no DLSS): nothing that stands out of the runs' own spread. The pass is one triangle over the mirror's rectangle, and only while a mirror is in the picture.

  • Not run: this branch without #1541. By the dumps the view's colour is black then, and the pass multiplies by it, so I expect no change at all. Also not run: AMD cards, and the Series X profile on this tree.

  • cargo test -p victory-gpu --lib mirror::: 3 pass (the parts by name, the setting, both programs of the pass compile). cargo clippy -p victory-gpu --all-targets has nothing in the new code.

  • For shader changes, the wave sizes tested: no translated shader changes; the pass's own two programs are plain HLSL.

  • cargo test passed for the crates it touches: yes (cargo test -p victory-gpu on this branch: 553 passed, 0 failed, 43 ignored).

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches. Related: #1541 (needed for this to show; this touches draw.rs in State::prepare_for, which #1541 does not change, and each applies cleanly on the other), #1018 (its closed predecessor). Nothing else names mirrors.

No screenshots: I don't post pictures of the game.

AI-assisted (Claude Code, Claude Fable 5.2).

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5545823637 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1762). Originally posted by [KyleS98](https://github.com/KyleS98) on 2026-11-28T23:57:40Z. --- No issue is open for this (searched the issues and pull requests for: mirror, MirrorReflection, bathroom mirror, StencilCulling, PS_MIRROR_PBR). ## What it changes Mirrors. In the first house's bathroom the round mirror over the sink shows the sky instead of the room. Two things are in the way; this pull request is the second one, and it shows only together with the first (#1541). ### How the title draws a mirror Found with `VICTORY_CAPTURE` pass lists, `VICTORY_DUMP_TARGETS` and the names in the shader containers: 1. It draws what the mirror shows as a **second view of its own**: the scene again from behind the glass (`MS_VS_MirrorReflectionTransform*`, `MSNC_VS_MirrorReflectionPedTransformSkinD`, `PS_MirrorReflectionDeferred*`), into a G-buffer of the picture's size rounded up to 16 (1280x736 on Series S), in a centred rectangle the size of the mirror on screen. 2. Before those draws, `PS_Prepass_StencilCulling` marks the mirror's pixels by writing that view's depth image through an unordered-access view, in the same command list. 3. `ps_generate_material_mask` turns the view's G-buffer into a material mask (a D16 image), and one full-screen draw for each kind of material (`PS_MIRROR_PBR_MATERIAL_*`, depth test EQUAL against the mask) lights the view into an R11G11B10 image. 4. `ps_mirror_volumetric_sky` and `ps_mirror_volumetric_scattering_transmittance` draw the sky and the air into that image, `ps_mirror_taa_default` resolves it, and `PS_ResolvePortalReflection` (drawn with the mirror's own mesh) puts it where the mirror is. ### The two faults - **The view was empty.** Step 2's write stayed in the depth plane's twin until the list closed, so every draw of step 1 tested against the plane as it had been: all the view's images held one colour each at the end of the frame, and the mirror showed the sky. That is what #1541 fixes (and I have nothing to add to its code; the evidence is in a comment there). - **The view is black once it is drawn.** Step 3 takes its indirect light from the probes the title's rays fill. Without the rays the view has the sun's direct light alone: the lit image held a small sunlit patch and nothing else. **This pull request.** ### The change `crates/victory-gpu/src/mirror.rs`, hooked in `State::prepare_for`: - Pixel programs get a part by their name in the container, as the compute programs get their role for the stand-in: `ps_generate_material_mask` and `ps_mirror_volumetric_sky`. Both run only while a mirror is in the picture. - At the mask's draw, the 2D texture of 8 bits a channel among its table views is noted as the view's colour (for that frame only). - Right before the sky's draw, a pass of ours adds to that draw's first target, within its scissor, **the light around times each texel's own colour**: one triangle, additive blend, then `State::replay` puts the title's state back. - The light around is what the stand-in for the indirect light gives the room itself, so a wall in the mirror is about as bright as the wall beside it: the mean of 144 of its points with a fifth of the picture's slow mean, at the stand-in's share (`crate::ambient::around`, the only addition to that file), or its constant. It has no direction: the view is seen from behind the glass, where the picture's points are not. - Where the view drew nothing its colour is black and nothing is added; the sky's draw fills those texels as before. - Nothing is added while the stand-in is off or has kept no frame yet, nor while the title's rays run (`VICTORY_BVH_BUILDER=1`). - `VICTORY_MIRROR_AMBIENT=<multiple>` scales it (default 1); `0` turns it off. ### Limits - Flat light: faces in the mirror have less shape than on the console. - It is as right as the stand-in's light is. When no window is in the picture the stand-in gives the room little light, and the mirror goes dark with it. - One room checked by eye. The opening's diner has a mirror view too (the pass runs there); I saw no fault in it, but did not compare it with the console. - With the title's rays on nothing is added, and the mirror was dark there in my runs. ## How it was tested - GPU and profile: RTX 3090 Ti 24 GB (driver 616.92), Ryzen 9 9950X3D, Windows 11 26200. First house from a shared save, bathroom; the save puts the player there in some launches only, and the mirror is in the picture in about half of those, so each result below is from launches repeated until it was. Profiles and settings are named with each result. Ray tracing (the builder) off throughout. - **This tree: `d4b5d517` + this + #1541** (cherry-picked; each applies cleanly on top of the other). Series S, DLSS Quality, builder off, `play`'s defaults. The mirror shows the wall opposite with its hook, the blue tile border and the tiles under it, about as dark as the room was in that view (the camera looked away from the window, where the stand-in gives little light). "Times used before the pass" stayed at 0 over the run, which is #1541's doing, and the pass logged its line with the view's rectangle. The frame rate was not measured there: that build's shader cache was still cold. - **VIctory-Neo** (a fork of this tree from `63b902f`; the same `mirror.rs`, with the depth plane published by a change of my own to the same effect as #1541): - before either change the mirror showed the sky (white, a blue band of sea, white); - with the depth change alone it was black, and the dump showed the view's G-buffer filled and its lit image empty but for a sunlit patch: that is the second fault; - with both, from the doorway, the mirror shows the character's face and shirt and the room behind him, at 1920x1080 on Series S and at 2560x1440 on Series X with DLSS Performance and FSR 3 frame generation. - **Speed, in Neo with both changes:** the prologue's cell ran 32.9 frames a second where the builds before ran 32.3 and 32.5 (Series X, 2560x1440, frame generation), and 38.8 where they ran 39.0 to 39.5 (Series S, no DLSS): nothing that stands out of the runs' own spread. The pass is one triangle over the mirror's rectangle, and only while a mirror is in the picture. - **Not run:** this branch without #1541. By the dumps the view's colour is black then, and the pass multiplies by it, so I expect no change at all. Also not run: AMD cards, and the Series X profile on this tree. - `cargo test -p victory-gpu --lib mirror::`: 3 pass (the parts by name, the setting, both programs of the pass compile). `cargo clippy -p victory-gpu --all-targets` has nothing in the new code. - For shader changes, the wave sizes tested: no translated shader changes; the pass's own two programs are plain HLSL. - `cargo test` passed for the crates it touches: yes (`cargo test -p victory-gpu` on this branch: 553 passed, 0 failed, 43 ignored). ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches. Related: #1541 (needed for this to show; this touches `draw.rs` in `State::prepare_for`, which #1541 does not change, and each applies cleanly on the other), #1018 (its closed predecessor). Nothing else names mirrors. No screenshots: I don't post pictures of the game. AI-assisted (Claude Code, Claude Fable 5.2).
KyleS98 commented 2026-11-29 00:11:17 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by KyleS98 on 2026-11-29T00:11:17Z.


A note on the red check, so it isn't read as this change's: it stops in Clippy on victory-shader, at emit/lower.rs:13896 (unused variable colour) and :2213 (manual checked division), which are main's own; the run on d4b5d517 itself fails on the same two. Nothing in the log is in the files this touches, and cargo clippy -p victory-gpu --all-targets has nothing in the new code here.

AI-assisted (Claude Code, Claude Fable 5.2).

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7247936482 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1762#issuecomment-7247936482). Originally posted by [KyleS98](https://github.com/KyleS98) on 2026-11-29T00:11:17Z. --- A note on the red check, so it isn't read as this change's: it stops in Clippy on `victory-shader`, at `emit/lower.rs:13896` (unused variable `colour`) and `:2213` (manual checked division), which are `main`'s own; the run on `d4b5d517` itself fails on the same two. Nothing in the log is in the files this touches, and `cargo clippy -p victory-gpu --all-targets` has nothing in the new code here. AI-assisted (Claude Code, Claude Fable 5.2).
KyleS98 commented 2026-11-29 03:08:31 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by KyleS98 on 2026-11-29T03:08:31Z.


Brought up to main (f9dfb76f merged in, head d26f1979). One line beyond the merge: main now makes a masked twin of a pixel shader (Shader::masked), and that initializer needed the new field, without which the branch no longer compiled against main although it showed as mergeable. The twin keeps its part in a mirror, being the same program under a sample mask.

cargo test -p victory-gpu on the new head: 592 passed, 0 failed, 44 ignored. The in-game runs in the description were on d4b5d517 and have not been repeated on the new base. The check still stops in Clippy at main's own finding in victory-shader (manual checked division, emit/lower.rs), now the only one; nothing in the log is in the files this touches.

AI-assisted (Claude Code, Claude Fable 5.2).

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7249866445 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1762#issuecomment-7249866445). Originally posted by [KyleS98](https://github.com/KyleS98) on 2026-11-29T03:08:31Z. --- Brought up to `main` (`f9dfb76f` merged in, head `d26f1979`). One line beyond the merge: `main` now makes a masked twin of a pixel shader (`Shader::masked`), and that initializer needed the new field, without which the branch no longer compiled against `main` although it showed as mergeable. The twin keeps its part in a mirror, being the same program under a sample mask. `cargo test -p victory-gpu` on the new head: 592 passed, 0 failed, 44 ignored. The in-game runs in the description were on `d4b5d517` and have not been repeated on the new base. The check still stops in Clippy at `main`'s own finding in `victory-shader` (manual checked division, `emit/lower.rs`), now the only one; nothing in the log is in the files this touches. AI-assisted (Claude Code, Claude Fable 5.2).
amazedturnip commented 2026-11-29 05:38:48 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by amazedturnip on 2026-11-29T05:38:48Z.


Tested paired with #1541 on 9800X3D + RTX 5070 Ti 16 GB (Series X 1440p DLSS, RT off). Mirror ambient lighting works cleanly across 20+ min gameplay with no artifacts or crashes.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7251376288 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1762#issuecomment-7251376288). Originally posted by [amazedturnip](https://github.com/amazedturnip) on 2026-11-29T05:38:48Z. --- Tested paired with #1541 on 9800X3D + RTX 5070 Ti 16 GB (Series X 1440p DLSS, RT off). Mirror ambient lighting works cleanly across 20+ min gameplay with no artifacts or crashes.
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
trustno1-coder/VIctory-NVIDIA!1762
No description provided.