RT sun shadows: further optimization (shadow-mask pass, reduced-rate tracing, hybrid edges, denoise) #195

Closed
opened 2026-09-30 03:17:38 +00:00 by sky_line · 1 comment
Owner

Follow-up to #185 (pushed up to 75ca3a315c). Current cost on an RTX 5090, same view: cascades 14.8 ms, ray-traced sun 17.2 ms (+2.4 ms: pass 1 +3.1, pass 2 +0.3, cascades -1.85). Already done: 1 ray/pixel + TAA noise, no rays where N.L <= 0, cascades skipped, transparent receivers opaque-only (blend casters excluded), probe/mirror captures unshadowed.

Candidates (roughly by expected win)

  1. Shadow mask pass instead of in-FS rays. Trace sun visibility in a compute pass right after the depth pre-pass (depth + the thin G-buffer normals already exist for AO/motion) into an R8 mask; the lit FS samples it. Coherent compute rays instead of divergent ray queries inside the heavy lit FS (register pressure / occupancy of every lit pixel pays for the RT code), and it unlocks 2-3 below. Transparent / particle receivers keep per-fragment rays (or sample the mask behind them).
  2. Half-resolution / checkerboard tracing + upsample. Trace 1/2 or 1/4 of the pixels (depth/normal-aware upsample), TAA / temporal accumulation fills the rest. Standard for RT shadows; ~2-4x fewer rays.
  3. Hybrid: trace only near shadow edges (AMD FidelityFX Hybrid Shadows): a cheap low-res cascade (or last frame's mask) classifies tiles as fully lit / fully shadowed; rays only for tiles with an edge. Most of the screen is uniformly lit or in shadow.
  4. Temporal accumulation + denoiser (#85): fewer rays per frame for the same soft penumbra; also removes the reliance on TAA for convergence.
  5. Hardware alpha test: opacity micromaps (#194) -- ~1.3 ms of the cost is the per-leaf candidate alpha test.
  6. Shorter rays / smaller TLAS for the sun: tmax from the shadow range and the RT radius instead of 1024 m; optionally a sun-specific instance selection (light-space extruded view volume) so the sun traces a smaller TLAS; check BLAS build flags (PREFER_FAST_TRACE, compaction) on foliage-heavy scenes.
  7. Cheaper transparent-layer rays: one visibility per pixel for stacked alpha (sample the opaque mask behind + a single ray for the front layer) instead of one ray per layer.
  8. Measurement first: sub-timers that isolate the ray-query cost inside pass 1 (a no-trace variant A/B), plus a per-pixel ray-count / candidate-count debug view to see where the cost concentrates (foliage vs open ground).

Goal

RT sun at or below the cascades' cost (so it can become the default on RT hardware), without visible quality loss (leaf-accurate shadows, stable under TAA).

Related: #185, #194, #85, #84, #157, #164.

Follow-up to #185 (pushed up to 75ca3a315c). Current cost on an RTX 5090, same view: cascades **14.8 ms**, ray-traced sun **17.2 ms** (+2.4 ms: pass 1 +3.1, pass 2 +0.3, cascades -1.85). Already done: 1 ray/pixel + TAA noise, no rays where N.L <= 0, cascades skipped, transparent receivers opaque-only (blend casters excluded), probe/mirror captures unshadowed. ### Candidates (roughly by expected win) 1. **Shadow mask pass instead of in-FS rays.** Trace sun visibility in a compute pass right after the depth pre-pass (depth + the thin G-buffer normals already exist for AO/motion) into an R8 mask; the lit FS samples it. Coherent compute rays instead of divergent ray queries inside the heavy lit FS (register pressure / occupancy of every lit pixel pays for the RT code), and it unlocks 2-3 below. Transparent / particle receivers keep per-fragment rays (or sample the mask behind them). 2. **Half-resolution / checkerboard tracing + upsample.** Trace 1/2 or 1/4 of the pixels (depth/normal-aware upsample), TAA / temporal accumulation fills the rest. Standard for RT shadows; ~2-4x fewer rays. 3. **Hybrid: trace only near shadow edges** (AMD FidelityFX Hybrid Shadows): a cheap low-res cascade (or last frame's mask) classifies tiles as fully lit / fully shadowed; rays only for tiles with an edge. Most of the screen is uniformly lit or in shadow. 4. **Temporal accumulation + denoiser** (#85): fewer rays per frame for the same soft penumbra; also removes the reliance on TAA for convergence. 5. **Hardware alpha test: opacity micromaps** (#194) -- ~1.3 ms of the cost is the per-leaf candidate alpha test. 6. **Shorter rays / smaller TLAS for the sun**: tmax from the shadow range and the RT radius instead of 1024 m; optionally a sun-specific instance selection (light-space extruded view volume) so the sun traces a smaller TLAS; check BLAS build flags (PREFER_FAST_TRACE, compaction) on foliage-heavy scenes. 7. **Cheaper transparent-layer rays**: one visibility per pixel for stacked alpha (sample the opaque mask behind + a single ray for the front layer) instead of one ray per layer. 8. **Measurement first**: sub-timers that isolate the ray-query cost inside pass 1 (a no-trace variant A/B), plus a per-pixel ray-count / candidate-count debug view to see where the cost concentrates (foliage vs open ground). ### Goal RT sun at or below the cascades' cost (so it can become the default on RT hardware), without visible quality loss (leaf-accurate shadows, stable under TAA). Related: #185, #194, #85, #84, #157, #164.
sky_line added this to the Slipstream project 2026-10-06 15:04:15 +00:00
Author
Owner

Done: the RT shadow-mask pass, reduced-rate tracing and related optimizations shipped. Remaining shadow work is tracked in #567 (shadow-map parity) and #572.

Done: the RT shadow-mask pass, reduced-rate tracing and related optimizations shipped. Remaining shadow work is tracked in #567 (shadow-map parity) and #572.
Sign in to join this conversation.
No milestone
No project
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
sky_line/Slipstream#195
No description provided.