GPU: bound ambient air inscattering by local surface luminance (#1395) #1930

Merged
dheerajc8073 merged 1 commit from upstream-pr/1930 into main 2026-11-30 14:12:04 +00:00
dheerajc8073 commented 2026-11-29 03:10:44 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by dheerajc8073 on 2026-11-29T03:10:44Z.


Fixes #1395

What it changes

In crates/victory-gpu/src/ambient.rs, clear_air runs after CS_AccumulateLocalLightInscatteringVolume (Role::Air) to cap volumetric air inscattering and prevent sky probes from flooding interior rooms with daylight haze when ray tracing is off.

Previously, clear_air calculated the inscattering cap as:

float far = float(at.z) / float(d);
float cap = air * lerp(dot(cells[CELLS].rgb, LUMA), dot(seen_there, LUMA), far);

Because far = 0 at near slices, cap evaluated to air * cells[CELLS] near the camera. In dark interiors (Jason's house at night, garages, mod shops, bathrooms/showers) and UI menus (wardrobe menu, Pro Builds menu), cells[CELLS] is elevated by UI text, local lamps, or outdoor history. This allowed probe sky light to penetrate dark interiors without being clamped, producing a milky green veil and washing out contrast (#1395).

This PR:

  1. Bounds the near-field ambient light by min(cells_luma, seen_luma):
float seen_luma = max(dot(seen_there, LUMA), 0.0);
float cells_luma = max(dot(cells[CELLS].rgb, LUMA), 0.0);
float room = min(cells_luma, seen_luma);
float far = float(at.z) / float(d);
float cap = air * lerp(room, seen_luma, far);
  1. In dark interiors or when menus open, the near air cap is strictly bounded by the surface light seen in that direction, eliminating milky haze and restoring indoor contrast.
  2. Looking out towards bright windows smoothly interpolates from room ambient to window ambient without creating an artificial white-green halo around the window frame.
  3. Preserves intended outdoor daytime haze, sunbeams, and atmospheric scattering.
  4. Adds regression tests verifying the bounded inscattering cap under dark interior and window conditions.

How it was tested

  • GPU and profile: NVIDIA RTX 5080 / RTX 3070, Series X / Series S profiles, DLSS Quality / Performance, ray tracing off (VICTORY_AMBIENT=0.8, VICTORY_AMBIENT_AIR=1.5, VICTORY_AMBIENT_SPECULAR=1).
  • Before: Milky haze indoors at night, wardrobe menu left side glowing milky, garage menus obscured by grey fog, and bright green/white halo around interior windows.
  • After: Dark rooms stay dark and high-contrast; wardrobe menu and mod shop backgrounds remain crisp without milky glow; window transitions render smoothly without halo.
  • For shader changes, the wave sizes tested: 32-lane and 64-lane waves (hlsl compute pass clear_air).
  • cargo test passed for the crates it touches: yes

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches. Related: #1395
<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5547078038 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1930). Originally posted by [dheerajc8073](https://github.com/dheerajc8073) on 2026-11-29T03:10:44Z. --- Fixes #1395 ## What it changes In `crates/victory-gpu/src/ambient.rs`, `clear_air` runs after `CS_AccumulateLocalLightInscatteringVolume` (`Role::Air`) to cap volumetric air inscattering and prevent sky probes from flooding interior rooms with daylight haze when ray tracing is off. Previously, `clear_air` calculated the inscattering cap as: ```hlsl float far = float(at.z) / float(d); float cap = air * lerp(dot(cells[CELLS].rgb, LUMA), dot(seen_there, LUMA), far); ``` Because `far = 0` at near slices, `cap` evaluated to `air * cells[CELLS]` near the camera. In dark interiors (Jason's house at night, garages, mod shops, bathrooms/showers) and UI menus (wardrobe menu, Pro Builds menu), `cells[CELLS]` is elevated by UI text, local lamps, or outdoor history. This allowed probe sky light to penetrate dark interiors without being clamped, producing a milky green veil and washing out contrast (#1395). This PR: 1. Bounds the near-field ambient light by `min(cells_luma, seen_luma)`: ```hlsl float seen_luma = max(dot(seen_there, LUMA), 0.0); float cells_luma = max(dot(cells[CELLS].rgb, LUMA), 0.0); float room = min(cells_luma, seen_luma); float far = float(at.z) / float(d); float cap = air * lerp(room, seen_luma, far); ``` 2. In dark interiors or when menus open, the near air cap is strictly bounded by the surface light seen in that direction, eliminating milky haze and restoring indoor contrast. 3. Looking out towards bright windows smoothly interpolates from room ambient to window ambient without creating an artificial white-green halo around the window frame. 4. Preserves intended outdoor daytime haze, sunbeams, and atmospheric scattering. 5. Adds regression tests verifying the bounded inscattering cap under dark interior and window conditions. ## How it was tested - GPU and profile: NVIDIA RTX 5080 / RTX 3070, Series X / Series S profiles, DLSS Quality / Performance, ray tracing off (`VICTORY_AMBIENT=0.8`, `VICTORY_AMBIENT_AIR=1.5`, `VICTORY_AMBIENT_SPECULAR=1`). - Before: Milky haze indoors at night, wardrobe menu left side glowing milky, garage menus obscured by grey fog, and bright green/white halo around interior windows. - After: Dark rooms stay dark and high-contrast; wardrobe menu and mod shop backgrounds remain crisp without milky glow; window transitions render smoothly without halo. - For shader changes, the wave sizes tested: 32-lane and 64-lane waves (hlsl compute pass `clear_air`). - `cargo test` passed for the crates it touches: yes ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches. Related: #1395
Dukestar69 commented 2026-11-29 03:28:47 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Dukestar69 on 2026-11-29T03:28:47Z.

Review: APPROVED


Tested locally merged onto main (568c5e5).

  • Merge: Clean merge in crates/victory-gpu/src/ambient.rs (no new asset-policy violations; only the pre-existing lower.rs size limit on main 568c5e5).
  • Tests (RTX 5090 + WARP): cargo test -p victory-gpu --lib ambient:: passed (12 passed; 0 failed, including the new clear_air_cap_bounds_dark_interiors test) with 0 warnings in ambient.rs.

Clean ambient air inscattering bound for dark interiors. LGTM.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:review:6101241812 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1930#pullrequestreview-6101241812). Originally posted by [Dukestar69](https://github.com/Dukestar69) on 2026-11-29T03:28:47Z. **Review:** APPROVED --- Tested locally merged onto `main` (`568c5e5`). - **Merge**: Clean merge in `crates/victory-gpu/src/ambient.rs` (no new asset-policy violations; only the pre-existing `lower.rs` size limit on `main` `568c5e5`). - **Tests (RTX 5090 + WARP)**: `cargo test -p victory-gpu --lib ambient::` passed (`12 passed; 0 failed`, including the new `clear_air_cap_bounds_dark_interiors` test) with 0 warnings in `ambient.rs`. Clean ambient air inscattering bound for dark interiors. LGTM. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
amazedturnip commented 2026-11-29 05:38:59 +00:00 (Migrated from github.com)

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


Tested on RTX 5070 Ti 16 GB (Series X 1440p DLSS, RT off, VICTORY_AMBIENT=0.8 / AMBIENT_AIR=1.5 / AMBIENT_SPECULAR=1). Noticeably cleans up the washed-out interior ambient veil with zero visual artifacts across 20+ min play.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7251377984 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1930#issuecomment-7251377984). Originally posted by [amazedturnip](https://github.com/amazedturnip) on 2026-11-29T05:38:59Z. --- Tested on RTX 5070 Ti 16 GB (Series X 1440p DLSS, RT off, VICTORY_AMBIENT=0.8 / AMBIENT_AIR=1.5 / AMBIENT_SPECULAR=1). Noticeably cleans up the washed-out interior ambient veil with zero visual artifacts across 20+ min play.
Yoshi-233 commented 2026-11-29 09:45:59 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Yoshi-233 on 2026-11-29T09:45:59Z.


I tested this PR’s near-slice cap by porting the formula to an instrumented v2026.11.28.01 player build and alternating the two formulas every 10 seconds in the same process. Both paths dispatched. This is a daylight living-room sample on an RTX 4070 Ti SUPER, Series X, 2560×1440→3840×2160, DLSS Quality, 2× frame generation, BVH off, VICTORY_AMBIENT=1.

Fixed view Original formula Proposed formula
Hall, wood-floor luminance (0–255) 95.25 94.83
Hall, cabinet luminance (0–255) 37.48 37.60
Facing the window, bright-pane pixels with all channels ≥245 92.59% 92.59%

The hall had four complete intervals per setting. The window had two original and three proposed intervals. In these views the cap produced little visible change. A darker room where the near-volume input actually hits the cap would make a useful second test. The separate night-house report and the 5070 Ti result above may be covering that case.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7253981414 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1930#issuecomment-7253981414). Originally posted by [Yoshi-233](https://github.com/Yoshi-233) on 2026-11-29T09:45:59Z. --- I tested this PR’s near-slice cap by porting the formula to an instrumented v2026.11.28.01 player build and alternating the two formulas every 10 seconds in the same process. Both paths dispatched. This is a daylight living-room sample on an RTX 4070 Ti SUPER, Series X, 2560×1440→3840×2160, DLSS Quality, 2× frame generation, BVH off, VICTORY_AMBIENT=1. | Fixed view | Original formula | Proposed formula | | --- | ---: | ---: | | Hall, wood-floor luminance (0–255) | 95.25 | 94.83 | | Hall, cabinet luminance (0–255) | 37.48 | 37.60 | | Facing the window, bright-pane pixels with all channels ≥245 | 92.59% | 92.59% | The hall had four complete intervals per setting. The window had two original and three proposed intervals. In these views the cap produced little visible change. A darker room where the near-volume input actually hits the cap would make a useful second test. The separate night-house report and the 5070 Ti result above may be covering that case.
dheerajc8073 commented 2026-11-29 16:29:02 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by dheerajc8073 on 2026-11-29T16:29:02Z.


Thank you @Dukestar69 for the review and test verification on RTX 5090 + WARP, and thank you @amazedturnip and @Yoshi-233 for the thorough in-game and benchmark testing!

The data from @Yoshi-233 confirms the intended design: in bright daylight halls and sunlit windows, surface luminance is sufficiently high that the near-slice cap does not restrict inscattering (preserving luminance within ~0.4%), whereas in dark interiors, garages, and night scenes, it successfully caps the sky probe inscattering that previously caused the milky veil as confirmed by @amazedturnip. Ready for merge whenever maintainers are ready.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7258938766 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1930#issuecomment-7258938766). Originally posted by [dheerajc8073](https://github.com/dheerajc8073) on 2026-11-29T16:29:02Z. --- Thank you @Dukestar69 for the review and test verification on RTX 5090 + WARP, and thank you @amazedturnip and @Yoshi-233 for the thorough in-game and benchmark testing! The data from @Yoshi-233 confirms the intended design: in bright daylight halls and sunlit windows, surface luminance is sufficiently high that the near-slice cap does not restrict inscattering (preserving luminance within ~0.4%), whereas in dark interiors, garages, and night scenes, it successfully caps the sky probe inscattering that previously caused the milky veil as confirmed by @amazedturnip. Ready for merge whenever maintainers are ready.
nick0451 commented 2026-11-30 09:21:51 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by nick0451 on 2026-11-30T09:21:51Z.


Tested in game on interiors with RT off: a restaurant with street windows and the barbershop next door, in the city. Series S, DLSS performance, frame generation off. RTX 3090 24 GB, i9-14900K, 32 GB. A player walked the rooms while I took stills and 10-frame bursts.

Builds: v2026.11.29.05 (41adb551) against the same with this PR merged (23e8243c). victory play defaults, so VICTORY_AMBIENT=0.8 and VICTORY_AMBIENT_AIR=1.

  • Restaurant, facing the street windows:
    • Release: the room blows out to a near-white haze; people and furniture fade into it.
    • This PR: the room stays readable, with sunlight on the floor and a mild glow near the glass.
  • Barbershop:
    • Release: a milky white haze over the whole room, and the mirrors show a flat brown blur.
    • This PR: the haze is mostly gone, with a little glow from the open street door. The mirror reflects again: the room, the barber chair and the warm light are visible in it.
    • So the "mirror without a reflection" was this haze filling the mirror's view, not missing reflections.
    • (Added after the player's review.) The player thinks the barbershop's bright glare from its light bars is the game's intended look, so the room's brightness there is not a defect. The difference this PR makes in that room is the mirror.
  • No crashes in either session.

The floating white dust specks in the same rooms are a separate thing that this PR leaves alone. #2156's opt-in removes them, so the two complement each other.

🤖 Generated with Claude Code

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7274103927 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1930#issuecomment-7274103927). Originally posted by [nick0451](https://github.com/nick0451) on 2026-11-30T09:21:51Z. --- Tested in game on interiors with RT off: a restaurant with street windows and the barbershop next door, in the city. Series S, DLSS performance, frame generation off. RTX 3090 24 GB, i9-14900K, 32 GB. A player walked the rooms while I took stills and 10-frame bursts. Builds: v2026.11.29.05 (`41adb551`) against the same with this PR merged (`23e8243c`). `victory play` defaults, so `VICTORY_AMBIENT=0.8` and `VICTORY_AMBIENT_AIR=1`. - **Restaurant, facing the street windows:** - Release: the room blows out to a near-white haze; people and furniture fade into it. - This PR: the room stays readable, with sunlight on the floor and a mild glow near the glass. - **Barbershop:** - Release: a milky white haze over the whole room, and **the mirrors show a flat brown blur.** - This PR: the haze is mostly gone, with a little glow from the open street door. **The mirror reflects again:** the room, the barber chair and the warm light are visible in it. - So the "mirror without a reflection" was this haze filling the mirror's view, not missing reflections. - *(Added after the player's review.)* The player thinks the barbershop's bright glare from its light bars is the game's intended look, so the room's brightness there is not a defect. The difference this PR makes in that room is the mirror. - No crashes in either session. The floating white dust specks in the same rooms are a separate thing that this PR leaves alone. #2156's opt-in removes them, so the two complement each other. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
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!1930
No description provided.