Model detail range replaces the distant detail switch: lod_range scales the depth at which models leave their detailed level (1x, 1.5x, 2x, 3x or max) (#949)

The pick patched before (main+0x1ee8424) is reached through its vtable only when the method is overridden; the culling
passes run about 20 inlined copies of it, so the switch changed almost nothing. The lodrange set patches the two places
per version that compute the level depth B at model setup (the setter and its inlined copy); the slope of the coarser
levels follows from B there, and max takes B = 1e30. The menu row sits under Grass range, with Steady detail under load
after it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Valiantsin DzerakhandClaude Opus 5.5 committed 2026-11-14 21:58:48 +03:00
1 parent 517a161457
commit cf3acd0a2f
11 files changed
+92 -48

No files matched your search

+3 -2
View File
@@ -12,8 +12,9 @@ set output TOTK_PATCH_OUTPUT 0
set scene TOTK_PATCH_SCENE 0
set shadow TOTK_PATCH_SHADOW 0
set cascade TOTK_PATCH_CASCADE 0
# Distant detail (patches-v121.txt explains both): no sites found in this version yet, so the switches do nothing.
set lod TOTK_LOD_DETAIL 0
# Model level of detail and load-dependent quality (patches-v121.txt explains both): no sites found in this version
# yet, so the settings do nothing.
set lodrange TOTK_PATCH_LODRANGE 0
set steady TOTK_LOD_STEADY 0
# 60 fps: the adaptive present-interval controller (main+0x8f26c8, 1.0.0 0x8f6bec) gets the minimum interval 1.
+15 -12
View File
@@ -143,18 +143,21 @@ set pooloff TOTK_POOL_OFFSET_PATCH 1
site pooloff main ad43f0 93407f22 2a1903e2 # sxtw x2, w25 -> mov w2, w25 (SetStorage offset)
site pooloff main ad440c 8b39c101 8b394101 # add x1, x8, w25, sxtw -> add x1, x8, w25, uxtw (packaged data source)
# Distant detail, after the emulator mods "LOD Improvement v2" (theboy181, sweetmini) and "Disable LOD Quality
# Reduction" (main-1.2.1.pchtxt). Those turn a conditional branch into an unconditional one; the generator patches
# only plain instructions (recomp/gen.py, the emitter's patch), so these sites feed the branch instead.
# Model level of detail: the level picker main+0x27d225c (a virtual method, vtable slot at data 0x43723f0) returns the
# floor at its parameters' +0x28 when the distance term is past the threshold, and otherwise interpolates towards the
# coarsest level; a one-level model returns count - 1 (0) at once. Here every model takes that early return, with the
# floor in w0, so distant models keep the detail they have up close. Unlike the mod, a one-level model still returns 0:
# the floor is not checked against the level count, and an index past a one-level list would read past its end.
set lod TOTK_LOD_DETAIL 0
# A site may use the flags only once, so the one-level case is a mask (all ones unless count - 1 is 0) on the floor.
site lod main 27d2264 71000520 5100052b 4b0b03ec 2a0b018c 131f7d8c b9402840 0a0c0000 6b00001f # subs w0, w9, #1 -> sub w11, w9, #1; neg w12, w11; orr w12, w12, w11; asr w12, w12, #31; ldr w0, [x2, #0x28]; and w0, w0, w12; cmp w0, w0 (b.eq taken)
# Load-dependent quality: the graphics settings setup (main+0xc7e9xx, it also reads the FSR and FXAA switches) walks a
# Model level of detail (runtime/resolution.c res_lod_range switches the set on). Each model unit keeps one record per
# view with a depth B, a second value 1.0 and a slope S = 1/(B - 1); the level pick (the virtual method main+0x27d225c
# and its inlined copies in the culling passes) keeps the most detailed level while the depth along the camera axis is
# within B and moves to coarser levels evenly up to B + 1/S. Most picks run the inlined copies, so the sites are where
# B is computed at model setup instead: the setter main+0x10eca28 (it saves B in s9 and derives S from it) and its
# inlined copy in main+0x925808. Both replace B with k * B + c from page +96 and +100 (k = 1.5, 2 or
# 3 with c = 0 moves every transition about k times farther; k = 1, c = 1e30 keeps the most detailed level at any
# depth). The models of an area take the value when they are set up, so a change shows after a restart.
set lodrange TOTK_PATCH_LODRANGE 0
site lodrange main 10eca44 4ea01c09 @page:x8 2d4c0d02 1f020c00 4ea01c09 # mov v9.16b, v0.16b -> ldp s2, s3, [page+96]; fmadd s0, s0, s2, s3; mov v9.16b, v0.16b (x8, s2, s3 free here)
site lodrange main 925838 1e292100 @page:x8 2d4c0500 1f000508 1e292100 # fcmp s8, s9 -> ldp s0, s1, [page+96]; fmadd s8, s8, s0, s1; fcmp s8, s9 (x8 reloaded at +0x18, s0/s1 rewritten before use)
# Load-dependent quality, after the emulator mod "Disable LOD Quality Reduction" (main-1.2.1.pchtxt), which turns a
# conditional branch into an unconditional one; the generator patches only plain instructions (recomp/gen.py, the
# emitter's patch), so the site feeds the branch instead. The graphics settings setup (main+0xc7e9xx, it also reads the
# FSR and FXAA switches) walks a
# list at its +0x120 and passes three floats of each entry to virtual setters, which the mod describes as the drop of
# model and texture detail when the frame rate falls; it skips all of it, to the epilogue, when the value it reads at
# main+0xc7eb24 is above 8. Reading 9 there skips it as the mod does; w21 is not read again on that path (the epilogue
+8 -5
View File
@@ -13,11 +13,14 @@ set scene TOTK_PATCH_SCENE 0
set shadow TOTK_PATCH_SHADOW 0
set cascade TOTK_PATCH_CASCADE 0
set grass TOTK_PATCH_GRASS 0
# Distant detail (patches-v121.txt explains both). The level picker main+0x1ee8424 is 1.2.1's main+0x27d225c with the
# same first words, and its early b.eq goes straight to the ret, so the 1.2.1 site words fit as they are.
set lod TOTK_LOD_DETAIL 0
site lod main 1ee842c 71000520 5100052b 4b0b03ec 2a0b018c 131f7d8c b9402840 0a0c0000 6b00001f # subs w0, w9, #1 -> the 1.2.1 words (one-level mask, floor in w0, cmp w0, w0: b.eq taken)
# The graphics settings setup (main+0x5868c4) inlines the three getters 1.2.1 calls: the value 1.2.1 reads at
# Model level of detail (patches-v121.txt explains the set; runtime/resolution.c res_lod_range switches it on). The
# setter main+0xc3dbe4 (1.2.1 0x10eca28) takes B in s0 and computes S = 1/(B - 1) after its entry compare, and
# main+0x3b8490 (1.2.1 0x925808) is its inlined copy; both scale B before the compare, so S follows.
set lodrange TOTK_PATCH_LODRANGE 0
site lodrange main c3dbe4 1e212000 @page:x8 2d4c1103 1f031000 1e212000 # fcmp s0, s1 -> ldp s3, s4, [page+96]; fmadd s0, s0, s3, s4; fcmp s0, s1 (x8 written before any read, s3 written at +0xc, s4 unused)
site lodrange main 3b84d0 1e212000 @page:x8 2d4c0d02 1f020c00 1e212000 # fcmp s0, s1 -> ldp s2, s3, [page+96]; fmadd s0, s0, s2, s3; fcmp s0, s1 (x8 reloaded at +0x18, s2/s3 dead)
# Load-dependent quality (patches-v121.txt, set steady). The graphics settings setup (main+0x5868c4) inlines the
# three getters 1.2.1 calls: the value 1.2.1 reads at
# main+0xc7eb24 is the ldr w10, [x10, #0x38] at main+0x58692c, and the getters' slow paths (main+0x586bc8, 0x586c18,
# 0x586f44) come back before the compare. So the site is the compare, which every path reaches: w10 = 9 skips the
# list walk to the epilogue (main+0x58729c), which does not read w10.
+2 -1
View File
@@ -17,7 +17,8 @@ of the 2 MiB-aligned module slot free); the runtime commits it and owns its cont
+0..15 the frame-rate step (runtime/frame_rate.c), +16..55 the output, swapchain and scene sizes
(runtime/resolution.c res_init), +56..59 the camera's aspect ratio (runtime/resolution.c res_init, set aspect), +60..63
the field-of-view factor (runtime/resolution.c res_fov_live, set fov), +92..95 the sun shadow map size
(runtime/resolution.c shadow_init, set shadow). A new set takes words outside these.
(runtime/resolution.c shadow_init, set shadow), +96..103 the model detail depth factor and offset
(runtime/resolution.c res_lod_range, set lodrange). A new set takes words outside these.
The replacement words are lifted at the site's address in place of the original instruction, and the generated C reads
`if (rt_patch_on[<set>]) { replacement } else { original }`: one byte load and a branch per executed site. Several