mirror of
https://github.com/valentderah/totk-pc-recomp.git
synced 2026-11-23 05:25:56 +00:00
Add soft sun shadows (PCSS) through a translator patch
The deferred lighting shaders take the sun shadow as four explicit-LOD compares on the cascade array. Translator patch 0010 turns every explicit-LOD compare on a 2D array texture into a PCSS lookup when the support buffer's new pcss field has x above 0: eight raw depth fetches within pcss.w find the blockers, (receiver - blocker) * pcss.x gives the penumbra width clamped to pcss.y..pcss.z, and eight compares on a disc of that radius average to the result. With x at 0 the original single compare runs behind a branch. Radii are in UV, so they hold at any shadow_scale. The support buffer grows to 1424 bytes; support_fill writes the field from pcss (percent of the default width, 0 to 200, default 0; TOTK_PCSS_K overrides the factor at 100 percent, default 0.5). build_xlate.py expects ten patches. The setting is in totk.ini.example and on the Screen tab of the menu (English and Russian). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
4af60604de
commit
24571ec0b0
8 files changed
+174
-6
No files matched your search
+3
-2
@@ -41,7 +41,7 @@ static const char *const known[] = {
|
||||
"GPU_INDEX", "GPU_NAME", "HIGHFPS_FIX", "INPUT", "INPUT_RECORD", "INPUT_SCRIPT", "LANG", "LIB_PREBUILD",
|
||||
"LIB_PREBUILD_KEEP", "LIB_PREBUILD_THREADS", "LOCALE", "LOD_GUARD", "MEMORY", "MENU_LANG", "MENU_TEST",
|
||||
"MENU_TEST_DIR", "MENU_TEST_SET", "MINIMAL_LAYOUT", "MIRROR_GAP", "MOTION", "MOUSE_SENS", "MOVIE_HOST", "MOVIE_PACE",
|
||||
"ONE_PER_CORE", "OPERATION_MODE", "OUTPUT_RES", "PAD_LAYOUT", "PATCH_OUTPUT", "PATCH_SCENE", "PERF_OVERLAY", "PERF_SLOW_MS", "PIPELINE_CACHE", "PIPE_MEMO", "PIPE_PREBUILD", "PIPE_SKIP", "PIPE_SYNC", "PIPE_WAIT",
|
||||
"ONE_PER_CORE", "OPERATION_MODE", "OUTPUT_RES", "PAD_LAYOUT", "PATCH_OUTPUT", "PATCH_SCENE", "PCSS", "PCSS_K", "PERF_OVERLAY", "PERF_SLOW_MS", "PIPELINE_CACHE", "PIPE_MEMO", "PIPE_PREBUILD", "PIPE_SKIP", "PIPE_SYNC", "PIPE_WAIT",
|
||||
"PREWARM_XLATE", "PROBE_MOVIE", "PROBE_MOVIE_SHOT", "PROFILE", "PROFILE_CHAINS", "PROFILE_DIR", "PROFILE_FRAMES",
|
||||
"PROFILE_MAIN", "PROFILE_RENDER", "PUSH_SKIP", "PUSH_STAGE", "RDOC", "RDOC_DIR", "RDOC_DLL", "REALTIME", "REEXEC",
|
||||
"RENDER_SCALE", "REPLAY_ASYNC",
|
||||
@@ -59,7 +59,7 @@ static const struct { const char *key, *section; } sections[] = {
|
||||
{"REALTIME", "frame rate"}, {"CLOTH_REALTIME", "frame rate"}, {"HIGHFPS_FIX", "frame rate"},
|
||||
{"FULLSCREEN", "display"}, {"WINDOW_SIZE", "display"}, {"PERF_OVERLAY", "display"}, {"VK_PRESENT", "display"},
|
||||
{"GPU_INDEX", "display"}, {"OUTPUT_RES", "display"}, {"RENDER_SCALE", "display"}, {"UPSCALER", "display"},
|
||||
{"SHARPNESS", "display"}, {"ANISO", "display"}, {"SHADOW_SCALE", "display"}, {"SHADOW_RANGE", "display"}, {"CONTACT_SHADOWS", "display"},
|
||||
{"SHARPNESS", "display"}, {"ANISO", "display"}, {"SHADOW_SCALE", "display"}, {"SHADOW_RANGE", "display"}, {"CONTACT_SHADOWS", "display"}, {"PCSS", "display"},
|
||||
{"MENU_LANG", "language"}, {"LANG", "language"}, {"OPERATION_MODE", "language"},
|
||||
{"VOLUME", "audio"},
|
||||
{"MOTION", "input"}, {"RUMBLE_STRENGTH", "input"}, {"RUMBLE_CURVE", "input"}, {"RUMBLE_TRIGGERS", "input"},
|
||||
@@ -95,6 +95,7 @@ static const CfgMeta metas[] = {
|
||||
{"UPSCALER", "fsr", "fsr|bilinear", LIVE}, {"SHARPNESS", "80", "0..100", LIVE},
|
||||
{"ANISO", "16", "game|2|4|8|16", RESTART}, {"SHADOW_SCALE", "1", "1..4", RESTART},
|
||||
{"SHADOW_RANGE", "100", "50..400", RESTART}, {"CONTACT_SHADOWS", "0", "0..100", RESTART},
|
||||
{"PCSS", "0", "0..200", RESTART},
|
||||
// Game
|
||||
{"FPS_LIMIT", "60", "30|60|120|144|display", LIVE}, {"FPS60", "1", "0|1", LIVE},
|
||||
{"REALTIME", "1", "0|1", RESTART}, {"CLOTH_REALTIME", "1", "0|1", RESTART},
|
||||
|
||||
@@ -550,6 +550,7 @@ static void tab_screen(float scale) {
|
||||
row_aniso();
|
||||
row_shadow_scale();
|
||||
row_shadow_range();
|
||||
opt_slider("TOTK_PCSS", UI_MENU_PCSS, 0, 200, UI_MENU_PCSS_DESC, 10, "%.0f %%");
|
||||
opt_slider("TOTK_CONTACT_SHADOWS", UI_MENU_CONTACT_SHADOWS, 0, 100, UI_MENU_CONTACT_SHADOWS_DESC, 10, "%.0f %%");
|
||||
opt_end();
|
||||
}
|
||||
|
||||
@@ -70,6 +70,9 @@ static const char *const text_en[UI_TEXT_COUNT] = {
|
||||
[UI_MENU_SHADOW_SCALE] = "Shadow resolution",
|
||||
[UI_MENU_SHADOW_SCALE_DESC] = "Draws the sun's shadow maps this many times larger on each side than the game's 960x960: "
|
||||
"sharper shadow edges and leaf shadows. Takes effect at the next start.",
|
||||
[UI_MENU_PCSS] = "Soft shadows",
|
||||
[UI_MENU_PCSS_DESC] = "Sun shadows sharp where an object meets the ground and softer the further the shadow falls "
|
||||
"(PCSS). 0 keeps the game's filter. Takes effect at the next start.",
|
||||
[UI_MENU_CONTACT_SHADOWS] = "Contact shadows",
|
||||
[UI_MENU_CONTACT_SHADOWS_DESC] = "Small sun shadows the shadow maps miss: at feet, under stones, in grass and creases. "
|
||||
"Traced on the screen after lighting. Takes effect at the next start.",
|
||||
@@ -302,6 +305,9 @@ static const char *const text_ru[UI_TEXT_COUNT] = {
|
||||
[UI_MENU_SHADOW_SCALE] = "Разрешение теней",
|
||||
[UI_MENU_SHADOW_SCALE_DESC] = "Карты теней от солнца рисуются во столько раз больше по каждой стороне, чем 960x960 "
|
||||
"самой игры: края теней и тени листвы чётче. Действует после перезапуска.",
|
||||
[UI_MENU_PCSS] = "Мягкие тени",
|
||||
[UI_MENU_PCSS_DESC] = "Тени от солнца резкие там, где предмет касается земли, и мягче, чем дальше падает тень "
|
||||
"(PCSS). 0 оставляет фильтр игры. Действует после перезапуска.",
|
||||
[UI_MENU_CONTACT_SHADOWS] = "Контактные тени",
|
||||
[UI_MENU_CONTACT_SHADOWS_DESC] = "Мелкие тени от солнца, которых нет на картах теней: у ног, под камнями, в траве и "
|
||||
"складках. Считаются по экрану после освещения. Действует после перезапуска.",
|
||||
|
||||
@@ -40,6 +40,7 @@ typedef enum {
|
||||
UI_MENU_SHADOW_SCALE, UI_MENU_SHADOW_SCALE_DESC,
|
||||
UI_MENU_SHADOW_RANGE, UI_MENU_SHADOW_RANGE_DESC,
|
||||
UI_MENU_CONTACT_SHADOWS, UI_MENU_CONTACT_SHADOWS_DESC,
|
||||
UI_MENU_PCSS, UI_MENU_PCSS_DESC,
|
||||
|
||||
// Game
|
||||
UI_MENU_FPS_LIMIT, UI_MENU_FPS_LIMIT_DESC, UI_MENU_FPS_30, UI_MENU_FPS_60, UI_MENU_FPS_120, UI_MENU_FPS_144,
|
||||
|
||||
+21
-1
@@ -32,7 +32,7 @@
|
||||
#define MAX_DESC 1024
|
||||
#define CHUNK_BYTES (4u << 20)
|
||||
#define ZERO_BYTES 65536u
|
||||
#define SUPPORT_BYTES 1408u // Ryujinx SupportBuffer (std140): alpha_test, is_bgra[8], viewport_inverse, viewport_size, ...
|
||||
#define SUPPORT_BYTES 1424u // Ryujinx SupportBuffer (std140): alpha_test, is_bgra[8], viewport_inverse, viewport_size, ...
|
||||
#define NVN_STAGE_VS 0
|
||||
#define NVN_STAGE_FS 1
|
||||
#define NVN_STAGE_CS 5
|
||||
@@ -1246,6 +1246,25 @@ static void support_in(const VkExec *ex, float in[3]) { // what support_fill r
|
||||
in[2] = ex->point_size > 0 ? ex->point_size : 1.0f;
|
||||
}
|
||||
|
||||
// TOTK_PCSS (percent, 0 = off): the pcss field of the support buffer, which translator patch 0010 reads in every
|
||||
// explicit-LOD compare on a 2D array texture (the sun cascades). x: penumbra width in UV per unit of light-space depth
|
||||
// between receiver and blocker (0 keeps the game's single compare), y and z: the narrowest and widest disc radius,
|
||||
// w: the blocker search radius, all in UV of the cascade map. Radii are in UV, so they hold at any TOTK_SHADOW_SCALE.
|
||||
// TOTK_PCSS_K overrides the depth-to-penumbra factor at 100 percent, for tuning.
|
||||
static const float *pcss_params(void) {
|
||||
static float p[4] = {-1, 0, 0, 0};
|
||||
if (p[0] < 0) {
|
||||
int pct = cfg_int("TOTK_PCSS");
|
||||
pct = pct < 0 ? 0 : pct > 200 ? 200 : pct;
|
||||
const char *k = cfg_get("TOTK_PCSS_K");
|
||||
float k100 = k && *k ? (float)atof(k) : 0.5f;
|
||||
p[0] = k100 * (float)pct / 100.0f;
|
||||
p[1] = 0.35f / 960.0f, p[2] = 5.0f / 960.0f, p[3] = 4.0f / 960.0f;
|
||||
if (pct) rt_log("vk: soft shadows (PCSS) at %d%% (depth factor %g)", pct, p[0]);
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
static void support_fill(uint8_t *b, float w, float h, float point_size) {
|
||||
memset(b, 0, SUPPORT_BYTES);
|
||||
float inv[4] = {w > 0 ? 2.0f / w : 0, h > 0 ? 2.0f / h : 0, 0, 0}, size[4] = {w, h, 0, 0};
|
||||
@@ -1253,6 +1272,7 @@ static void support_fill(uint8_t *b, float w, float h, float point_size) {
|
||||
memcpy(b + 160, size, 16);
|
||||
const float one = 1.0f;
|
||||
memcpy(b + 1392, &point_size, 4); // point_size (translator patch 0008): vertex shaders that write none output it
|
||||
memcpy(b + 1408, pcss_params(), 16); // pcss (translator patch 0010): soft sun shadows in the cascade compares
|
||||
for (int i = 0; i < 73; i++) memcpy(b + 192 + 16 * i, &one, 4); // render scale 1: the host renders at guest size
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user