Merge task/cascade: shadow_range moves the sun cascades on 1.2.1 and 1.4.3, from pull requests #1258 and #1254 (shinodanpen, #606)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Valiantsin DzerakhandClaude Opus 5.5 committed 2026-11-17 20:03:05 +03:00
commit a36e7917da
3 files changed
+29 -3

No files matched your search

+13
View File
@@ -11,6 +11,7 @@ set output TOTK_PATCH_OUTPUT 0
set scene TOTK_PATCH_SCENE 0
set shadow TOTK_PATCH_SHADOW 0
set grass TOTK_PATCH_GRASS 0
set cascade TOTK_PATCH_CASCADE 0
# 60 fps: the adaptive present-interval controller (main+0x8f26c8, 1.0.0 0x8f6bec) gets the minimum interval 1.
site fps60 main 8f273c 6b08015f 7100055f # clamp: cmp w10, #1 (was cmp w10, w8 = minimum)
@@ -1144,6 +1145,18 @@ spin sdk 3d3250 3d3270 # 9 instructions; loads
# computation). Found by a write watch on the size field (the writer was this function, and no other).
site shadow main cec22c 11001d6b @page:x11 b9405d6b 11001d6b # add w11, w11, #7 -> adrp x11, page; ldr w11, [x11, #92]; add w11, w11, #7
# Sun shadow cascade distances (runtime/resolution.c res_shadow_range switches the set on; issue #606). On 1.2.1 the
# depth shadow parameters (depth_shadow_near_0_0..3 and depth_shadow_far_0, whose constructor defaults at
# main+0x114c2f8.. are 20, 40, 80, 160 and 2000 m) do not reach the sun's cascades: the game's shadow controller sets
# bit 1 of the scene's depth shadow flags when it starts (main+0xc7b0e8), and with that bit the per-view update
# (main+0xa2cff4) skips its copy of those parameters into the cascade boundaries. The controller writes the boundaries
# itself each frame in main+0xcebdf4: d[0] at main+0xcec2ac, d[1..n-1] at main+0xcec314 and the far d[n] at
# main+0xcec36c (d = [cascade set + 0x308], read by main+0xa2d6ec). The set multiplies d[1..n] where they are stored,
# by page +64 (20 m times shadow_range / 100) over 20; d[0], the first cascade's start, stays. x3, s16 and s17 are
# dead at both sites.
site cascade main cec314 bd000446 @page:x3 bd404070 1e269011 1e311a10 1e3008d0 bd000450 # str s6, [x2, #4] -> adrp x3, page; ldr s16, [x3, #64]; fmov s17, #20.0; fdiv s16, s16, s17; fmul s16, s6, s16; str s16, [x2, #4]
site cascade main cec36c bc29d945 @page:x3 bd404070 1e269011 1e311a10 1e3008b0 bc29d950 # str s5, [x10, w9, sxtw #2] -> the same with fmul s16, s5, s16; str s16, [x10, w9, sxtw #2]
# Grass range (runtime/resolution.c res_grass_range; patches-v143.txt describes the set and the page). The near grass
# map's constructor loads its extent, step and texture sizes at main+0xfe58b4..0xfe5950, and main+0x1a30a28 sets the
# extent to 62.5 or 31.25 m, as on 1.4.3.
+12
View File
@@ -1104,6 +1104,18 @@ site cascade main 6fabb8 52a83408 @page:x8 b9404108 # mov w8, #20.0 -> ldr w8
site cascade main 6fac40 52a84408 @page:x8 b9404508 # mov w8, #40.0 -> ldr w8, [page+68]
site cascade main 6facc8 52a85408 @page:x8 b9404908 # mov w8, #80.0 -> ldr w8, [page+72]
site cascade main 6fad4c 52a86408 @page:x8 b9404d08 # mov w8, #160.0 -> ldr w8, [page+76]
# The four sites above reach the cascades only through the copy of the parameters into the cascade boundaries
# (main+0x5680ec, in the per-view update). The game's shadow controller sets bit 1 of the scene's depth shadow flags
# when it starts (main+0xb74494), with that bit the per-view update skips the copy (main+0x567f6c), and the controller
# writes the boundaries itself each frame in main+0x68318c: d[0] at main+0x683680, d[1..n-1] at main+0x6836ec and the
# far d[n] at main+0x683740 (d = [cascade set + 0x308]). In Hyrule Field the four sites alone leave the cascades as
# they are at 100 (issue #606 has the same on 1.2.1). These two multiply d[1..n] where the controller stores them, by
# page +64 (20 m times shadow_range / 100) over 20; d[0], the first cascade's start, stays. The function computes the
# boundaries from the controller's own fields and its arguments and reads neither the parameters nor d, so a boundary
# is scaled once on either path. x25 (written at main+0x683704 before any read), x16, s18 and s19 are dead at the
# sites.
site cascade main 6836ec bd000711 @page:x25 bd404332 1e269013 1e331a52 1e320a32 bd000712 # str s17, [x24, #4] -> adrp x25, page; ldr s18, [x25, #64]; fmov s19, #20.0; fdiv s18, s18, s19; fmul s18, s17, s18; str s18, [x24, #4]
site cascade main 683740 bc2ed9b0 @page:x16 bd404212 1e269013 1e331a52 1e320a12 bc2ed9b2 # str s16, [x13, w14, sxtw #2] -> the same through x16 with fmul s18, s16, s18; str s18, [x13, w14, sxtw #2]
# Climbing (issues #35, #276, #1001): the climb controller's velocity step (main+0x1f49754, shared by wall and ladder
# climbing, climb jumps and climb-overs) multiplies the requested velocity by a factor that makes up for a movement loss
+4 -3
View File
@@ -510,9 +510,10 @@ static void shadow_init(uint8_t *page) {
// ---- start: the patch page and the sets
static uint64_t pack(unsigned w, unsigned h) { return (uint64_t)h << 32 | w; }
// TOTK_SHADOW_RANGE (percent, 50 to 400; 100 = the game's): the sun's shadow cascades end at 20, 40, 80 and 160 m.
// Other values multiply those distances through the cascade patch set (recomp/patches-v143.txt), so the sharp first
// cascade reaches further and the visible steps between cascades move away from the player, at the cost of shadow
// TOTK_SHADOW_RANGE (percent, 50 to 400; 100 = the game's): the sun's shadow cascades end at 20, 40, 80 and 160 m by
// the depth shadow parameters' defaults; in the field the shadow controller computes the boundaries from the camera
// each frame instead. Other values multiply the boundaries through the cascade patch set (recomp/patches-v143.txt and
// patches-v121.txt; the controller's sites take page +64 over 20 as the factor), so the sharp first cascade reaches further and the visible steps between cascades move away from the player, at the cost of shadow
// texels per metre (TOTK_SHADOW_SCALE pays that back).
static void res_shadow_range(void) {
int pct = cfg_int("TOTK_SHADOW_RANGE"), set = rt_patch_set("cascade");