shader - cube arrays sample slices 0's +X face, and compute samples always read mip 0 (causes too-bright reflections and some blocky character shading) #5
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
performance
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/brothernog--rota#5
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@LordLoon on GitHub · 2026-11-27 06:13 UTC · original
AI-assisted issue from my play test and some probe testing
Findings
Three rendering faults in the title on an NVIDIA RTX 4080 SUPER, with the tuned defaults:
Two faults in the translator explain parts of this. Both are reproduced below
1. Cube arrays: every face of a later slice reads slice 0's +X face
On the console, a cube-array sample's face operand is
8 × slice + face.cube_direction(
crates/victory-shader/src/emit/lower.rs:11801, marked as a shortcut) only matches faces 0 to 5.Any other value falls back to the first row of its table (+X), and the slice is dropped. Cube
samples are also only ever emitted as
TextureCube(resource kind 5), neverTextureCubeArray(9).A probe test was run (a compute program,
image_sample_lon a cube whose face f holds f + 1,one cube bound). It reads:
Reflection probes usually live in cube arrays, so every probe after the first shows one face of
probe 0. That fits the wrong, too-bright reflections.
Proposed fix: emit
TextureCubeArraywithslice = floor(face / 8)andface = face mod 8,and create the host's cube SRVs as cube-array views (
NumCubes = 1for a single cube). Acube-array view can show any cube, so one shader form covers both cases.
2. Implicit-LOD samples in compute programs always read level 0
Outside a pixel program,
image_sample(implicit LOD) is lowered to a level-0 read(
lower.rs:11509, marked as a shortcut). The comment there counts 730 compute programs that dothis, among them the G-buffer resolves. The console takes their derivatives from the quad's lanes.
A probe test was run (four lanes of one compute quad sampling a 64² mipped cube, 8 texels apart in
x and 16 in y; each mip holds its own level number). The lanes' coordinates do differ
(
1.5, 1.625, 1.75, 1.875), but every lane reads level 0 on WARP and on hardware, where thefootprint calls for about level 4.
Full-resolution reads where a coarser mip belongs alias. That fits the tiled, sparkly shading on
characters, and it adds to the specular shimmer.
Proposed fix: in compute programs, take the derivatives from the lanes with
QuadReadAcrossX/
QuadReadAcrossY(lane ^ 1, lane ^ 2, as the console pairs them) and sample withSampleGrad.These are suspected, not shown yet:
VICTORY_RT_MISS=0VICTORY_LEAN_MATH=16(or144)VICTORY_F16_NEAREST=1VICTORY_CARD_STEPS=0VICTORY_SHADER_OPT=0Recommend an A/B test
Reproduce - probe tests
The two probe tests are
#[cfg(all(test, windows))]modules built oncube_lod_tests.rsandintersect_tests::build_compute_shader. They can be added as regression tests with the fixesRun them with
```cargo test -p victory-shader --locked --lib cube_ -- --nocapture.@LordLoon on GitHub · 2026-11-27 06:19 UTC · original
Let me know if you need any logs. No crash log was created on my play test, but I may attempt another round later for a larger stress test
@brothernog on GitHub · 2026-11-27 06:25 UTC · original
Thanks, this is a great write-up. Both shortcuts are where you point (
lower.rs:11509for implicit-LOD samples in compute,lower.rs:11801for cube faces past 5), and the probe tests make them easy to check.Some numbers from tonight's runs on an RTX 3050 8 GB that touch the same symptoms:
VICTORY_RT_MISS=0is not usable here: median fps fell from about 10.5 to 7.0, VRAM went to 8.1 GB, and the opening cutscene rendered almost entirely black. SoRT_MISS=1stays for now.VICTORY_CARD_ALL=1(a current default) causes a white flash, a too-dark cutscene and banded shading.VICTORY_CARD_ALL=0withVICTORY_CARD_BUFFERS_MIN_KB=64andVICTORY_TEXTURE_NO_WAIT=1gives the same or better frame rate (10.5-10.7 median) with the right picture. The defaults will change once it is confirmed.VICTORY_CARD_STEPS=0). One lead is that, with rays missing, the diffuse-light resolve leaves stale probe memory in screen tiles (see the top ofambient.rs). Your mip-0 finding is another good candidate for the same look, so both will get an A/B.I'll try your fixes behind switches next to those runs and report back here. A PR with the probe tests as regression tests is very welcome if you'd like to send one.
This comment was AI-assisted.