RT shadows: shadow terminator artifacts on smooth-shaded low-poly mesh (triangles fill stepwise) -- Hanika offset for all RT shadow rays #664

Closed
opened 2026-10-11 04:00:16 +00:00 by sky_line · 2 comments
Owner

Ray-traced shadows on smooth-shaded low-poly mesh (avatar legs, rigged bodies, sculpties) step along the triangles. Near the terminator, where the surface turns away from the light, whole triangles fill with shadow one at a time, from one side to the other. Dotted lines also appear along triangle edges from the soft-shadow samples. Seen in-world on a pony avatar's legs lit by an RT projector.

Cause: the shadow terminator problem

  • Shading uses the interpolated vertex normal, i.e. a smooth curve.
  • The shadow ray starts on the flat triangle. Near the terminator, a ray leaving one flat facet toward the light hits the neighbouring facet, which bulges above the flat plane, and reports shadow.
  • We already have sun-only mitigations: RenderVKSunTerminatorSoften (Chiang, Li & Burley 2019) and RenderVKRTShadowTerminatorFloor, which lifts soft-disc rays near the terminator. Projector RT shadows, and probably RT point/probe rays, appear to have neither.

Fix: Hanika, "Hacking the Shadow Terminator" (Ray Tracing Gems II, ch. 4)

Before tracing, move the shadow-ray origin from the flat triangle onto the smooth surface implied by the vertex normals (projection onto the tangent planes at the three vertices, blended barycentrically). It's cheap, needs no tuning, and is independent of light type. Apply it to sun / moon, projector and any other RT shadow rays (RT shadow mask, the lit pass's ray-query path, god rays if relevant), for both rigged (post-skin positions and normals) and static geometry. Keep the existing sun tweaks only where they still add something, and keep an A/B setting.

Related: #648 (AO facet lines from the per-facet geometric normal). It's the same smooth-vs-faceted mismatch, but in a different pass.

Ray-traced shadows on **smooth-shaded low-poly mesh** (avatar legs, rigged bodies, sculpties) step along the triangles. Near the terminator, where the surface turns away from the light, whole triangles fill with shadow one at a time, from one side to the other. Dotted lines also appear along triangle edges from the soft-shadow samples. Seen in-world on a pony avatar's legs lit by an RT **projector**. ## Cause: the shadow terminator problem - Shading uses the interpolated vertex normal, i.e. a smooth curve. - The shadow ray starts on the **flat** triangle. Near the terminator, a ray leaving one flat facet toward the light hits the neighbouring facet, which bulges above the flat plane, and reports shadow. - We already have sun-only mitigations: `RenderVKSunTerminatorSoften` (Chiang, Li & Burley 2019) and `RenderVKRTShadowTerminatorFloor`, which lifts soft-disc rays near the terminator. Projector RT shadows, and probably RT point/probe rays, appear to have neither. ## Fix: Hanika, "Hacking the Shadow Terminator" (Ray Tracing Gems II, ch. 4) Before tracing, move the shadow-ray origin from the flat triangle onto the smooth surface implied by the vertex normals (projection onto the tangent planes at the three vertices, blended barycentrically). It's cheap, needs no tuning, and is independent of light type. Apply it to sun / moon, projector and any other RT shadow rays (RT shadow mask, the lit pass's ray-query path, god rays if relevant), for both rigged (post-skin positions and normals) and static geometry. Keep the existing sun tweaks only where they still add something, and keep an A/B setting. Related: #648 (AO facet lines from the per-facet geometric normal). It's the same smooth-vs-faceted mismatch, but in a different pass.
sky_line added this to the Slipstream project 2026-10-11 04:00:16 +00:00
Author
Owner

Agent dispatched (Opus).

Agent dispatched (Opus).
Author
Owner

Fixed in 1.3.0 Beta 3: the shadow terminator lift now comes from the exact rasterized triangle (pre-pass), with no triangle-by-triangle filling, crease leaks or seam lines in testing. The grazing fade is off by default.

Fixed in **1.3.0 Beta 3**: the shadow terminator lift now comes from the exact rasterized triangle (pre-pass), with no triangle-by-triangle filling, crease leaks or seam lines in testing. The grazing fade is off by default.
sky_line 2026-10-11 08:53:33 +00:00
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#664
No description provided.