From 581c1ecdef5fc5d06b0f49bba8df2bbbc56eefe2 Mon Sep 17 00:00:00 2001 From: Specht2010 <485902+Specht2010@users.noreply.github.com> Date: Sun, 1 Nov 2026 17:59:29 -0400 Subject: [PATCH 1/2] Darken only sunlit pixels with contact shadows The half-resolution lighting pass the composite reads keeps the sun's visibility in its first target's alpha: 1 in the sun, 0 in the shadow maps' shadow and everywhere underground. vk_contact.c finds that pass (eight targets at half the scene size, the first RGBA8) and contact_shadow.comp scales its darkening by that alpha, so a contact shadow takes away direct sunlight only and caves no longer turn flat. Without that pass in the frame the old behaviour stays. TOTK_CONTACT_DEBUG=2 shows the visibility in grey. Carried onto dev from #439: the march is now planned by the scan (vk_contact_plan) and recorded from a VkExecJob, so the lighting target travels in the job's new sun field, and the factor multiplies the facing-the-sun factor of the back-face fix. Co-Authored-By: itaskaev2 <165683571+itaskaev2@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 --- docs/settings.md | 2 +- runtime/contact_shadow_spv.h | 417 +++++++++++++++------------- runtime/shaders/contact_shadow.comp | 13 +- runtime/vk_contact.c | 57 +++- runtime/vk_exec.h | 2 + 5 files changed, 276 insertions(+), 215 deletions(-) diff --git a/docs/settings.md b/docs/settings.md index 1b0193fe..1d23673e 100644 --- a/docs/settings.md +++ b/docs/settings.md @@ -20,7 +20,7 @@ Many rows below are developer tools that only act together with another setting | --- | --- | --- | --- | | `astc_time` | `1` times the GPU dispatches of each ASTC texture decode and logs the time per block footprint and the largest call. | Adds GPU timestamp queries around every decode; if the queue has no timestamps or no `hostQueryReset`, the log says the decodes are not timed and nothing is measured. | Caution | | `bind_stats` | `1` counts bindings and descriptors per draw of each stage and how much of the bound state changes between draws. | Adds per-draw bookkeeping to the render thread and extra log output; frames get slower. | Caution | -| `contact_debug` | `1` draws the contact-shadow factor in grey in place of the picture. | The frame shows a grey debug image while it is set; has no effect when contact shadows are off. | Caution | +| `contact_debug` | `1` draws the contact-shadow factor in grey in place of the picture; `2` draws the sun visibility the shadows are scaled by (white in the sun, black in shade and underground). | The frame shows a grey debug image while it is set; has no effect when contact shadows are off. | Caution | | `core_diag` | `1` records why ready guest threads wait for a virtual core and for how long, with a histogram every 60 presents. | Turns on host-call and SVC depth tracking and writes many log lines (one per present over 25 ms); frames get slower. | Caution | | `menu_cursor_log` | `1` logs what the menu cursor code reads at every screen change. | Only adds log lines. | Safe | | `perf_slow_ms` (default `50`) | Frames at least this many milliseconds long get a `perf: slow frame` log line with the time blocked per cause. | Changes how many frames are logged; a small value fills the log. | Safe | diff --git a/runtime/contact_shadow_spv.h b/runtime/contact_shadow_spv.h index a89c3faa..dd0d1578 100644 --- a/runtime/contact_shadow_spv.h +++ b/runtime/contact_shadow_spv.h @@ -1,9 +1,9 @@ // Generated by tools/build_shaders.py from runtime/shaders/contact_shadow.comp; do not edit. -// source sha256 88275d28f96ea19281dbcd08a440ff79821716210894596ffb05ba7bc572dc9a +// source sha256 e44a73a42aed3d5c2ac3a0a7e8809234f6175f8e331d30f93331ae9ca32fda71 #pragma once #include static const uint32_t contact_shadow_spv[] = { - 0x07230203, 0x00010300, 0x000d000b, 0x000003e4, 0x00000000, 0x00020011, 0x00000001, 0x00020011, + 0x07230203, 0x00010300, 0x000d000b, 0x0000040b, 0x00000000, 0x00020011, 0x00000001, 0x00020011, 0x00000031, 0x0006000b, 0x00000001, 0x4c534c47, 0x6474732e, 0x3035342e, 0x00000000, 0x0003000e, 0x00000000, 0x00000001, 0x0006000f, 0x00000005, 0x00000004, 0x6e69616d, 0x00000000, 0x0000011f, 0x00060010, 0x00000004, 0x00000011, 0x00000008, 0x00000008, 0x00000001, 0x00030047, 0x00000033, @@ -11,8 +11,9 @@ static const uint32_t contact_shadow_spv[] = { 0x00000001, 0x00000023, 0x00000010, 0x00050048, 0x00000033, 0x00000002, 0x00000023, 0x00000020, 0x00050048, 0x00000033, 0x00000003, 0x00000023, 0x00000030, 0x00040047, 0x00000086, 0x00000021, 0x00000000, 0x00040047, 0x00000086, 0x00000022, 0x00000000, 0x00040047, 0x0000011f, 0x0000000b, - 0x0000001c, 0x00040047, 0x000001ff, 0x00000021, 0x00000001, 0x00040047, 0x000001ff, 0x00000022, - 0x00000000, 0x00040047, 0x0000021c, 0x0000000b, 0x00000019, 0x00020013, 0x00000002, 0x00030021, + 0x0000001c, 0x00040047, 0x00000162, 0x00000021, 0x00000002, 0x00040047, 0x00000162, 0x00000022, + 0x00000000, 0x00040047, 0x00000172, 0x00000021, 0x00000001, 0x00040047, 0x00000172, 0x00000022, + 0x00000000, 0x00040047, 0x00000242, 0x0000000b, 0x00000019, 0x00020013, 0x00000002, 0x00030021, 0x00000003, 0x00000002, 0x00030016, 0x00000006, 0x00000020, 0x00040017, 0x00000007, 0x00000006, 0x00000002, 0x00040017, 0x0000000a, 0x00000006, 0x00000003, 0x00040015, 0x00000019, 0x00000020, 0x00000001, 0x00040017, 0x0000001a, 0x00000019, 0x00000002, 0x0004002b, 0x00000006, 0x00000027, @@ -34,22 +35,23 @@ static const uint32_t contact_shadow_spv[] = { 0x00000000, 0x00040017, 0x0000011d, 0x0000002c, 0x00000003, 0x00040020, 0x0000011e, 0x00000001, 0x0000011d, 0x0004003b, 0x0000011e, 0x0000011f, 0x00000001, 0x00040017, 0x00000120, 0x0000002c, 0x00000002, 0x0004002b, 0x00000006, 0x00000140, 0x3f7fbe77, 0x0004002b, 0x00000006, 0x0000014c, - 0x42a00000, 0x0004002b, 0x00000006, 0x00000161, 0x3e99999a, 0x0004002b, 0x0000002c, 0x00000173, - 0x00000003, 0x0004002b, 0x00000006, 0x00000179, 0x3ecccccd, 0x0004002b, 0x00000006, 0x0000017a, - 0x40400000, 0x0004002b, 0x00000006, 0x0000017e, 0x3e19999a, 0x0004002b, 0x00000006, 0x00000180, - 0x3c23d70a, 0x0004002b, 0x00000006, 0x00000189, 0x3e800000, 0x0004002b, 0x00000019, 0x00000198, - 0x00000010, 0x0004002b, 0x00000006, 0x000001a4, 0xbd4ccccd, 0x0005002c, 0x00000007, 0x000001ae, - 0x00000110, 0x00000110, 0x00040017, 0x000001af, 0x000000b1, 0x00000002, 0x0005002c, 0x00000007, - 0x000001b6, 0x00000029, 0x00000029, 0x0004002b, 0x00000006, 0x000001d2, 0x3ca3d70a, 0x0004002b, - 0x00000006, 0x000001d4, 0x3b03126f, 0x0004002b, 0x00000006, 0x000001e9, 0x42200000, 0x0004002b, - 0x00000019, 0x000001f7, 0x00000003, 0x00090019, 0x000001fd, 0x00000006, 0x00000001, 0x00000000, - 0x00000000, 0x00000000, 0x00000002, 0x00000008, 0x00040020, 0x000001fe, 0x00000000, 0x000001fd, - 0x0004003b, 0x000001fe, 0x000001ff, 0x00000000, 0x0004002b, 0x0000002c, 0x0000021b, 0x00000008, - 0x0006002c, 0x0000011d, 0x0000021c, 0x0000021b, 0x0000021b, 0x0000003b, 0x0005002c, 0x00000007, - 0x000003df, 0x0000004e, 0x0000004e, 0x0005002c, 0x0000001a, 0x000003e0, 0x00000077, 0x00000077, - 0x0004002b, 0x00000006, 0x000003e2, 0x3dcccccd, 0x0004002b, 0x00000006, 0x000003e3, 0x3d800000, + 0x42a00000, 0x0004002b, 0x00000019, 0x0000015b, 0x00000003, 0x0004003b, 0x00000085, 0x00000162, + 0x00000000, 0x0004002b, 0x0000002c, 0x00000166, 0x00000003, 0x0004002b, 0x00000006, 0x0000016c, + 0x3fc00000, 0x00090019, 0x00000170, 0x00000006, 0x00000001, 0x00000000, 0x00000000, 0x00000000, + 0x00000002, 0x00000008, 0x00040020, 0x00000171, 0x00000000, 0x00000170, 0x0004003b, 0x00000171, + 0x00000172, 0x00000000, 0x0004002b, 0x00000006, 0x0000018a, 0x3e99999a, 0x0004002b, 0x00000006, + 0x000001a1, 0x3ecccccd, 0x0004002b, 0x00000006, 0x000001a2, 0x40400000, 0x0004002b, 0x00000006, + 0x000001a6, 0x3e19999a, 0x0004002b, 0x00000006, 0x000001a8, 0x3c23d70a, 0x0004002b, 0x00000006, + 0x000001b1, 0x3e800000, 0x0004002b, 0x00000019, 0x000001c0, 0x00000010, 0x0004002b, 0x00000006, + 0x000001cc, 0xbd4ccccd, 0x0005002c, 0x00000007, 0x000001d6, 0x00000110, 0x00000110, 0x00040017, + 0x000001d7, 0x000000b1, 0x00000002, 0x0005002c, 0x00000007, 0x000001de, 0x00000029, 0x00000029, + 0x0004002b, 0x00000006, 0x000001fa, 0x3ca3d70a, 0x0004002b, 0x00000006, 0x000001fc, 0x3b03126f, + 0x0004002b, 0x00000006, 0x00000211, 0x42200000, 0x0004002b, 0x0000002c, 0x00000241, 0x00000008, + 0x0006002c, 0x0000011d, 0x00000242, 0x00000241, 0x00000241, 0x0000003b, 0x0005002c, 0x00000007, + 0x00000406, 0x0000004e, 0x0000004e, 0x0005002c, 0x0000001a, 0x00000407, 0x00000077, 0x00000077, + 0x0004002b, 0x00000006, 0x00000409, 0x3dcccccd, 0x0004002b, 0x00000006, 0x0000040a, 0x3d800000, 0x00050036, 0x00000002, 0x00000004, 0x00000000, 0x00000003, 0x000200f8, 0x00000005, 0x000300f7, - 0x0000021d, 0x00000000, 0x000300fb, 0x0000002d, 0x0000021e, 0x000200f8, 0x0000021e, 0x0004003d, + 0x00000243, 0x00000000, 0x000300fb, 0x0000002d, 0x00000244, 0x000200f8, 0x00000244, 0x0004003d, 0x0000011d, 0x00000121, 0x0000011f, 0x0007004f, 0x00000120, 0x00000122, 0x00000121, 0x00000121, 0x00000000, 0x00000001, 0x0004007c, 0x0000001a, 0x00000123, 0x00000122, 0x00050051, 0x00000019, 0x00000125, 0x00000123, 0x00000000, 0x00060041, 0x00000037, 0x00000126, 0x00000035, 0x00000071, @@ -60,196 +62,213 @@ static const uint32_t contact_shadow_spv[] = { 0x00060041, 0x00000037, 0x0000012f, 0x00000035, 0x00000071, 0x0000003b, 0x0004003d, 0x00000006, 0x00000130, 0x0000012f, 0x0004006e, 0x00000019, 0x00000131, 0x00000130, 0x000500af, 0x000000b1, 0x00000132, 0x0000012e, 0x00000131, 0x000200f9, 0x0000012c, 0x000200f8, 0x0000012c, 0x000700f5, - 0x000000b1, 0x00000133, 0x00000129, 0x0000021e, 0x00000132, 0x0000012b, 0x000300f7, 0x00000135, + 0x000000b1, 0x00000133, 0x00000129, 0x00000244, 0x00000132, 0x0000012b, 0x000300f7, 0x00000135, 0x00000000, 0x000400fa, 0x00000133, 0x00000134, 0x00000135, 0x000200f8, 0x00000134, 0x000200f9, - 0x0000021d, 0x000200f8, 0x00000135, 0x0004003d, 0x00000084, 0x00000138, 0x00000086, 0x00040064, + 0x00000243, 0x000200f8, 0x00000135, 0x0004003d, 0x00000084, 0x00000138, 0x00000086, 0x00040064, 0x00000083, 0x0000013a, 0x00000138, 0x0007005f, 0x00000032, 0x0000013b, 0x0000013a, 0x00000123, 0x00000002, 0x00000036, 0x00050051, 0x00000006, 0x0000013c, 0x0000013b, 0x00000000, 0x000500bc, 0x000000b1, 0x0000013e, 0x0000013c, 0x00000110, 0x000500be, 0x000000b1, 0x00000141, 0x0000013c, 0x00000140, 0x000500a6, 0x000000b1, 0x00000142, 0x0000013e, 0x00000141, 0x000300f7, 0x00000144, 0x00000000, 0x000400fa, 0x00000142, 0x00000143, 0x00000144, 0x000200f8, 0x00000143, 0x000200f9, - 0x0000021d, 0x000200f8, 0x00000144, 0x00060041, 0x00000037, 0x00000148, 0x00000035, 0x00000036, + 0x00000243, 0x000200f8, 0x00000144, 0x00060041, 0x00000037, 0x00000148, 0x00000035, 0x00000036, 0x0000004a, 0x0004003d, 0x00000006, 0x00000149, 0x00000148, 0x00050085, 0x00000006, 0x0000014a, 0x0000013c, 0x00000149, 0x000500ba, 0x000000b1, 0x0000014d, 0x0000014a, 0x0000014c, 0x000300f7, 0x0000014f, 0x00000000, 0x000400fa, 0x0000014d, 0x0000014e, 0x0000014f, 0x000200f8, 0x0000014e, - 0x000200f9, 0x0000021d, 0x000200f8, 0x0000014f, 0x0004006f, 0x00000007, 0x00000153, 0x00000123, - 0x00050081, 0x00000007, 0x00000155, 0x00000153, 0x000003df, 0x00050041, 0x00000072, 0x00000156, + 0x000200f9, 0x00000243, 0x000200f8, 0x0000014f, 0x0004006f, 0x00000007, 0x00000153, 0x00000123, + 0x00050081, 0x00000007, 0x00000155, 0x00000153, 0x00000406, 0x00050041, 0x00000072, 0x00000156, 0x00000035, 0x00000071, 0x0004003d, 0x00000032, 0x00000157, 0x00000156, 0x0007004f, 0x00000007, 0x00000158, 0x00000157, 0x00000157, 0x00000002, 0x00000003, 0x00050085, 0x00000007, 0x00000159, - 0x00000155, 0x00000158, 0x0005008e, 0x00000007, 0x00000226, 0x00000159, 0x00000027, 0x00050083, - 0x00000007, 0x00000228, 0x00000226, 0x000001b6, 0x00050051, 0x00000006, 0x0000022a, 0x00000228, - 0x00000000, 0x00050085, 0x00000006, 0x0000022c, 0x0000022a, 0x0000014a, 0x00060041, 0x00000037, - 0x0000022d, 0x00000035, 0x00000036, 0x0000002d, 0x0004003d, 0x00000006, 0x0000022e, 0x0000022d, - 0x00050088, 0x00000006, 0x0000022f, 0x0000022c, 0x0000022e, 0x00050051, 0x00000006, 0x00000231, - 0x00000228, 0x00000001, 0x0004007f, 0x00000006, 0x00000232, 0x00000231, 0x00050085, 0x00000006, - 0x00000234, 0x00000232, 0x0000014a, 0x00060041, 0x00000037, 0x00000235, 0x00000035, 0x00000036, - 0x0000003b, 0x0004003d, 0x00000006, 0x00000236, 0x00000235, 0x00050088, 0x00000006, 0x00000237, - 0x00000234, 0x00000236, 0x0004007f, 0x00000006, 0x00000239, 0x0000014a, 0x00060050, 0x0000000a, - 0x0000023a, 0x0000022f, 0x00000237, 0x00000239, 0x0007004f, 0x00000007, 0x00000250, 0x00000157, - 0x00000157, 0x00000000, 0x00000001, 0x0004006e, 0x0000001a, 0x00000251, 0x00000250, 0x00050082, - 0x0000001a, 0x00000253, 0x00000251, 0x000003e0, 0x00050082, 0x0000001a, 0x00000255, 0x00000123, - 0x0000009d, 0x0008000c, 0x0000001a, 0x000002c8, 0x00000001, 0x0000002d, 0x00000255, 0x00000070, - 0x00000253, 0x0004006f, 0x00000007, 0x000002ca, 0x000002c8, 0x00050081, 0x00000007, 0x000002cc, - 0x000002ca, 0x000003df, 0x00050085, 0x00000007, 0x000002d0, 0x000002cc, 0x00000158, 0x0004003d, - 0x00000084, 0x000002d1, 0x00000086, 0x00040064, 0x00000083, 0x000002d3, 0x000002d1, 0x0007005f, - 0x00000032, 0x000002d4, 0x000002d3, 0x000002c8, 0x00000002, 0x00000036, 0x00050051, 0x00000006, - 0x000002d5, 0x000002d4, 0x00000000, 0x00050085, 0x00000006, 0x000002d8, 0x000002d5, 0x00000149, - 0x0005008e, 0x00000007, 0x000002de, 0x000002d0, 0x00000027, 0x00050083, 0x00000007, 0x000002e0, - 0x000002de, 0x000001b6, 0x00050051, 0x00000006, 0x000002e2, 0x000002e0, 0x00000000, 0x00050085, - 0x00000006, 0x000002e4, 0x000002e2, 0x000002d8, 0x00050088, 0x00000006, 0x000002e7, 0x000002e4, - 0x0000022e, 0x00050051, 0x00000006, 0x000002e9, 0x000002e0, 0x00000001, 0x0004007f, 0x00000006, - 0x000002ea, 0x000002e9, 0x00050085, 0x00000006, 0x000002ec, 0x000002ea, 0x000002d8, 0x00050088, - 0x00000006, 0x000002ef, 0x000002ec, 0x00000236, 0x0004007f, 0x00000006, 0x000002f1, 0x000002d8, - 0x00060050, 0x0000000a, 0x000002f2, 0x000002e7, 0x000002ef, 0x000002f1, 0x00050080, 0x0000001a, - 0x00000258, 0x00000123, 0x0000009d, 0x0008000c, 0x0000001a, 0x000002fe, 0x00000001, 0x0000002d, - 0x00000258, 0x00000070, 0x00000253, 0x0004006f, 0x00000007, 0x00000300, 0x000002fe, 0x00050081, - 0x00000007, 0x00000302, 0x00000300, 0x000003df, 0x00050085, 0x00000007, 0x00000306, 0x00000302, - 0x00000158, 0x0004003d, 0x00000084, 0x00000307, 0x00000086, 0x00040064, 0x00000083, 0x00000309, - 0x00000307, 0x0007005f, 0x00000032, 0x0000030a, 0x00000309, 0x000002fe, 0x00000002, 0x00000036, - 0x00050051, 0x00000006, 0x0000030b, 0x0000030a, 0x00000000, 0x00050085, 0x00000006, 0x0000030e, - 0x0000030b, 0x00000149, 0x0005008e, 0x00000007, 0x00000314, 0x00000306, 0x00000027, 0x00050083, - 0x00000007, 0x00000316, 0x00000314, 0x000001b6, 0x00050051, 0x00000006, 0x00000318, 0x00000316, - 0x00000000, 0x00050085, 0x00000006, 0x0000031a, 0x00000318, 0x0000030e, 0x00050088, 0x00000006, - 0x0000031d, 0x0000031a, 0x0000022e, 0x00050051, 0x00000006, 0x0000031f, 0x00000316, 0x00000001, - 0x0004007f, 0x00000006, 0x00000320, 0x0000031f, 0x00050085, 0x00000006, 0x00000322, 0x00000320, - 0x0000030e, 0x00050088, 0x00000006, 0x00000325, 0x00000322, 0x00000236, 0x0004007f, 0x00000006, - 0x00000327, 0x0000030e, 0x00060050, 0x0000000a, 0x00000328, 0x0000031d, 0x00000325, 0x00000327, - 0x00050082, 0x0000001a, 0x0000025b, 0x00000123, 0x000000a8, 0x0008000c, 0x0000001a, 0x00000334, - 0x00000001, 0x0000002d, 0x0000025b, 0x00000070, 0x00000253, 0x0004006f, 0x00000007, 0x00000336, - 0x00000334, 0x00050081, 0x00000007, 0x00000338, 0x00000336, 0x000003df, 0x00050085, 0x00000007, - 0x0000033c, 0x00000338, 0x00000158, 0x0004003d, 0x00000084, 0x0000033d, 0x00000086, 0x00040064, - 0x00000083, 0x0000033f, 0x0000033d, 0x0007005f, 0x00000032, 0x00000340, 0x0000033f, 0x00000334, - 0x00000002, 0x00000036, 0x00050051, 0x00000006, 0x00000341, 0x00000340, 0x00000000, 0x00050085, - 0x00000006, 0x00000344, 0x00000341, 0x00000149, 0x0005008e, 0x00000007, 0x0000034a, 0x0000033c, - 0x00000027, 0x00050083, 0x00000007, 0x0000034c, 0x0000034a, 0x000001b6, 0x00050051, 0x00000006, - 0x0000034e, 0x0000034c, 0x00000000, 0x00050085, 0x00000006, 0x00000350, 0x0000034e, 0x00000344, - 0x00050088, 0x00000006, 0x00000353, 0x00000350, 0x0000022e, 0x00050051, 0x00000006, 0x00000355, - 0x0000034c, 0x00000001, 0x0004007f, 0x00000006, 0x00000356, 0x00000355, 0x00050085, 0x00000006, - 0x00000358, 0x00000356, 0x00000344, 0x00050088, 0x00000006, 0x0000035b, 0x00000358, 0x00000236, - 0x0004007f, 0x00000006, 0x0000035d, 0x00000344, 0x00060050, 0x0000000a, 0x0000035e, 0x00000353, - 0x0000035b, 0x0000035d, 0x00050080, 0x0000001a, 0x0000025e, 0x00000123, 0x000000a8, 0x0008000c, - 0x0000001a, 0x0000036a, 0x00000001, 0x0000002d, 0x0000025e, 0x00000070, 0x00000253, 0x0004006f, - 0x00000007, 0x0000036c, 0x0000036a, 0x00050081, 0x00000007, 0x0000036e, 0x0000036c, 0x000003df, - 0x00050085, 0x00000007, 0x00000372, 0x0000036e, 0x00000158, 0x0004003d, 0x00000084, 0x00000373, - 0x00000086, 0x00040064, 0x00000083, 0x00000375, 0x00000373, 0x0007005f, 0x00000032, 0x00000376, - 0x00000375, 0x0000036a, 0x00000002, 0x00000036, 0x00050051, 0x00000006, 0x00000377, 0x00000376, - 0x00000000, 0x00050085, 0x00000006, 0x0000037a, 0x00000377, 0x00000149, 0x0005008e, 0x00000007, - 0x00000380, 0x00000372, 0x00000027, 0x00050083, 0x00000007, 0x00000382, 0x00000380, 0x000001b6, - 0x00050051, 0x00000006, 0x00000384, 0x00000382, 0x00000000, 0x00050085, 0x00000006, 0x00000386, - 0x00000384, 0x0000037a, 0x00050088, 0x00000006, 0x00000389, 0x00000386, 0x0000022e, 0x00050051, - 0x00000006, 0x0000038b, 0x00000382, 0x00000001, 0x0004007f, 0x00000006, 0x0000038c, 0x0000038b, - 0x00050085, 0x00000006, 0x0000038e, 0x0000038c, 0x0000037a, 0x00050088, 0x00000006, 0x00000391, - 0x0000038e, 0x00000236, 0x0004007f, 0x00000006, 0x00000393, 0x0000037a, 0x00060050, 0x0000000a, - 0x00000394, 0x00000389, 0x00000391, 0x00000393, 0x000500aa, 0x000000b1, 0x00000262, 0x00000125, - 0x00000036, 0x000400a8, 0x000000b1, 0x00000263, 0x00000262, 0x000300f7, 0x0000027a, 0x00000000, - 0x000400fa, 0x00000263, 0x00000264, 0x0000027a, 0x000200f8, 0x00000264, 0x00050051, 0x00000019, - 0x00000268, 0x00000253, 0x00000000, 0x000500b1, 0x000000b1, 0x00000269, 0x00000125, 0x00000268, - 0x000300f7, 0x00000278, 0x00000000, 0x000400fa, 0x00000269, 0x0000026a, 0x00000278, 0x000200f8, - 0x0000026a, 0x00050083, 0x00000006, 0x0000026f, 0x0000014a, 0x0000030e, 0x0006000c, 0x00000006, - 0x00000270, 0x00000001, 0x00000004, 0x0000026f, 0x00050083, 0x00000006, 0x00000275, 0x000002d8, - 0x0000014a, 0x0006000c, 0x00000006, 0x00000276, 0x00000001, 0x00000004, 0x00000275, 0x000500b8, - 0x000000b1, 0x00000277, 0x00000270, 0x00000276, 0x000200f9, 0x00000278, 0x000200f8, 0x00000278, - 0x000700f5, 0x000000b1, 0x00000279, 0x00000269, 0x00000264, 0x00000277, 0x0000026a, 0x000200f9, - 0x0000027a, 0x000200f8, 0x0000027a, 0x000700f5, 0x000000b1, 0x0000027b, 0x00000262, 0x0000014f, - 0x00000279, 0x00000278, 0x00050051, 0x00000019, 0x0000027d, 0x00000123, 0x00000001, 0x000500aa, - 0x000000b1, 0x0000027e, 0x0000027d, 0x00000036, 0x000400a8, 0x000000b1, 0x0000027f, 0x0000027e, - 0x000300f7, 0x00000296, 0x00000000, 0x000400fa, 0x0000027f, 0x00000280, 0x00000296, 0x000200f8, - 0x00000280, 0x00050051, 0x00000019, 0x00000284, 0x00000253, 0x00000001, 0x000500b1, 0x000000b1, - 0x00000285, 0x0000027d, 0x00000284, 0x000300f7, 0x00000294, 0x00000000, 0x000400fa, 0x00000285, - 0x00000286, 0x00000294, 0x000200f8, 0x00000286, 0x00050083, 0x00000006, 0x0000028b, 0x0000014a, - 0x0000037a, 0x0006000c, 0x00000006, 0x0000028c, 0x00000001, 0x00000004, 0x0000028b, 0x00050083, - 0x00000006, 0x00000291, 0x00000344, 0x0000014a, 0x0006000c, 0x00000006, 0x00000292, 0x00000001, - 0x00000004, 0x00000291, 0x000500b8, 0x000000b1, 0x00000293, 0x0000028c, 0x00000292, 0x000200f9, - 0x00000294, 0x000200f8, 0x00000294, 0x000700f5, 0x000000b1, 0x00000295, 0x00000285, 0x00000280, - 0x00000293, 0x00000286, 0x000200f9, 0x00000296, 0x000200f8, 0x00000296, 0x000700f5, 0x000000b1, - 0x00000297, 0x0000027e, 0x0000027a, 0x00000295, 0x00000294, 0x000300f7, 0x000002a1, 0x00000000, - 0x000400fa, 0x0000027b, 0x00000299, 0x0000029d, 0x000200f8, 0x00000299, 0x00050083, 0x0000000a, - 0x0000029c, 0x00000328, 0x0000023a, 0x000200f9, 0x000002a1, 0x000200f8, 0x0000029d, 0x00050083, - 0x0000000a, 0x000002a0, 0x0000023a, 0x000002f2, 0x000200f9, 0x000002a1, 0x000200f8, 0x000002a1, - 0x000700f5, 0x0000000a, 0x000003d5, 0x0000029c, 0x00000299, 0x000002a0, 0x0000029d, 0x000300f7, - 0x000002ac, 0x00000000, 0x000400fa, 0x00000297, 0x000002a4, 0x000002a8, 0x000200f8, 0x000002a4, - 0x00050083, 0x0000000a, 0x000002a7, 0x00000394, 0x0000023a, 0x000200f9, 0x000002ac, 0x000200f8, - 0x000002a8, 0x00050083, 0x0000000a, 0x000002ab, 0x0000023a, 0x0000035e, 0x000200f9, 0x000002ac, - 0x000200f8, 0x000002ac, 0x000700f5, 0x0000000a, 0x000003d6, 0x000002a7, 0x000002a4, 0x000002ab, - 0x000002a8, 0x0007000c, 0x0000000a, 0x000002b0, 0x00000001, 0x00000044, 0x000003d5, 0x000003d6, - 0x0006000c, 0x0000000a, 0x000002b1, 0x00000001, 0x00000045, 0x000002b0, 0x00050094, 0x00000006, - 0x000002b4, 0x000002b1, 0x0000023a, 0x000500ba, 0x000000b1, 0x000002b5, 0x000002b4, 0x00000110, - 0x000300f7, 0x000002bb, 0x00000000, 0x000400fa, 0x000002b5, 0x000002b6, 0x000002b9, 0x000200f8, - 0x000002b6, 0x0004007f, 0x0000000a, 0x000002b8, 0x000002b1, 0x000200f9, 0x000002bb, 0x000200f8, - 0x000002b9, 0x000200f9, 0x000002bb, 0x000200f8, 0x000002bb, 0x000700f5, 0x0000000a, 0x000003d7, - 0x000002b8, 0x000002b6, 0x000002b1, 0x000002b9, 0x00050041, 0x00000072, 0x00000167, 0x00000035, - 0x00000077, 0x0004003d, 0x00000032, 0x00000168, 0x00000167, 0x0008004f, 0x0000000a, 0x00000169, - 0x00000168, 0x00000168, 0x00000000, 0x00000001, 0x00000002, 0x00050094, 0x00000006, 0x0000016a, - 0x000003d7, 0x00000169, 0x0008000c, 0x00000006, 0x0000016b, 0x00000001, 0x00000031, 0x00000110, - 0x00000161, 0x0000016a, 0x000500bd, 0x000000b1, 0x0000016e, 0x0000016b, 0x00000110, 0x000300f7, - 0x00000170, 0x00000000, 0x000400fa, 0x0000016e, 0x0000016f, 0x00000170, 0x000200f8, 0x0000016f, - 0x000200f9, 0x0000021d, 0x000200f8, 0x00000170, 0x00060041, 0x00000037, 0x00000174, 0x00000035, - 0x00000077, 0x00000173, 0x0004003d, 0x00000006, 0x00000175, 0x00000174, 0x00050085, 0x00000006, - 0x00000178, 0x0000014a, 0x000003e2, 0x0008000c, 0x00000006, 0x0000017b, 0x00000001, 0x0000002b, - 0x00000178, 0x00000179, 0x0000017a, 0x00050085, 0x00000006, 0x0000017c, 0x00000175, 0x0000017b, - 0x00050085, 0x00000006, 0x00000181, 0x0000014a, 0x00000180, 0x00050081, 0x00000006, 0x00000182, - 0x0000017e, 0x00000181, 0x00050085, 0x00000006, 0x00000186, 0x0000017c, 0x000003e3, 0x00050094, - 0x00000006, 0x00000398, 0x00000153, 0x00000068, 0x0006000c, 0x00000006, 0x00000399, 0x00000001, - 0x0000000a, 0x00000398, 0x00050085, 0x00000006, 0x0000039a, 0x00000064, 0x00000399, 0x0006000c, - 0x00000006, 0x0000039b, 0x00000001, 0x0000000a, 0x0000039a, 0x00050081, 0x00000006, 0x0000018e, - 0x00000189, 0x0000039b, 0x00050085, 0x00000006, 0x0000018f, 0x00000186, 0x0000018e, 0x000200f9, - 0x00000192, 0x000200f8, 0x00000192, 0x000700f5, 0x00000006, 0x000003d9, 0x0000018f, 0x00000170, - 0x000001e7, 0x00000195, 0x000700f5, 0x00000019, 0x000003d8, 0x00000036, 0x00000170, 0x000001e4, - 0x00000195, 0x000500b1, 0x000000b1, 0x00000199, 0x000003d8, 0x00000198, 0x000400f6, 0x00000194, - 0x00000195, 0x00000000, 0x000400fa, 0x00000199, 0x00000193, 0x00000194, 0x000200f8, 0x00000193, - 0x0005008e, 0x0000000a, 0x000001a0, 0x00000169, 0x000003d9, 0x00050081, 0x0000000a, 0x000001a1, - 0x0000023a, 0x000001a0, 0x00050051, 0x00000006, 0x000001a3, 0x000001a1, 0x00000002, 0x000500be, - 0x000000b1, 0x000001a5, 0x000001a3, 0x000001a4, 0x000300f7, 0x000001a7, 0x00000000, 0x000400fa, - 0x000001a5, 0x000001a6, 0x000001a7, 0x000200f8, 0x000001a6, 0x000200f9, 0x00000194, 0x000200f8, - 0x000001a7, 0x0004007f, 0x00000006, 0x000003a1, 0x000001a3, 0x00050051, 0x00000006, 0x000003a3, - 0x000001a1, 0x00000000, 0x00050085, 0x00000006, 0x000003a4, 0x0000004e, 0x000003a3, 0x00050085, - 0x00000006, 0x000003a7, 0x000003a4, 0x0000022e, 0x00050088, 0x00000006, 0x000003a9, 0x000003a7, - 0x000003a1, 0x00050081, 0x00000006, 0x000003aa, 0x0000004e, 0x000003a9, 0x00050051, 0x00000006, - 0x000003ac, 0x000001a1, 0x00000001, 0x00050085, 0x00000006, 0x000003ad, 0x0000004e, 0x000003ac, - 0x00050085, 0x00000006, 0x000003b0, 0x000003ad, 0x00000236, 0x00050088, 0x00000006, 0x000003b2, - 0x000003b0, 0x000003a1, 0x00050083, 0x00000006, 0x000003b3, 0x0000004e, 0x000003b2, 0x00050050, - 0x00000007, 0x000003b4, 0x000003aa, 0x000003b3, 0x000500b8, 0x000001af, 0x000001b0, 0x000003b4, - 0x000001ae, 0x0004009a, 0x000000b1, 0x000001b1, 0x000001b0, 0x000400a8, 0x000000b1, 0x000001b2, - 0x000001b1, 0x000300f7, 0x000001b4, 0x00000000, 0x000400fa, 0x000001b2, 0x000001b3, 0x000001b4, - 0x000200f8, 0x000001b3, 0x000500ba, 0x000001af, 0x000001b7, 0x000003b4, 0x000001b6, 0x0004009a, - 0x000000b1, 0x000001b8, 0x000001b7, 0x000200f9, 0x000001b4, 0x000200f8, 0x000001b4, 0x000700f5, - 0x000000b1, 0x000001b9, 0x000001b1, 0x000001a7, 0x000001b8, 0x000001b3, 0x000300f7, 0x000001bb, - 0x00000000, 0x000400fa, 0x000001b9, 0x000001ba, 0x000001bb, 0x000200f8, 0x000001ba, 0x000200f9, - 0x00000194, 0x000200f8, 0x000001bb, 0x0004003d, 0x00000084, 0x000001be, 0x00000086, 0x00050085, - 0x00000007, 0x000001c3, 0x000003b4, 0x00000250, 0x0004006e, 0x0000001a, 0x000001c4, 0x000001c3, - 0x00040064, 0x00000083, 0x000001c5, 0x000001be, 0x0007005f, 0x00000032, 0x000001c6, 0x000001c5, - 0x000001c4, 0x00000002, 0x00000036, 0x00050051, 0x00000006, 0x000001c7, 0x000001c6, 0x00000000, - 0x00050085, 0x00000006, 0x000001ca, 0x000001c7, 0x00000149, 0x00050083, 0x00000006, 0x000001d0, - 0x000003a1, 0x000001ca, 0x00050085, 0x00000006, 0x000001d5, 0x0000014a, 0x000001d4, 0x00050081, - 0x00000006, 0x000001d6, 0x000001d2, 0x000001d5, 0x000500ba, 0x000000b1, 0x000001d7, 0x000001d0, - 0x000001d6, 0x000500b8, 0x000000b1, 0x000001da, 0x000001d0, 0x00000182, 0x000500a7, 0x000000b1, - 0x000001db, 0x000001d7, 0x000001da, 0x000300f7, 0x000001dd, 0x00000000, 0x000400fa, 0x000001db, - 0x000001dc, 0x000001dd, 0x000200f8, 0x000001dc, 0x0004006f, 0x00000006, 0x000001df, 0x000003d8, - 0x00050085, 0x00000006, 0x000001e0, 0x000001df, 0x000003e3, 0x00050083, 0x00000006, 0x000001e1, - 0x00000029, 0x000001e0, 0x000200f9, 0x00000194, 0x000200f8, 0x000001dd, 0x000200f9, 0x00000195, - 0x000200f8, 0x00000195, 0x00050080, 0x00000019, 0x000001e4, 0x000003d8, 0x00000077, 0x00050081, - 0x00000006, 0x000001e7, 0x000003d9, 0x00000186, 0x000200f9, 0x00000192, 0x000200f8, 0x00000194, - 0x000b00f5, 0x00000006, 0x000003dc, 0x00000110, 0x00000192, 0x00000110, 0x000001a6, 0x00000110, - 0x000001ba, 0x000001e1, 0x000001dc, 0x0008000c, 0x00000006, 0x000001eb, 0x00000001, 0x00000031, - 0x000001e9, 0x0000014c, 0x0000014a, 0x00050083, 0x00000006, 0x000001ec, 0x00000029, 0x000001eb, - 0x00060041, 0x00000037, 0x000001ee, 0x00000035, 0x00000036, 0x00000173, 0x0004003d, 0x00000006, - 0x000001ef, 0x000001ee, 0x00050085, 0x00000006, 0x000001f1, 0x000001ef, 0x000003dc, 0x00050085, - 0x00000006, 0x000001f3, 0x000001f1, 0x000001ec, 0x00050085, 0x00000006, 0x000001f5, 0x000001f3, - 0x0000016b, 0x00050083, 0x00000006, 0x000001f6, 0x00000029, 0x000001f5, 0x00060041, 0x00000037, - 0x000001f8, 0x00000035, 0x000001f7, 0x0000002d, 0x0004003d, 0x00000006, 0x000001f9, 0x000001f8, - 0x000500ba, 0x000000b1, 0x000001fa, 0x000001f9, 0x0000004e, 0x000300f7, 0x000001fc, 0x00000000, - 0x000400fa, 0x000001fa, 0x000001fb, 0x000001fc, 0x000200f8, 0x000001fb, 0x0004003d, 0x000001fd, - 0x00000200, 0x000001ff, 0x00070050, 0x00000032, 0x00000203, 0x000001f6, 0x000001f6, 0x000001f6, - 0x00000029, 0x00040063, 0x00000200, 0x00000123, 0x00000203, 0x000200f9, 0x0000021d, 0x000200f8, - 0x000001fc, 0x000500be, 0x000000b1, 0x00000206, 0x000001f6, 0x00000140, 0x000300f7, 0x00000208, - 0x00000000, 0x000400fa, 0x00000206, 0x00000207, 0x00000208, 0x000200f8, 0x00000207, 0x000200f9, - 0x0000021d, 0x000200f8, 0x00000208, 0x0004003d, 0x000001fd, 0x0000020c, 0x000001ff, 0x00050062, - 0x00000032, 0x0000020e, 0x0000020c, 0x00000123, 0x0004003d, 0x000001fd, 0x0000020f, 0x000001ff, - 0x0008004f, 0x0000000a, 0x00000212, 0x0000020e, 0x0000020e, 0x00000000, 0x00000001, 0x00000002, - 0x0005008e, 0x0000000a, 0x00000214, 0x00000212, 0x000001f6, 0x00050051, 0x00000006, 0x00000216, - 0x0000020e, 0x00000003, 0x00050051, 0x00000006, 0x00000217, 0x00000214, 0x00000000, 0x00050051, - 0x00000006, 0x00000218, 0x00000214, 0x00000001, 0x00050051, 0x00000006, 0x00000219, 0x00000214, - 0x00000002, 0x00070050, 0x00000032, 0x0000021a, 0x00000217, 0x00000218, 0x00000219, 0x00000216, - 0x00040063, 0x0000020f, 0x00000123, 0x0000021a, 0x000200f9, 0x0000021d, 0x000200f8, 0x0000021d, + 0x00000155, 0x00000158, 0x00060041, 0x00000037, 0x0000015c, 0x00000035, 0x0000015b, 0x0000003b, + 0x0004003d, 0x00000006, 0x0000015d, 0x0000015c, 0x000500ba, 0x000000b1, 0x0000015e, 0x0000015d, + 0x0000004e, 0x000300f7, 0x00000161, 0x00000000, 0x000400fa, 0x0000015e, 0x00000160, 0x00000168, + 0x000200f8, 0x00000160, 0x0004003d, 0x00000084, 0x00000163, 0x00000162, 0x00070058, 0x00000032, + 0x00000165, 0x00000163, 0x00000159, 0x00000002, 0x00000110, 0x00050051, 0x00000006, 0x00000167, + 0x00000165, 0x00000003, 0x000200f9, 0x00000161, 0x000200f8, 0x00000168, 0x000200f9, 0x00000161, + 0x000200f8, 0x00000161, 0x000700f5, 0x00000006, 0x000003fb, 0x00000167, 0x00000160, 0x00000029, + 0x00000168, 0x00060041, 0x00000037, 0x0000016a, 0x00000035, 0x0000015b, 0x0000002d, 0x0004003d, + 0x00000006, 0x0000016b, 0x0000016a, 0x000500ba, 0x000000b1, 0x0000016d, 0x0000016b, 0x0000016c, + 0x000300f7, 0x0000016f, 0x00000000, 0x000400fa, 0x0000016d, 0x0000016e, 0x0000016f, 0x000200f8, + 0x0000016e, 0x0004003d, 0x00000170, 0x00000173, 0x00000172, 0x00070050, 0x00000032, 0x00000176, + 0x000003fb, 0x000003fb, 0x000003fb, 0x00000029, 0x00040063, 0x00000173, 0x00000123, 0x00000176, + 0x000200f9, 0x00000243, 0x000200f8, 0x0000016f, 0x000500bc, 0x000000b1, 0x00000179, 0x000003fb, + 0x00000110, 0x000300f7, 0x0000017b, 0x00000000, 0x000400fa, 0x00000179, 0x0000017a, 0x0000017b, + 0x000200f8, 0x0000017a, 0x000500b8, 0x000000b1, 0x0000017e, 0x0000016b, 0x0000004e, 0x000200f9, + 0x0000017b, 0x000200f8, 0x0000017b, 0x000700f5, 0x000000b1, 0x0000017f, 0x00000179, 0x0000016f, + 0x0000017e, 0x0000017a, 0x000300f7, 0x00000181, 0x00000000, 0x000400fa, 0x0000017f, 0x00000180, + 0x00000181, 0x000200f8, 0x00000180, 0x000200f9, 0x00000243, 0x000200f8, 0x00000181, 0x0005008e, + 0x00000007, 0x0000024c, 0x00000159, 0x00000027, 0x00050083, 0x00000007, 0x0000024e, 0x0000024c, + 0x000001de, 0x00050051, 0x00000006, 0x00000250, 0x0000024e, 0x00000000, 0x00050085, 0x00000006, + 0x00000252, 0x00000250, 0x0000014a, 0x00060041, 0x00000037, 0x00000253, 0x00000035, 0x00000036, + 0x0000002d, 0x0004003d, 0x00000006, 0x00000254, 0x00000253, 0x00050088, 0x00000006, 0x00000255, + 0x00000252, 0x00000254, 0x00050051, 0x00000006, 0x00000257, 0x0000024e, 0x00000001, 0x0004007f, + 0x00000006, 0x00000258, 0x00000257, 0x00050085, 0x00000006, 0x0000025a, 0x00000258, 0x0000014a, + 0x00060041, 0x00000037, 0x0000025b, 0x00000035, 0x00000036, 0x0000003b, 0x0004003d, 0x00000006, + 0x0000025c, 0x0000025b, 0x00050088, 0x00000006, 0x0000025d, 0x0000025a, 0x0000025c, 0x0004007f, + 0x00000006, 0x0000025f, 0x0000014a, 0x00060050, 0x0000000a, 0x00000260, 0x00000255, 0x0000025d, + 0x0000025f, 0x0007004f, 0x00000007, 0x00000276, 0x00000157, 0x00000157, 0x00000000, 0x00000001, + 0x0004006e, 0x0000001a, 0x00000277, 0x00000276, 0x00050082, 0x0000001a, 0x00000279, 0x00000277, + 0x00000407, 0x00050082, 0x0000001a, 0x0000027b, 0x00000123, 0x0000009d, 0x0008000c, 0x0000001a, + 0x000002ee, 0x00000001, 0x0000002d, 0x0000027b, 0x00000070, 0x00000279, 0x0004006f, 0x00000007, + 0x000002f0, 0x000002ee, 0x00050081, 0x00000007, 0x000002f2, 0x000002f0, 0x00000406, 0x00050085, + 0x00000007, 0x000002f6, 0x000002f2, 0x00000158, 0x0004003d, 0x00000084, 0x000002f7, 0x00000086, + 0x00040064, 0x00000083, 0x000002f9, 0x000002f7, 0x0007005f, 0x00000032, 0x000002fa, 0x000002f9, + 0x000002ee, 0x00000002, 0x00000036, 0x00050051, 0x00000006, 0x000002fb, 0x000002fa, 0x00000000, + 0x00050085, 0x00000006, 0x000002fe, 0x000002fb, 0x00000149, 0x0005008e, 0x00000007, 0x00000304, + 0x000002f6, 0x00000027, 0x00050083, 0x00000007, 0x00000306, 0x00000304, 0x000001de, 0x00050051, + 0x00000006, 0x00000308, 0x00000306, 0x00000000, 0x00050085, 0x00000006, 0x0000030a, 0x00000308, + 0x000002fe, 0x00050088, 0x00000006, 0x0000030d, 0x0000030a, 0x00000254, 0x00050051, 0x00000006, + 0x0000030f, 0x00000306, 0x00000001, 0x0004007f, 0x00000006, 0x00000310, 0x0000030f, 0x00050085, + 0x00000006, 0x00000312, 0x00000310, 0x000002fe, 0x00050088, 0x00000006, 0x00000315, 0x00000312, + 0x0000025c, 0x0004007f, 0x00000006, 0x00000317, 0x000002fe, 0x00060050, 0x0000000a, 0x00000318, + 0x0000030d, 0x00000315, 0x00000317, 0x00050080, 0x0000001a, 0x0000027e, 0x00000123, 0x0000009d, + 0x0008000c, 0x0000001a, 0x00000324, 0x00000001, 0x0000002d, 0x0000027e, 0x00000070, 0x00000279, + 0x0004006f, 0x00000007, 0x00000326, 0x00000324, 0x00050081, 0x00000007, 0x00000328, 0x00000326, + 0x00000406, 0x00050085, 0x00000007, 0x0000032c, 0x00000328, 0x00000158, 0x0004003d, 0x00000084, + 0x0000032d, 0x00000086, 0x00040064, 0x00000083, 0x0000032f, 0x0000032d, 0x0007005f, 0x00000032, + 0x00000330, 0x0000032f, 0x00000324, 0x00000002, 0x00000036, 0x00050051, 0x00000006, 0x00000331, + 0x00000330, 0x00000000, 0x00050085, 0x00000006, 0x00000334, 0x00000331, 0x00000149, 0x0005008e, + 0x00000007, 0x0000033a, 0x0000032c, 0x00000027, 0x00050083, 0x00000007, 0x0000033c, 0x0000033a, + 0x000001de, 0x00050051, 0x00000006, 0x0000033e, 0x0000033c, 0x00000000, 0x00050085, 0x00000006, + 0x00000340, 0x0000033e, 0x00000334, 0x00050088, 0x00000006, 0x00000343, 0x00000340, 0x00000254, + 0x00050051, 0x00000006, 0x00000345, 0x0000033c, 0x00000001, 0x0004007f, 0x00000006, 0x00000346, + 0x00000345, 0x00050085, 0x00000006, 0x00000348, 0x00000346, 0x00000334, 0x00050088, 0x00000006, + 0x0000034b, 0x00000348, 0x0000025c, 0x0004007f, 0x00000006, 0x0000034d, 0x00000334, 0x00060050, + 0x0000000a, 0x0000034e, 0x00000343, 0x0000034b, 0x0000034d, 0x00050082, 0x0000001a, 0x00000281, + 0x00000123, 0x000000a8, 0x0008000c, 0x0000001a, 0x0000035a, 0x00000001, 0x0000002d, 0x00000281, + 0x00000070, 0x00000279, 0x0004006f, 0x00000007, 0x0000035c, 0x0000035a, 0x00050081, 0x00000007, + 0x0000035e, 0x0000035c, 0x00000406, 0x00050085, 0x00000007, 0x00000362, 0x0000035e, 0x00000158, + 0x0004003d, 0x00000084, 0x00000363, 0x00000086, 0x00040064, 0x00000083, 0x00000365, 0x00000363, + 0x0007005f, 0x00000032, 0x00000366, 0x00000365, 0x0000035a, 0x00000002, 0x00000036, 0x00050051, + 0x00000006, 0x00000367, 0x00000366, 0x00000000, 0x00050085, 0x00000006, 0x0000036a, 0x00000367, + 0x00000149, 0x0005008e, 0x00000007, 0x00000370, 0x00000362, 0x00000027, 0x00050083, 0x00000007, + 0x00000372, 0x00000370, 0x000001de, 0x00050051, 0x00000006, 0x00000374, 0x00000372, 0x00000000, + 0x00050085, 0x00000006, 0x00000376, 0x00000374, 0x0000036a, 0x00050088, 0x00000006, 0x00000379, + 0x00000376, 0x00000254, 0x00050051, 0x00000006, 0x0000037b, 0x00000372, 0x00000001, 0x0004007f, + 0x00000006, 0x0000037c, 0x0000037b, 0x00050085, 0x00000006, 0x0000037e, 0x0000037c, 0x0000036a, + 0x00050088, 0x00000006, 0x00000381, 0x0000037e, 0x0000025c, 0x0004007f, 0x00000006, 0x00000383, + 0x0000036a, 0x00060050, 0x0000000a, 0x00000384, 0x00000379, 0x00000381, 0x00000383, 0x00050080, + 0x0000001a, 0x00000284, 0x00000123, 0x000000a8, 0x0008000c, 0x0000001a, 0x00000390, 0x00000001, + 0x0000002d, 0x00000284, 0x00000070, 0x00000279, 0x0004006f, 0x00000007, 0x00000392, 0x00000390, + 0x00050081, 0x00000007, 0x00000394, 0x00000392, 0x00000406, 0x00050085, 0x00000007, 0x00000398, + 0x00000394, 0x00000158, 0x0004003d, 0x00000084, 0x00000399, 0x00000086, 0x00040064, 0x00000083, + 0x0000039b, 0x00000399, 0x0007005f, 0x00000032, 0x0000039c, 0x0000039b, 0x00000390, 0x00000002, + 0x00000036, 0x00050051, 0x00000006, 0x0000039d, 0x0000039c, 0x00000000, 0x00050085, 0x00000006, + 0x000003a0, 0x0000039d, 0x00000149, 0x0005008e, 0x00000007, 0x000003a6, 0x00000398, 0x00000027, + 0x00050083, 0x00000007, 0x000003a8, 0x000003a6, 0x000001de, 0x00050051, 0x00000006, 0x000003aa, + 0x000003a8, 0x00000000, 0x00050085, 0x00000006, 0x000003ac, 0x000003aa, 0x000003a0, 0x00050088, + 0x00000006, 0x000003af, 0x000003ac, 0x00000254, 0x00050051, 0x00000006, 0x000003b1, 0x000003a8, + 0x00000001, 0x0004007f, 0x00000006, 0x000003b2, 0x000003b1, 0x00050085, 0x00000006, 0x000003b4, + 0x000003b2, 0x000003a0, 0x00050088, 0x00000006, 0x000003b7, 0x000003b4, 0x0000025c, 0x0004007f, + 0x00000006, 0x000003b9, 0x000003a0, 0x00060050, 0x0000000a, 0x000003ba, 0x000003af, 0x000003b7, + 0x000003b9, 0x000500aa, 0x000000b1, 0x00000288, 0x00000125, 0x00000036, 0x000400a8, 0x000000b1, + 0x00000289, 0x00000288, 0x000300f7, 0x000002a0, 0x00000000, 0x000400fa, 0x00000289, 0x0000028a, + 0x000002a0, 0x000200f8, 0x0000028a, 0x00050051, 0x00000019, 0x0000028e, 0x00000279, 0x00000000, + 0x000500b1, 0x000000b1, 0x0000028f, 0x00000125, 0x0000028e, 0x000300f7, 0x0000029e, 0x00000000, + 0x000400fa, 0x0000028f, 0x00000290, 0x0000029e, 0x000200f8, 0x00000290, 0x00050083, 0x00000006, + 0x00000295, 0x0000014a, 0x00000334, 0x0006000c, 0x00000006, 0x00000296, 0x00000001, 0x00000004, + 0x00000295, 0x00050083, 0x00000006, 0x0000029b, 0x000002fe, 0x0000014a, 0x0006000c, 0x00000006, + 0x0000029c, 0x00000001, 0x00000004, 0x0000029b, 0x000500b8, 0x000000b1, 0x0000029d, 0x00000296, + 0x0000029c, 0x000200f9, 0x0000029e, 0x000200f8, 0x0000029e, 0x000700f5, 0x000000b1, 0x0000029f, + 0x0000028f, 0x0000028a, 0x0000029d, 0x00000290, 0x000200f9, 0x000002a0, 0x000200f8, 0x000002a0, + 0x000700f5, 0x000000b1, 0x000002a1, 0x00000288, 0x00000181, 0x0000029f, 0x0000029e, 0x00050051, + 0x00000019, 0x000002a3, 0x00000123, 0x00000001, 0x000500aa, 0x000000b1, 0x000002a4, 0x000002a3, + 0x00000036, 0x000400a8, 0x000000b1, 0x000002a5, 0x000002a4, 0x000300f7, 0x000002bc, 0x00000000, + 0x000400fa, 0x000002a5, 0x000002a6, 0x000002bc, 0x000200f8, 0x000002a6, 0x00050051, 0x00000019, + 0x000002aa, 0x00000279, 0x00000001, 0x000500b1, 0x000000b1, 0x000002ab, 0x000002a3, 0x000002aa, + 0x000300f7, 0x000002ba, 0x00000000, 0x000400fa, 0x000002ab, 0x000002ac, 0x000002ba, 0x000200f8, + 0x000002ac, 0x00050083, 0x00000006, 0x000002b1, 0x0000014a, 0x000003a0, 0x0006000c, 0x00000006, + 0x000002b2, 0x00000001, 0x00000004, 0x000002b1, 0x00050083, 0x00000006, 0x000002b7, 0x0000036a, + 0x0000014a, 0x0006000c, 0x00000006, 0x000002b8, 0x00000001, 0x00000004, 0x000002b7, 0x000500b8, + 0x000000b1, 0x000002b9, 0x000002b2, 0x000002b8, 0x000200f9, 0x000002ba, 0x000200f8, 0x000002ba, + 0x000700f5, 0x000000b1, 0x000002bb, 0x000002ab, 0x000002a6, 0x000002b9, 0x000002ac, 0x000200f9, + 0x000002bc, 0x000200f8, 0x000002bc, 0x000700f5, 0x000000b1, 0x000002bd, 0x000002a4, 0x000002a0, + 0x000002bb, 0x000002ba, 0x000300f7, 0x000002c7, 0x00000000, 0x000400fa, 0x000002a1, 0x000002bf, + 0x000002c3, 0x000200f8, 0x000002bf, 0x00050083, 0x0000000a, 0x000002c2, 0x0000034e, 0x00000260, + 0x000200f9, 0x000002c7, 0x000200f8, 0x000002c3, 0x00050083, 0x0000000a, 0x000002c6, 0x00000260, + 0x00000318, 0x000200f9, 0x000002c7, 0x000200f8, 0x000002c7, 0x000700f5, 0x0000000a, 0x000003fc, + 0x000002c2, 0x000002bf, 0x000002c6, 0x000002c3, 0x000300f7, 0x000002d2, 0x00000000, 0x000400fa, + 0x000002bd, 0x000002ca, 0x000002ce, 0x000200f8, 0x000002ca, 0x00050083, 0x0000000a, 0x000002cd, + 0x000003ba, 0x00000260, 0x000200f9, 0x000002d2, 0x000200f8, 0x000002ce, 0x00050083, 0x0000000a, + 0x000002d1, 0x00000260, 0x00000384, 0x000200f9, 0x000002d2, 0x000200f8, 0x000002d2, 0x000700f5, + 0x0000000a, 0x000003fd, 0x000002cd, 0x000002ca, 0x000002d1, 0x000002ce, 0x0007000c, 0x0000000a, + 0x000002d6, 0x00000001, 0x00000044, 0x000003fc, 0x000003fd, 0x0006000c, 0x0000000a, 0x000002d7, + 0x00000001, 0x00000045, 0x000002d6, 0x00050094, 0x00000006, 0x000002da, 0x000002d7, 0x00000260, + 0x000500ba, 0x000000b1, 0x000002db, 0x000002da, 0x00000110, 0x000300f7, 0x000002e1, 0x00000000, + 0x000400fa, 0x000002db, 0x000002dc, 0x000002df, 0x000200f8, 0x000002dc, 0x0004007f, 0x0000000a, + 0x000002de, 0x000002d7, 0x000200f9, 0x000002e1, 0x000200f8, 0x000002df, 0x000200f9, 0x000002e1, + 0x000200f8, 0x000002e1, 0x000700f5, 0x0000000a, 0x000003fe, 0x000002de, 0x000002dc, 0x000002d7, + 0x000002df, 0x00050041, 0x00000072, 0x00000190, 0x00000035, 0x00000077, 0x0004003d, 0x00000032, + 0x00000191, 0x00000190, 0x0008004f, 0x0000000a, 0x00000192, 0x00000191, 0x00000191, 0x00000000, + 0x00000001, 0x00000002, 0x00050094, 0x00000006, 0x00000193, 0x000003fe, 0x00000192, 0x0008000c, + 0x00000006, 0x00000194, 0x00000001, 0x00000031, 0x00000110, 0x0000018a, 0x00000193, 0x000500bd, + 0x000000b1, 0x00000197, 0x00000194, 0x00000110, 0x000300f7, 0x00000199, 0x00000000, 0x000400fa, + 0x00000197, 0x00000198, 0x00000199, 0x000200f8, 0x00000198, 0x000200f9, 0x00000243, 0x000200f8, + 0x00000199, 0x00060041, 0x00000037, 0x0000019c, 0x00000035, 0x00000077, 0x00000166, 0x0004003d, + 0x00000006, 0x0000019d, 0x0000019c, 0x00050085, 0x00000006, 0x000001a0, 0x0000014a, 0x00000409, + 0x0008000c, 0x00000006, 0x000001a3, 0x00000001, 0x0000002b, 0x000001a0, 0x000001a1, 0x000001a2, + 0x00050085, 0x00000006, 0x000001a4, 0x0000019d, 0x000001a3, 0x00050085, 0x00000006, 0x000001a9, + 0x0000014a, 0x000001a8, 0x00050081, 0x00000006, 0x000001aa, 0x000001a6, 0x000001a9, 0x00050085, + 0x00000006, 0x000001ae, 0x000001a4, 0x0000040a, 0x00050094, 0x00000006, 0x000003be, 0x00000153, + 0x00000068, 0x0006000c, 0x00000006, 0x000003bf, 0x00000001, 0x0000000a, 0x000003be, 0x00050085, + 0x00000006, 0x000003c0, 0x00000064, 0x000003bf, 0x0006000c, 0x00000006, 0x000003c1, 0x00000001, + 0x0000000a, 0x000003c0, 0x00050081, 0x00000006, 0x000001b6, 0x000001b1, 0x000003c1, 0x00050085, + 0x00000006, 0x000001b7, 0x000001ae, 0x000001b6, 0x000200f9, 0x000001ba, 0x000200f8, 0x000001ba, + 0x000700f5, 0x00000006, 0x00000400, 0x000001b7, 0x00000199, 0x0000020f, 0x000001bd, 0x000700f5, + 0x00000019, 0x000003ff, 0x00000036, 0x00000199, 0x0000020c, 0x000001bd, 0x000500b1, 0x000000b1, + 0x000001c1, 0x000003ff, 0x000001c0, 0x000400f6, 0x000001bc, 0x000001bd, 0x00000000, 0x000400fa, + 0x000001c1, 0x000001bb, 0x000001bc, 0x000200f8, 0x000001bb, 0x0005008e, 0x0000000a, 0x000001c8, + 0x00000192, 0x00000400, 0x00050081, 0x0000000a, 0x000001c9, 0x00000260, 0x000001c8, 0x00050051, + 0x00000006, 0x000001cb, 0x000001c9, 0x00000002, 0x000500be, 0x000000b1, 0x000001cd, 0x000001cb, + 0x000001cc, 0x000300f7, 0x000001cf, 0x00000000, 0x000400fa, 0x000001cd, 0x000001ce, 0x000001cf, + 0x000200f8, 0x000001ce, 0x000200f9, 0x000001bc, 0x000200f8, 0x000001cf, 0x0004007f, 0x00000006, + 0x000003c7, 0x000001cb, 0x00050051, 0x00000006, 0x000003c9, 0x000001c9, 0x00000000, 0x00050085, + 0x00000006, 0x000003ca, 0x0000004e, 0x000003c9, 0x00050085, 0x00000006, 0x000003cd, 0x000003ca, + 0x00000254, 0x00050088, 0x00000006, 0x000003cf, 0x000003cd, 0x000003c7, 0x00050081, 0x00000006, + 0x000003d0, 0x0000004e, 0x000003cf, 0x00050051, 0x00000006, 0x000003d2, 0x000001c9, 0x00000001, + 0x00050085, 0x00000006, 0x000003d3, 0x0000004e, 0x000003d2, 0x00050085, 0x00000006, 0x000003d6, + 0x000003d3, 0x0000025c, 0x00050088, 0x00000006, 0x000003d8, 0x000003d6, 0x000003c7, 0x00050083, + 0x00000006, 0x000003d9, 0x0000004e, 0x000003d8, 0x00050050, 0x00000007, 0x000003da, 0x000003d0, + 0x000003d9, 0x000500b8, 0x000001d7, 0x000001d8, 0x000003da, 0x000001d6, 0x0004009a, 0x000000b1, + 0x000001d9, 0x000001d8, 0x000400a8, 0x000000b1, 0x000001da, 0x000001d9, 0x000300f7, 0x000001dc, + 0x00000000, 0x000400fa, 0x000001da, 0x000001db, 0x000001dc, 0x000200f8, 0x000001db, 0x000500ba, + 0x000001d7, 0x000001df, 0x000003da, 0x000001de, 0x0004009a, 0x000000b1, 0x000001e0, 0x000001df, + 0x000200f9, 0x000001dc, 0x000200f8, 0x000001dc, 0x000700f5, 0x000000b1, 0x000001e1, 0x000001d9, + 0x000001cf, 0x000001e0, 0x000001db, 0x000300f7, 0x000001e3, 0x00000000, 0x000400fa, 0x000001e1, + 0x000001e2, 0x000001e3, 0x000200f8, 0x000001e2, 0x000200f9, 0x000001bc, 0x000200f8, 0x000001e3, + 0x0004003d, 0x00000084, 0x000001e6, 0x00000086, 0x00050085, 0x00000007, 0x000001eb, 0x000003da, + 0x00000276, 0x0004006e, 0x0000001a, 0x000001ec, 0x000001eb, 0x00040064, 0x00000083, 0x000001ed, + 0x000001e6, 0x0007005f, 0x00000032, 0x000001ee, 0x000001ed, 0x000001ec, 0x00000002, 0x00000036, + 0x00050051, 0x00000006, 0x000001ef, 0x000001ee, 0x00000000, 0x00050085, 0x00000006, 0x000001f2, + 0x000001ef, 0x00000149, 0x00050083, 0x00000006, 0x000001f8, 0x000003c7, 0x000001f2, 0x00050085, + 0x00000006, 0x000001fd, 0x0000014a, 0x000001fc, 0x00050081, 0x00000006, 0x000001fe, 0x000001fa, + 0x000001fd, 0x000500ba, 0x000000b1, 0x000001ff, 0x000001f8, 0x000001fe, 0x000500b8, 0x000000b1, + 0x00000202, 0x000001f8, 0x000001aa, 0x000500a7, 0x000000b1, 0x00000203, 0x000001ff, 0x00000202, + 0x000300f7, 0x00000205, 0x00000000, 0x000400fa, 0x00000203, 0x00000204, 0x00000205, 0x000200f8, + 0x00000204, 0x0004006f, 0x00000006, 0x00000207, 0x000003ff, 0x00050085, 0x00000006, 0x00000208, + 0x00000207, 0x0000040a, 0x00050083, 0x00000006, 0x00000209, 0x00000029, 0x00000208, 0x000200f9, + 0x000001bc, 0x000200f8, 0x00000205, 0x000200f9, 0x000001bd, 0x000200f8, 0x000001bd, 0x00050080, + 0x00000019, 0x0000020c, 0x000003ff, 0x00000077, 0x00050081, 0x00000006, 0x0000020f, 0x00000400, + 0x000001ae, 0x000200f9, 0x000001ba, 0x000200f8, 0x000001bc, 0x000b00f5, 0x00000006, 0x00000403, + 0x00000110, 0x000001ba, 0x00000110, 0x000001ce, 0x00000110, 0x000001e2, 0x00000209, 0x00000204, + 0x0008000c, 0x00000006, 0x00000213, 0x00000001, 0x00000031, 0x00000211, 0x0000014c, 0x0000014a, + 0x00050083, 0x00000006, 0x00000214, 0x00000029, 0x00000213, 0x00060041, 0x00000037, 0x00000216, + 0x00000035, 0x00000036, 0x00000166, 0x0004003d, 0x00000006, 0x00000217, 0x00000216, 0x00050085, + 0x00000006, 0x00000219, 0x00000217, 0x00000403, 0x00050085, 0x00000006, 0x0000021b, 0x00000219, + 0x00000214, 0x00050085, 0x00000006, 0x0000021d, 0x0000021b, 0x00000194, 0x00050085, 0x00000006, + 0x0000021f, 0x0000021d, 0x000003fb, 0x00050083, 0x00000006, 0x00000220, 0x00000029, 0x0000021f, + 0x000500ba, 0x000000b1, 0x00000223, 0x0000016b, 0x0000004e, 0x000300f7, 0x00000225, 0x00000000, + 0x000400fa, 0x00000223, 0x00000224, 0x00000225, 0x000200f8, 0x00000224, 0x0004003d, 0x00000170, + 0x00000226, 0x00000172, 0x00070050, 0x00000032, 0x00000229, 0x00000220, 0x00000220, 0x00000220, + 0x00000029, 0x00040063, 0x00000226, 0x00000123, 0x00000229, 0x000200f9, 0x00000243, 0x000200f8, + 0x00000225, 0x000500be, 0x000000b1, 0x0000022c, 0x00000220, 0x00000140, 0x000300f7, 0x0000022e, + 0x00000000, 0x000400fa, 0x0000022c, 0x0000022d, 0x0000022e, 0x000200f8, 0x0000022d, 0x000200f9, + 0x00000243, 0x000200f8, 0x0000022e, 0x0004003d, 0x00000170, 0x00000232, 0x00000172, 0x00050062, + 0x00000032, 0x00000234, 0x00000232, 0x00000123, 0x0004003d, 0x00000170, 0x00000235, 0x00000172, + 0x0008004f, 0x0000000a, 0x00000238, 0x00000234, 0x00000234, 0x00000000, 0x00000001, 0x00000002, + 0x0005008e, 0x0000000a, 0x0000023a, 0x00000238, 0x00000220, 0x00050051, 0x00000006, 0x0000023c, + 0x00000234, 0x00000003, 0x00050051, 0x00000006, 0x0000023d, 0x0000023a, 0x00000000, 0x00050051, + 0x00000006, 0x0000023e, 0x0000023a, 0x00000001, 0x00050051, 0x00000006, 0x0000023f, 0x0000023a, + 0x00000002, 0x00070050, 0x00000032, 0x00000240, 0x0000023d, 0x0000023e, 0x0000023f, 0x0000023c, + 0x00040063, 0x00000235, 0x00000123, 0x00000240, 0x000200f9, 0x00000243, 0x000200f8, 0x00000243, 0x000100fd, 0x00010038, }; diff --git a/runtime/shaders/contact_shadow.comp b/runtime/shaders/contact_shadow.comp index 3e390fb1..ea11a00c 100644 --- a/runtime/shaders/contact_shadow.comp +++ b/runtime/shaders/contact_shadow.comp @@ -7,12 +7,13 @@ layout(local_size_x = 8, local_size_y = 8) in; layout(binding = 0) uniform sampler2D lin_depth; // the game's linear depth: view distance / far layout(binding = 1, r11f_g11f_b10f) uniform image2D scene; // the lit scene colour, darkened in place +layout(binding = 2) uniform sampler2D sun_vis; // half-resolution lighting: alpha is sun visibility layout(push_constant) uniform Params { vec4 proj; // projection x scale, y scale, far plane, strength (0..1) vec4 light; // view-space direction toward the sun (xyz), march length in metres at 10 m (w) vec4 size; // width, height, 1/width, 1/height - vec4 opt; // x: debug (1: write the shadow factor as grey) + vec4 opt; // x: debug (1: the shadow factor as grey, 2: the sun visibility), y: 1 with sun_vis bound } pc; vec3 view_pos(vec2 uv, float z) { // z: distance in front of the camera @@ -58,6 +59,14 @@ void main() { float z = d * pc.proj.z; if (z > 80.0) return; vec2 uv = (vec2(px) + 0.5) * pc.size.zw; + // Direct sunlight on this pixel as the game's lighting found it: 0 in the shadow maps' shadow and underground, where + // darkening would take away ambient light and texture detail (flat caves). Without that pass every pixel counts as lit. + float vis = pc.opt.y > 0.5 ? textureLod(sun_vis, uv, 0.0).a : 1.0; + if (pc.opt.x > 1.5) { + imageStore(scene, px, vec4(vis, vis, vis, 1.0)); + return; + } + if (vis <= 0.0 && pc.opt.x < 0.5) return; vec3 p = view_pos(uv, z); // A contact shadow can only take away direct sunlight, and a surface turned away from the sun gets none: its march // runs into the surface itself at once, and darkening it would darken the ambient light and the fog the composite @@ -84,7 +93,7 @@ void main() { } } float fade = 1.0 - smoothstep(40.0, 80.0, z); - float k = 1.0 - pc.proj.w * occ * fade * lit; + float k = 1.0 - pc.proj.w * occ * fade * lit * vis; if (pc.opt.x > 0.5) { imageStore(scene, px, vec4(k, k, k, 1.0)); return; diff --git a/runtime/vk_contact.c b/runtime/vk_contact.c index 10944798..ff428fb0 100644 --- a/runtime/vk_contact.c +++ b/runtime/vk_contact.c @@ -18,9 +18,17 @@ // a view-space position toward // the sun (the G-buffer shaders compare dot(c4[44].xyz, pos) + c4[44].w with the cascade map). The scene colour images // get STORAGE usage when the setting is on (vk_texture.c create_tex). +// +// Only sunlit pixels are darkened. The composite reads a half-resolution lighting pass (eight targets at half the scene +// size, the first RGBA8) whose first target's alpha is the sun's visibility: 1 in the sun, 0 in the shadow maps' +// shadow and everywhere underground (found by comparing frame dumps of a sunny path and a cave). The march's darkening +// is scaled by it, so a contact shadow takes away direct sunlight and leaves the ambient light and textures alone; +// darkening the whole colour turned caves flat, where nearly every ray toward the sun meets the rock overhead. Without +// that pass in the frame every pixel is darkened as before. TOTK_CONTACT_DEBUG=2 shows the visibility in grey. #include "vk.h" #include +#include #include #include "cfg.h" @@ -36,6 +44,7 @@ static struct { VkPipeline pipe; VkSampler sampler; VkExecTarget scene, depth; // the last G-buffer's scene colour and linear depth + VkExecTarget sun; // this frame's half-resolution lighting target (is_lighting); no img: none seen int pending; // the composite into scene ran; the march waits for the next pass uint64_t c4; } C; @@ -53,17 +62,19 @@ static int init(VkCtx *c) { C.tried = 1; vk_contact_strength(); if (!C.strength) return 0; - const char *e = cfg_get("TOTK_CONTACT_DEBUG"); // 1: the frame shows the contact shadow factor in grey - C.debug = e && *e && strcmp(e, "0"); + const char *e = cfg_get("TOTK_CONTACT_DEBUG"); // 1: the contact shadow factor in grey, 2: the sun visibility + C.debug = e ? atoi(e) : 0; C.push = (PFN_vkCmdPushDescriptorSetKHR)vkGetDeviceProcAddr(c->device, "vkCmdPushDescriptorSetKHR"); - VkDescriptorSetLayoutBinding b[2] = { + VkDescriptorSetLayoutBinding b[3] = { {.binding = 0, .descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, .descriptorCount = 1, .stageFlags = VK_SHADER_STAGE_COMPUTE_BIT}, {.binding = 1, .descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, .descriptorCount = 1, + .stageFlags = VK_SHADER_STAGE_COMPUTE_BIT}, + {.binding = 2, .descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, .descriptorCount = 1, .stageFlags = VK_SHADER_STAGE_COMPUTE_BIT}}; VkDescriptorSetLayoutCreateInfo dci = {.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO, .flags = VK_DESCRIPTOR_SET_LAYOUT_CREATE_PUSH_DESCRIPTOR_BIT_KHR, - .bindingCount = 2, .pBindings = b}; + .bindingCount = 3, .pBindings = b}; VkPushConstantRange pr = {VK_SHADER_STAGE_COMPUTE_BIT, 0, 64}; VkPipelineLayoutCreateInfo li = {.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO, .setLayoutCount = 1, .pSetLayouts = &C.dsl, .pushConstantRangeCount = 1, .pPushConstantRanges = &pr}; @@ -91,7 +102,8 @@ static int init(VkCtx *c) { rt_log("vk: contact shadows off: their pipeline could not be created"); return 0; } - rt_log("vk: contact shadows on, strength %d%%%s", C.strength, C.debug ? " (debug view)" : ""); + rt_log("vk: contact shadows on, strength %d%%%s", C.strength, + C.debug == 2 ? " (debug view: sun visibility)" : C.debug ? " (debug view)" : ""); return C.ok = 1; } @@ -118,6 +130,13 @@ static void mem_barrier(VkCommandBuffer cb) { vkCmdPipelineBarrier2(cb, &d); } +// The half-resolution lighting pass after the G-buffer: eight targets at half the scene's size, the first RGBA8. +static int is_lighting(const VkExec *ex) { + const VkExecTarget *t = &ex->color[0]; + return C.scene.image && ex->pass_ncolor == 8 && t->image && t->img && !t->level && + t->format == VK_FORMAT_R8G8B8A8_UNORM && ex->pass_w * 2 == C.scene.width && ex->pass_h * 2 == C.scene.height; +} + // The lighting composite: the remembered scene colour as the only target, with a D16 depth of its size. static int is_composite(const VkExec *ex) { return C.scene.image && ex->pass_ncolor >= 1 && ex->color[0].image == C.scene.image && !ex->color[0].level && @@ -134,7 +153,11 @@ int vk_contact_plan(const VkExec *ex, int pass, VkExecJob *j) { if (b->addr && b->size == 0x940) C.c4 = b->addr; if (is_gbuffer(ex, &scene, &depth)) { C.pending = 0; - C.scene = *scene, C.depth = *depth; + C.scene = *scene, C.depth = *depth, C.sun = (VkExecTarget){0}; + return 0; + } + if (is_lighting(ex)) { + C.sun = ex->color[0]; return 0; } if (is_composite(ex)) { @@ -149,7 +172,7 @@ int vk_contact_plan(const VkExec *ex, int pass, VkExecJob *j) { float px = u[7 * 4 + 0], py = u[8 * 4 + 1], zfar = u[14 * 4 + 1]; if (!(ll > 1e-6f) || !(px > 0) || !(py > 0) || !(zfar > 1)) return 0; float w = (float)C.scene.width, h = (float)C.scene.height; - *j = (VkExecJob){.scene = C.scene, .depth = C.depth, + *j = (VkExecJob){.scene = C.scene, .depth = C.depth, .sun = C.sun, .pc = {px, py, zfar, (float)C.strength / 100.0f, lx / ll, ly / ll, lz / ll, 0.6f, w, h, 1.0f / w, 1.0f / h, @@ -165,6 +188,9 @@ void vk_contact_exec(VkExec *ex, const VkExecJob *j) { VkImageView out = vk_exec_target_view(j->scene.img, VK_FORMAT_B10G11R11_UFLOAT_PACK32, VK_IMAGE_VIEW_TYPE_2D, VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1, 0); if (!in || !out) return; + VkImageView sun = j->sun.img ? vk_exec_target_view(j->sun.img, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_VIEW_TYPE_2D, + VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1, 0) + : VK_NULL_HANDLE; // A full barrier that also takes the images in the feedback layout back to GENERAL (vk_exec.c barrier_to): the // G-buffer's linear depth and scene colour are such images once a draw sampled them in their own pass, and the march // binds them in GENERAL. A memory barrier alone left them in ATTACHMENT_FEEDBACK_LOOP_OPTIMAL_EXT. @@ -173,19 +199,24 @@ void vk_contact_exec(VkExec *ex, const VkExecJob *j) { float pcv[16]; memcpy(pcv, j->pc, sizeof pcv); pcv[12] = (float)C.debug; + pcv[13] = sun ? 1.0f : 0.0f; if (!C.logged) { C.logged = 1; - rt_log("vk: contact shadows on a %ux%u scene, sun toward %.3f %.3f %.3f (view space), far %g", j->scene.width, j->scene.height, - pcv[4], pcv[5], pcv[6], pcv[2]); + rt_log("vk: contact shadows on a %ux%u scene, sun toward %.3f %.3f %.3f (view space), far %g; %s", j->scene.width, + j->scene.height, pcv[4], pcv[5], pcv[6], pcv[2], + sun ? "sunlit pixels only" : "no sun visibility found: every pixel"); } - VkDescriptorImageInfo ii = {C.sampler, in, VK_IMAGE_LAYOUT_GENERAL}, oi = {VK_NULL_HANDLE, out, VK_IMAGE_LAYOUT_GENERAL}; - VkWriteDescriptorSet w[2] = { + VkDescriptorImageInfo ii = {C.sampler, in, VK_IMAGE_LAYOUT_GENERAL}, oi = {VK_NULL_HANDLE, out, VK_IMAGE_LAYOUT_GENERAL}, + si = {C.sampler, sun ? sun : in, VK_IMAGE_LAYOUT_GENERAL}; // not read without a sun view + VkWriteDescriptorSet w[3] = { {.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET, .dstBinding = 0, .descriptorCount = 1, .descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, .pImageInfo = &ii}, {.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET, .dstBinding = 1, .descriptorCount = 1, - .descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, .pImageInfo = &oi}}; + .descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, .pImageInfo = &oi}, + {.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET, .dstBinding = 2, .descriptorCount = 1, + .descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, .pImageInfo = &si}}; vkCmdBindPipeline(cb, VK_PIPELINE_BIND_POINT_COMPUTE, C.pipe); - rec_push(C.push, cb, VK_PIPELINE_BIND_POINT_COMPUTE, C.layout, 0, 2, w); + rec_push(C.push, cb, VK_PIPELINE_BIND_POINT_COMPUTE, C.layout, 0, 3, w); vkCmdPushConstants(cb, C.layout, VK_SHADER_STAGE_COMPUTE_BIT, 0, sizeof pcv, pcv); vkCmdDispatch(cb, (j->scene.width + 7) / 8, (j->scene.height + 7) / 8, 1); mem_barrier(cb); // and what follows sees the darkened colour diff --git a/runtime/vk_exec.h b/runtime/vk_exec.h index 865d89db..6df46b92 100644 --- a/runtime/vk_exec.h +++ b/runtime/vk_exec.h @@ -69,6 +69,8 @@ typedef struct VkExecJob { int chunk; // vk_exec.c: the chunk that holds the op VkExecTarget scene, depth; // contact: the scene colour and the linear depth; DLSS: the light target to copy // (mask) or the scaling pass's target (evaluation; no tex: in place) + VkExecTarget sun; // contact: the half-resolution lighting target whose alpha is sun visibility + // (no img: none in this frame) float pc[16]; // the march's push constants } VkExecJob; From 43bd965e6952887df90a214d5ac4f6225b82e9ca Mon Sep 17 00:00:00 2001 From: Valiantsin Dzerakh Date: Thu, 19 Nov 2026 21:00:43 +0300 Subject: [PATCH 2/2] A chunked replay's contact shadow march takes the lighting target's image at the time it records, as it does the scene colour and the linear depth, not the entry the scan saw Co-Authored-By: Claude Opus 5.5 --- runtime/vk_exec.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/runtime/vk_exec.c b/runtime/vk_exec.c index 3ff91b2d..0ef4a57c 100644 --- a/runtime/vk_exec.c +++ b/runtime/vk_exec.c @@ -1046,8 +1046,11 @@ static void run_job(VkExec *ex) { if (j.kind != VK_JOB_CONTACT) { vk_dlaa_exec(ex, &j); } else { - // The scan resolved the scene and its depth without creating entries (vk_texture_revive): their images now. + // The scan resolved the scene, its depth and the lighting target without creating entries (vk_texture_revive): + // their images now. A lighting target without one leaves the march darkening every pixel. const VkTexImage *si = vk_texture_get(j.scene.tex), *di = vk_texture_get(j.depth.tex); + const VkTexImage *ui = j.sun.img ? vk_texture_get(j.sun.tex) : NULL; + j.sun.img = ui, j.sun.image = ui ? ui->image : VK_NULL_HANDLE; if (si && di) { j.scene.img = si, j.scene.image = si->image, j.depth.img = di, j.depth.image = di->image; vk_contact_exec(ex, &j);