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

Manually merged
github merged 1 commit from github-bot/gh-1930 into main 2026-11-30 14:14:58 +00:00 AGit
Owner

@⁠dheerajc8073 on GitHub · 2026-11-29 03:10 UTC · original
dheerajc8073:fix/ambient-air-indoor-haze → main · +42 −2 · 1 files · 1 commits · merged 2026-11-30 14:12 UTC

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
**@⁠dheerajc8073** on GitHub · 2026-11-29 03:10 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1930) `dheerajc8073:fix/ambient-air-indoor-haze` → `main` · +42 −2 · 1 files · 1 commits · merged 2026-11-30 14:12 UTC 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
In clear_air (CS_AccumulateLocalLightInscatteringVolume post-pass),
volumetric inscattering is capped to prevent sky probes from flooding
interior rooms with daylight haze when ray tracing is off.

Previously, clear_air computed:
  float cap = air * lerp(dot(cells[CELLS].rgb, LUMA), dot(seen_there, LUMA), far);

Because far is 0 at near camera slices, cap evaluated to air * cells[CELLS]
near the camera. In dark interiors (e.g. Jason's house at night, garages,
showers) and menus (wardrobe, mod shop), 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 scene contrast (#1395).

Bound the near-field ambient light by min(cells_luma, seen_luma) so the
air cap in front of a dark surface cannot exceed the surface light in that
direction. Looking out towards bright windows smoothly interpolates from
room light to window light as far increases, while preserving daylight
haze and sunbeams outdoors.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-29 03:12:24 +00:00
Author
Owner

@⁠Dukestar69 on GitHub · 2026-11-29 03:28 UTC · original · approved these changes

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).

**@⁠Dukestar69** on GitHub · 2026-11-29 03:28 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1930#pullrequestreview-6101241812) · **approved these changes** 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).
Author
Owner

@⁠amazedturnip on GitHub · 2026-11-29 05:38 UTC · original

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.

**@⁠amazedturnip** on GitHub · 2026-11-29 05:38 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1930#issuecomment-7251377984) 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.
Author
Owner

@⁠Yoshi-233 on GitHub · 2026-11-29 09:45 UTC · original

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.

**@⁠Yoshi-233** on GitHub · 2026-11-29 09:45 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1930#issuecomment-7253981414) 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.
Author
Owner

@⁠dheerajc8073 on GitHub · 2026-11-29 16:29 UTC · original

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.

**@⁠dheerajc8073** on GitHub · 2026-11-29 16:29 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1930#issuecomment-7258938766) 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.
Author
Owner

@⁠nick0451 on GitHub · 2026-11-30 09:21 UTC · original · edited 2026-11-30 09:22 UTC

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

**@⁠nick0451** on GitHub · 2026-11-30 09:21 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1930#issuecomment-7274103927) · edited 2026-11-30 09:22 UTC 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)
github manually merged commit 12535884e5 into main 2026-11-30 14:14:58 +00:00
This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/trustno1-coder--VIctory-NVIDIA!1930
No description provided.