#1623: Blend layers lit from resolved visibility; the front layer fills the GI cache #1630

Closed
TheSlowly wants to merge 0 commits from TheSlowly/Slipstream:blend-front-layer into main
Collaborator

Fixes #1623; the rest of #1499 (closed, but the cloud mosaic remained).

  • #1499: the front blend layer is now a GI receiver (RenderVKGILayerFill, 1 texel in 8 a frame, per-group hashed phase): surfaces only a blend layer occupies get their own cache cells instead of falling back cell by cell. The hashed phase matters: a screen-wide pattern biased all cells of a region the same way, the change test read that as a light change and held the cloud in one-frame means (stuck specks).
  • #1623: pass 14 resolves the front layer's sun / local-light / occlusion visibility over frames (RenderVKBlendFrontLight); forward fragments of that layer read it instead of tracing their own rays (plane depth test against the half-res records). Deeper layers borrow it by visible weight (RenderVKBlendLayerReuse, per preset: Ultra 0 .. Low 1) and, with RenderVKBlendLayerGI, its resolved GI.

At a blend-heavy spot (cloud): front-layer path -1.4 ms, fill +0.4 ms; the cloud's black mosaic, the stuck specks and the overlap halo are gone in-world. uRtFwd grows from 10 to 15 half-res regions (+13 MB) -- this touches pass 14, so it overlaps with the RT reflection work.

Fixes #1623; the rest of #1499 (closed, but the cloud mosaic remained). - #1499: the front blend layer is now a GI receiver (RenderVKGILayerFill, 1 texel in 8 a frame, per-group hashed phase): surfaces only a blend layer occupies get their own cache cells instead of falling back cell by cell. The hashed phase matters: a screen-wide pattern biased all cells of a region the same way, the change test read that as a light change and held the cloud in one-frame means (stuck specks). - #1623: pass 14 resolves the front layer's sun / local-light / occlusion visibility over frames (RenderVKBlendFrontLight); forward fragments of that layer read it instead of tracing their own rays (plane depth test against the half-res records). Deeper layers borrow it by visible weight (RenderVKBlendLayerReuse, per preset: Ultra 0 .. Low 1) and, with RenderVKBlendLayerGI, its resolved GI. At a blend-heavy spot (cloud): front-layer path -1.4 ms, fill +0.4 ms; the cloud's black mosaic, the stuck specks and the overlap halo are gone in-world. uRtFwd grows from 10 to 15 half-res regions (+13 MB) -- this touches pass 14, so it overlaps with the RT reflection work.
The radiance cache was filled by the opaque G-buffer's GI texels only, and
its cells are keyed by the normal's dominant axis, so a surface only an
alpha-blend layer occupies (a cloud's underside, a pane away from a wall)
had cells in patches. The layer's forward read fell back cell by cell to
the mirror-ray occlusion, which hits nearby ground: the static light / dark
mosaic.

A new GI stage (-DCLEAN_GI_LAYER, recordGILayers, before the cache's
resolve) makes the front layer a receiver: per frame one half-resolution
texel of each 2 x 2 finds the front blend layer along pass 14's block ray,
traces one cosine ray from it with the GI trace's hit shading and adds the
estimate to the layer point's cell. RenderVKGILayerFill (default on) is the
A/B; GPU timer c_gi_layer / g_gi_layer.
RenderVKBlendHitLighting traced up to ~10 rays per blended layer per
frame with no history (~5 ms at ~3 layers per pixel in a town scene).

Pass 14 (the RT forward pass, which already finds the front blend layer
per half-resolution texel and resolves its reflection and GI) now also
resolves THE LAYER'S LIGHT over frames: the sun visibility, the local
lights' shadowed / unshadowed ratio (the hit walk twice over the same
picks; rtrProjRay's g_rtr_novis) and the occlusion ray, plus the layer's
alpha -- rows [10 h, 15 h) of uRtFwd (RFT_REGIONS 15). The forward FS lights
the front layer with its own unshadowed walk x that ratio, the resolved sun
and occlusion: no rays. A layer behind it whose visible weight (alpha x
(1 - the front alpha)) is under RenderVKBlendLayerReuse takes the front
layer's terms; the rest trace as before. The presets set the threshold
(Ultra 0 .. Low 1). RenderVKBlendFrontLight (default on) is the A/B.
Measured on the cloud (bridge, 2026-11-19): the front-layer light saved
1.6 ms of the blended pass's 11.2, but 6.5 ms remained even with every
deeper layer reusing, against 4.3 ms with the per-layer rays off; the
cache fill cost 0.65 ms; white specks / patches flickered on the cloud
with GI on (not from the hit lighting: on, off and the front path alike).

- rtFwdLightIn: a fragment whose 2 x 2 has no matching record takes the
  same layer's records of the 4 x 4 around (a leaf beside a hole pass 14's
  block ray passed through); a record BEHIND the fragment no longer counts
  as "in front" (the fragment then lay in front of the recorded layer and
  borrowed a surface behind it).
- RenderVKBlendLayerGI (default on): a deeper layer that takes the front
  layer's light terms takes its resolved GI too, not the raw cache cells.
- The cache fill traces one half-resolution texel in 8 a frame (every
  texel once in 8 frames), not one in 4.
The fill's checkerboard (swapping every 4 frames, every group's texel in
step) gave every cell its samples from the same sub-positions on the same
frames: a bias along the light's gradient, the same sign across a region
for 4 frames running. The cache's change test sums cell departures as
independent, so it read that as a light change and held the region
CHANGED (one-frame means, re-armed each swap): a cloud underside stuck
flickering in cell-sized light / dark specks until the cache was reset.
Each 2x2 group now runs its own hashed phase of 8; coverage and cost unchanged.
rtFwdLightIn matched records by view depth within 2 % + 5 cm (~35 cm at
15 m). Two layers that close (a cloud's upper puff over its body) took
each other's sun visibility: a bright line along the overlap. The
fragment's view-depth slope (set in clean_draw.frag next to
g_shadow_ng) now predicts its plane's depth at each record's block ray;
the tolerance is 0.4 % + 2 cm + half a pixel of slope.
Author
Collaborator

Merged into main in fedb692509; closing.

Merged into main in fedb692509; closing.
TheSlowly closed this pull request 2026-11-22 03:07:44 +00:00

Pull request closed

Sign in to join this conversation.
No reviewers
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!1630
No description provided.