Viewer: screen-space ray march for hair diffuse ambient #430

Manually merged
github merged 1 commit from github-bot/gh-430 into gh-pr/430/base 2026-11-27 03:03:07 +00:00 AGit
Owner

@⁠holdmysocks on GitHub · 2026-11-27 01:15 UTC · original
holdmysocks:claude/hair-gi-occlusion → master · +70 −1 · 1 files · 1 commits · merged 2026-11-27 02:57 UTC

What

Hair's diffuse ambient now goes through a port of the game's screen-space ray march. Before this change it was unoccluded sky light around the strand tangent.

The game's method (read from its passes)

The game's diffuse ambient is screen-probe GI plus a final gather.

  • Hair pixels host probes oriented by the strand tangent, and the final gather is a cosine (Lambert) lobe about that tangent.
  • Each probe ray is first marched on screen through the depth buffer:
    • Ray length is the view depth, capped at 1 m at character range.
    • 8 taps at (k+1+r)/8 along the ray, where r is a per-ray jitter.
    • The crossing is refined linearly between taps.
    • A crossing counts as a hit only within half of one step's change in device depth.
  • A ray the march doesn't stop goes on into the game's world-space ray trace.
  • The bent-cone pass also covers hair pixels, but no hair lighting program reads its result, so it isn't ported.

Port

  • What runs: 4 cosine-weighted rays about the tangent per frame; the viewer's frame accumulation averages them.
  • Blocked rays: take one bounce off the hair (albedo × open light). This stands in for the game's previous-frame radiance at the hit point.
  • Open rays: keep the sky ambient. The viewer has no world-space trace to carry them further.

Before and after (Mandy, the reference-match setup, indoor and outdoor)

  • Indoor: visible darkening in the curls, the folds of the lengths and at the parting.
    • Up to 18/255, about 2/255 averaged over the hair.
    • Region means (sRGB 0–255), before → after: crown 87.2 → 86.8, inner hair left 36.5 → 34.5, lengths left 60.1 → 58.0.
  • Outdoor: almost no change (mean 0.03/255).
  • Diagnostic upper bound (not in this PR): counting every too-deep crossing as blocked, roughly what a world-space trace could add, moves the crown only to 85.9.
    • So under these sunlit setups, the darker crown and parting in the game frames are not explained by occlusion of the diffuse ambient. They need a different cause.

Confidence

  • March structure: high.
  • Its parameters (8 taps, 0.5 thickness, the 1 m cap): medium.
  • One-bounce radiance stand-in: low.
  • Ray direction selection (the game picks equal-area octahedral directions per probe): not ported.
  • Not known: the probe-to-pixel upscale weights, and the length cap past 1 m.

Hair drawn through the standard BSDF path also uses the tangent here. In the game, its probes would use the normal; that is unchanged.

**@⁠holdmysocks** on GitHub · 2026-11-27 01:15 UTC · [original](https://github.com/holdmysocks/SixNG/pull/430) `holdmysocks:claude/hair-gi-occlusion` → `master` · +70 −1 · 1 files · 1 commits · merged 2026-11-27 02:57 UTC ## What Hair's diffuse ambient now goes through a port of the game's screen-space ray march. Before this change it was unoccluded sky light around the strand tangent. ## The game's method (read from its passes) The game's diffuse ambient is screen-probe GI plus a final gather. - Hair pixels host probes oriented by the strand tangent, and the final gather is a cosine (Lambert) lobe about that tangent. - Each probe ray is first marched on screen through the depth buffer: - Ray length is the view depth, capped at 1 m at character range. - 8 taps at (k+1+r)/8 along the ray, where r is a per-ray jitter. - The crossing is refined linearly between taps. - A crossing counts as a hit only within half of one step's change in device depth. - A ray the march doesn't stop goes on into the game's world-space ray trace. - The bent-cone pass also covers hair pixels, but no hair lighting program reads its result, so it isn't ported. ## Port - **What runs:** 4 cosine-weighted rays about the tangent per frame; the viewer's frame accumulation averages them. - **Blocked rays:** take one bounce off the hair (albedo × open light). This stands in for the game's previous-frame radiance at the hit point. - **Open rays:** keep the sky ambient. The viewer has no world-space trace to carry them further. ## Before and after (Mandy, the reference-match setup, indoor and outdoor) - **Indoor:** visible darkening in the curls, the folds of the lengths and at the parting. - Up to 18/255, about 2/255 averaged over the hair. - Region means (sRGB 0–255), before → after: crown 87.2 → 86.8, inner hair left 36.5 → 34.5, lengths left 60.1 → 58.0. - **Outdoor:** almost no change (mean 0.03/255). - **Diagnostic upper bound** (not in this PR): counting every too-deep crossing as blocked, roughly what a world-space trace could add, moves the crown only to 85.9. - So under these sunlit setups, the darker crown and parting in the game frames are not explained by occlusion of the diffuse ambient. They need a different cause. ## Confidence - March structure: high. - Its parameters (8 taps, 0.5 thickness, the 1 m cap): medium. - One-bounce radiance stand-in: low. - Ray direction selection (the game picks equal-area octahedral directions per probe): not ported. - Not known: the probe-to-pixel upscale weights, and the length cap past 1 m. Hair drawn through the standard BSDF path also uses the tangent here. In the game, its probes would use the normal; that is unchanged.
The game's diffuse ambient for hair comes from screen probes oriented by
the strand tangent; each probe ray is first marched on screen through the
depth buffer. Port that march (8 taps, jittered start, linear refinement,
half-step thickness test, ray length = view depth capped at 1 m) for 4
cosine-weighted rays about the tangent per frame. Blocked rays take one
bounce off the hair (albedo x open light) in place of the game's
previous-frame radiance; rays the march leaves open keep the sky ambient,
since the viewer has no world-space trace to continue them.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 01:27:36 +00:00
github-bot changed target branch from master to gh-pr/430/base 2026-11-27 03:03:04 +00:00
github manually merged commit fab321ae71 into gh-pr/430/base 2026-11-27 03:03:07 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.