From ce156ff76bcb48b1f1527b2aff102ae1f70061c3 Mon Sep 17 00:00:00 2001 From: itaskaev2 <165683571+itaskaev2@users.noreply.github.com> Date: Tue, 24 Nov 2026 23:02:37 +0100 Subject: [PATCH] Keep the 16:9 width of the view at shapes narrower than 16:9 (vert_plus) (#632) The camera kept the game's vertical view angle at every shape, so 16:10, 3:2 and 4:3 showed less of the world at the sides than 16:9. res_fov_live now also multiplies the fov patch's factor by 2 atan(tan(v/2) k) / v, k = 16:9 over the aspect and v = 51.2 degrees, the game's default vertical angle measured from a 4:3 frame at fov 130 against 16:9 (scale 0.730). Measured after: 4:3 frames are 16:9 ones scaled by 0.752 (0.750 is exact), 16:10 by 1.000 (1.106 without). vert_plus = 0 keeps the game's vertical view; it multiplies with fov. Co-Authored-By: Claude Opus 5.5 --- runtime/cfg.c | 5 +++-- runtime/resolution.c | 43 ++++++++++++++++++++++++++++++++++--------- totk.ini.example | 9 +++++++-- 3 files changed, 44 insertions(+), 13 deletions(-) diff --git a/runtime/cfg.c b/runtime/cfg.c index d8919a6a..2d89ca04 100644 --- a/runtime/cfg.c +++ b/runtime/cfg.c @@ -66,7 +66,7 @@ static const char *const known[] = { "SHADER_MEMO", "SHADOW", "SHADOW_DEFER", "SHADOW_RANGE", "SHADOW_RES", "SHADOW_SCALE", "SHADOW_SNAP", "SHARED_FONTS", "SHARPNESS", "SHOTS", "SHOTS_DIR", "SHUTTER_FIX", "SHOTS_FULL", "SKIP_CS", "SPEED_PROBE", "SPIN", "SPIN_HANDOFF_US", "SPLIT_DRAWS", "SPLIT_US", "STICK_DEADZONE", "STICK_SENS", "SWKBD_ANSWER", "SYNC_AHEAD", - "SWKBD_TEST", "TEST_OOM", "TEST_PAD", "TEST_PAD_RUMBLE_MS", "TEST_PREPARE_SHADERS", "TEX_ALIAS", "TEX_BLOCK_MIB", "TEX_HEAP_EXTRA_MB", "TEX_MEMO", "TEX_RELEASED_MIB", "TEX_VRAM_PRESSURE", "TIMER_1MS", "TRACE", "TXD_TRANSPOSE", "UBO_SNAPSHOT", "UB_OVERLAY", "UB_OVERLAY_OUT", "UPSCALER", "VB_USED", "VK_DYN_A2C", "VK_DYN_VERTEX", "VK_NO_FLOAT64", "VK_NO_HOST_IMPORT", + "SWKBD_TEST", "TEST_OOM", "TEST_PAD", "TEST_PAD_RUMBLE_MS", "TEST_PREPARE_SHADERS", "TEX_ALIAS", "TEX_BLOCK_MIB", "TEX_HEAP_EXTRA_MB", "TEX_MEMO", "TEX_RELEASED_MIB", "TEX_VRAM_PRESSURE", "TIMER_1MS", "TRACE", "TXD_TRANSPOSE", "UBO_SNAPSHOT", "UB_OVERLAY", "UB_OVERLAY_OUT", "UPSCALER", "VB_USED", "VERT_PLUS", "VK_DYN_A2C", "VK_DYN_VERTEX", "VK_NO_FLOAT64", "VK_NO_HOST_IMPORT", "VK_PRESENT", "VK_RECORDER", "VK_SSBO_ALIGN", "VK_SUBGROUP", "VK_SUBGROUP_PIN", "VK_VALIDATION", "VMA_BLOCK_MIB", "VOLUME", "VOLUME_MASK_BIAS", "VOLUME_MUSIC", "VOLUME_SFX", "VOLUME_VOICE", "VRAM_HEADROOM", "VRAM_LIMIT_MIB", "VS_OUTS", "WALK_KEY", "WALK_SCALE", "WB_EAGER", "WB_EXACT", "WB_FENCE_LIMIT", "WB_MERGE", "WINDOW_SIZE", "XLATE", "XLATE_ID", "XLATE_KEEP", "XLATE_PROCS", "ZSTD_CHECK", "ZSTD_NATIVE", @@ -81,7 +81,7 @@ static const struct { const char *key, *section; } sections[] = { {"FULLSCREEN", "display"}, {"WINDOW_SIZE", "display"}, {"PERF_OVERLAY", "display"}, {"VK_PRESENT", "display"}, {"GPU_INDEX", "display"}, {"OUTPUT_RES", "display"}, {"RENDER_SCALE", "display"}, {"UPSCALER", "display"}, {"HUD_WIDTH", "display"}, - {"SHARPNESS", "display"}, {"DYNAMIC_RES", "display"}, {"ASPECT", "display"}, {"MOVIE_ASPECT", "display"}, {"FOV", "display"}, {"ANISO", "display"}, + {"SHARPNESS", "display"}, {"DYNAMIC_RES", "display"}, {"ASPECT", "display"}, {"MOVIE_ASPECT", "display"}, {"FOV", "display"}, {"VERT_PLUS", "display"}, {"ANISO", "display"}, {"LOD_STEADY", "display"}, {"COLOR_PRESET", "display"}, {"COLOR_BRIGHTNESS", "display"}, {"COLOR_CONTRAST", "display"}, {"COLOR_SATURATION", "display"}, {"COLOR_GAMMA", "display"}, {"HDR", "display"}, {"HDR_PEAK_NITS", "display"}, {"HDR_GAME_NITS", "display"}, @@ -149,6 +149,7 @@ static const CfgMeta metas[] = { {"DLSS_CHAR_MASK", "65", "0|35|65|100", LIVE}, {"REFLEX", "off", "off|auto|on|boost", RESTART}, {"FXAA", "1", "0|1", LIVE}, {"LOD_STEADY", "0", "0|1", RESTART}, // sets steady {"ASPECT", "fit", "fit|stretch", LIVE}, {"MOVIE_ASPECT", "keep", "keep|stretch", LIVE}, {"FOV", "100", "70..140", LIVE}, + {"VERT_PLUS", "1", "0|1", LIVE}, // resolution.c res_fov_live {"ANISO", "game", "game|2|4|8|16", RESTART}, // vk_texture.c sampler_features // colour adjustment (vk_color.c); the preset is the menu's, the four values are what the present uses {"COLOR_PRESET", "default", "default|vivid|clarity|custom", LIVE}, {"COLOR_BRIGHTNESS", "0", "-30..30", LIVE}, diff --git a/runtime/resolution.c b/runtime/resolution.c index 465105c1..fd18b71c 100644 --- a/runtime/resolution.c +++ b/runtime/resolution.c @@ -44,6 +44,8 @@ #include "ov.h" #include "platform/platform.h" +static void vert_plus_init(double ratio_over_16x9); + #define BASE_W 1920 #define BASE_H 1080 #define SCENE_W 1600 @@ -643,6 +645,7 @@ void res_init(void) { memcpy(page + 56, &r, sizeof r); rt_patch_switch(aspect, 1); rt_log("resolution: camera aspect ratio %.4f (16:9 is %.4f)", ratio, game); + if (ratio < game) vert_plus_init(ratio / game); } } else { rt_patch_switch(aspect, 0); // the page holds no ratio @@ -673,25 +676,47 @@ int res_wants_wide_overlay(const unsigned out[2]) { // Field of view (TOTK_FOV, percent of the game's own, 70..140, live): the camera's vertical view angle times the factor // on page +60 (recomp/patches-v110.txt, patches-v121.txt and patches-v143.txt, set fov). The horizontal angle follows -// through the aspect ratio. 100 switches the set off, so the camera code is the game's own. Runs on a settings change -// (gfx_present.c window_settings_live), the first time at the first present. +// through the aspect ratio. A factor of 1 switches the set off, so the camera code is the game's own. Runs on a settings +// change (gfx_present.c window_settings_live), the first time at the first present. +// +// Vert+ (TOTK_VERT_PLUS, on by default): the camera keeps the game's vertical view angle at every shape, so a shape +// narrower than 16:9 (16:10, 3:2, 4:3) showed less of the world at the sides than 16:9 does. The factor is then also +// multiplied by the one that gives the game's default view the horizontal angle it has at 16:9: tan(v'/2) = tan(v/2) +// * (16/9) / aspect, so v' / v = 2 atan(tan(v/2) k) / v with k = 16:9 over the aspect. v is the game's default +// vertical angle, 51.2 degrees, measured on 1.4.3 at Lookout Landing: a 4:3 frame at TOTK_FOV=130 is a 16:9 frame of +// the same moment scaled by 0.730 about its middle (tan(v/2) / tan(1.3 v/2) = 0.730 gives v = 51.2). The patch scales +// the angle linearly, so a zoomed view (the bow, the scope) gets the same factor, a few percent short of the exact one. #define FOV_MIN 70 #define FOV_MAX 140 +#define VERT_PLUS_V (51.2 * 3.14159265358979 / 180) +static float vert_plus_k = 1; // set by res_init (vert_plus_init) for a camera narrower than 16:9 + +static void vert_plus_init(double ratio_over_16x9) { + double k = 1 / ratio_over_16x9, v = VERT_PLUS_V; + vert_plus_k = (float)(2 * atan(tan(v / 2) * k) / v); +} + void res_fov_live(void) { - static int set = -2, shown = 100; + static int set = -2, shown = 100, shown_vp = -1; if (set == -2) set = rt_patch_set("fov"); int pct = cfg_int("TOTK_FOV"); pct = pct < FOV_MIN ? FOV_MIN : pct > FOV_MAX ? FOV_MAX : pct; - if (pct == shown) return; - shown = pct; + int vp = vert_plus_k != 1 && cfg_bool("TOTK_VERT_PLUS"); + if (pct == shown && vp == shown_vp) return; + shown = pct, shown_vp = vp; if (set < 0) { - rt_log("resolution: this game version has no field-of-view patch; TOTK_FOV=%d does nothing", pct); + if (pct != 100 || vp) + rt_log("resolution: this game version has no field-of-view patch; TOTK_FOV=%d and Vert+ do nothing", pct); return; } - float k = pct / 100.0f; + float k = pct / 100.0f * (vp ? vert_plus_k : 1); memcpy((uint8_t *)rt_patch_page() + 60, &k, sizeof k); // before the switch: a site that sees it on reads k - rt_patch_switch(set, pct != 100); - rt_log("resolution: field of view %d%% of the game's", pct); + rt_patch_switch(set, k != 1); + if (vp) + rt_log("resolution: field of view %d%% of the game's, times %.4f for Vert+ (the 16:9 width at this narrower " + "shape)", pct, vert_plus_k); + else + rt_log("resolution: field of view %d%% of the game's", pct); } // TOTK_DYNAMIC_RES = 0 holds the game's dynamic resolution at 100 % (patches-v110.txt, patches-v121.txt and patches-v143.txt, diff --git a/totk.ini.example b/totk.ini.example index b5b98cc9..d838e4c5 100644 --- a/totk.ini.example +++ b/totk.ini.example @@ -225,8 +225,8 @@ # screens streamed to (2340x1080 or 3120x1440 at 19.5:9, 2400x1080 at 20:9). The installer makes the UI layout for the # shapes of the connected displays and of this setting; at a shape it has none for, the game draws the largest 16:9 # size that fits inside it with bars and makes the layout in the background for the next start (a source build: make -# it with tools/make_romfs_patches.py --aspect WxH). A shape narrower than 16:9 keeps the game's vertical view, so it -# shows less at the sides; fov widens it. Portrait shapes and shapes outside 4:3..32:9 draw 16:9 with bars. Read at +# it with tools/make_romfs_patches.py --aspect WxH). A shape narrower than 16:9 keeps the width of the 16:9 view and +# shows more above and below (vert_plus). Portrait shapes and shapes outside 4:3..32:9 draw 16:9 with bars. Read at # start. Default: 1920x1080, or on a primary display of 21:9, 32:9, 16:10, 3:2 or 4:3 the smallest size of that shape # at least 1080 high that fits the display (1920x1280 on a 3:2 laptop, 2560x1080 on a 21:9 monitor), so the picture # fills the screen without black bars, with prompts = xbox or pc too (on an install by an older setup, which built the @@ -265,6 +265,11 @@ # Field of view, in percent of the game's own: 70 to 140, 100 (the default) leaves the camera as it is. Higher shows # more of the world around Link. Game versions 1.1.0, 1.2.1 and 1.4.3. Changes while the game runs take effect at once. # fov = 100 +# Vert+ at a game resolution narrower than 16:9 (16:10, 3:2, 4:3): 1, the default, widens the camera's vertical view +# so the picture shows as much of the world at the sides as 16:9 does, and more above and below. 0: the game's own +# vertical view at every shape, so a narrower shape shows less at the sides. Multiplies with fov. Changes while the +# game runs take effect at once. +# vert_plus = 1 # Anisotropic filtering of surface textures: game (the level the game asks for, as on the Switch) or 2, 4, 8, 16. Keeps # ground, roads and walls seen at a shallow angle sharp into the distance. Only filtered, mipmapped textures that tile # are raised; shadow maps, data maps and screen-sized buffers keep the game's setting. Read at start.