Commit Graph
3 Commits
Author SHA1 Message Date
Valiantsin DzerakhandClaude Opus 5.5 6ff98e2d61 Contact shadows take the in-image neighbour on the screen border when they find the surface normal
On the border the clamped neighbour is the pixel itself, so the nearer-in-depth pick took a zero difference and
normalize() returned NaN; `lit <= 0.0` is false for NaN, so whether those pixels were marched and what they wrote
depended on how the driver clamps NaN. The border now uses the side inside the image, and a NaN gate skips the march.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 10:05:54 +03:00
itaskaev2andClaude Opus 5.5 a3fee27cfe Leave surfaces turned away from the sun out of the contact shadows
The contact shadow march darkened the whole lit colour of every pixel whose ray toward the sun passed behind
geometry. On a face turned away from the sun the ray runs into that face at once, so every such face within 80 m
was darkened by the full strength, although it gets no direct sunlight to lose: what was darkened was its ambient
light and the fog the composite had already added. In hazy scenes (the Gerudo sandstorm) the shaded rock faces and
the undersides of overhangs showed as dark smoky silhouettes in the haze, and objects such as a wagon lost their
fogged look. The shader now takes the surface normal from the linear depth and scales the shadow by how far the
surface faces the sun: none for faces turned away, a growing share from a grazing angle on.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 23:35:24 +01:00
itaskaev2andClaude Opus 5.5 4af60604de Add screen-space contact shadows
TotK fills a full-resolution G-buffer with a B10G11R11 scene colour, an R32F linear depth and a D32F depth, lights it
in half resolution, and composites the lighting into the scene colour in one pass whose only target is that colour,
with a D16 class depth. vk_contact.c recognises both passes, and when the pass after the composite begins (or a
dispatch or copy comes first) runtime/shaders/contact_shadow.comp marches each pixel 16 steps toward the sun through
the linear depth and darkens the scene colour where nearby geometry blocks the ray: the small shadows at feet, under
stones and in grass that the shadow maps miss. Transparent surfaces, the sky and post-processing come after.

The projection, far plane and sun direction come from the fragment stage's 0x940-byte camera block (c4): c4[7].x,
c4[8].y, c4[14].y, and the first cascade's depth row c4[44].xyz, whose negation points toward the sun. Scene colour
images get STORAGE usage while the setting is on.

contact_shadows (percent strength, default 0) is in totk.ini.example and on the Screen tab of the menu (English and
Russian). TOTK_CONTACT_DEBUG=1 shows the shadow factor in grey instead of the frame. It costs about 0.45 ms per frame
at a 3840x2160 scene on an RTX 4080 SUPER.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-30 15:29:53 +01:00