From 5dcac19982a8ee4a69ab6cc16c26f0f38659f254 Mon Sep 17 00:00:00 2001 From: applezra Date: Fri, 30 Oct 2026 22:56:47 -0700 Subject: [PATCH] Force anisotropic filtering only on samplers that tile The aniso setting raised every filtered, mipmapped colour sampler to the chosen level. Some of those read screen-sized buffers, among them the ones the inventory's character preview is drawn from. Their coordinates stretch steeply at the model's edges, so the anisotropic taps reach across the edge and leave a speckled fringe around the character. The level is now raised only for samplers that repeat on U and V, which the surface textures it is meant for do; clamped samplers keep the game's level. Distant ground stays as sharp as before. Co-Authored-By: Claude Opus 5.5 --- runtime/vk_texture.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/runtime/vk_texture.c b/runtime/vk_texture.c index ce7619f7..14d11067 100644 --- a/runtime/vk_texture.c +++ b/runtime/vk_texture.c @@ -1505,9 +1505,14 @@ static VkSampler make_sampler(VkCtx *c, const samp_par *d) { float lim = c->props.limits.maxSamplerLodBias; si.mipLodBias = fmaxf(-lim, fminf(lim, d->lod_bias)); float aniso = d->aniso; - // TOTK_ANISO raises the level for filtered, mipmapped colour samplers only: depth-compare (shadow) samplers and - // nearest or unmipmapped ones (data maps, LUTs) keep what the game set. - if (aniso_force > 1 && !d->cmp_mode && si.magFilter == VK_FILTER_LINEAR && si.minFilter == VK_FILTER_LINEAR && + // TOTK_ANISO raises the level for filtered, mipmapped colour samplers that repeat on U and V only: the surface + // textures it is for tile. Depth-compare (shadow) samplers, nearest or unmipmapped ones (data maps, LUTs) and clamped + // ones keep what the game set. Clamped samplers read screen-sized buffers, whose coordinates can stretch steeply at + // an object's edge; there anisotropic taps reach across the edge and leave a speckled fringe (the inventory's + // character preview). + int tiled = (modes[0] == VK_SAMPLER_ADDRESS_MODE_REPEAT || modes[0] == VK_SAMPLER_ADDRESS_MODE_MIRRORED_REPEAT) && + (modes[1] == VK_SAMPLER_ADDRESS_MODE_REPEAT || modes[1] == VK_SAMPLER_ADDRESS_MODE_MIRRORED_REPEAT); + if (aniso_force > 1 && tiled && !d->cmp_mode && si.magFilter == VK_FILTER_LINEAR && si.minFilter == VK_FILTER_LINEAR && (mf == NVN_MIN_FILTER_LINEAR_MIPMAP_NEAREST || mf == NVN_MIN_FILTER_LINEAR_MIPMAP_LINEAR) && aniso < aniso_force) aniso = aniso_force; if (aniso > 1) {