From 676bd084f54c84b0b51e27f996c0a70a8affd977 Mon Sep 17 00:00:00 2001 From: Dario Date: Sat, 22 Mar 2025 13:47:59 -0300 Subject: [PATCH] Adjust mip bias. --- src/render/rt64_shader_library.cpp | 2 +- src/shaders/TextureSampler.hlsli | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/render/rt64_shader_library.cpp b/src/render/rt64_shader_library.cpp index fb19e28..00ce37b 100644 --- a/src/render/rt64_shader_library.cpp +++ b/src/render/rt64_shader_library.cpp @@ -192,7 +192,7 @@ namespace RT64 { samplerDesc.addressW = RenderTextureAddressMode::CLAMP; // This matches the bias used in the shader when native samplers are not used. - samplerDesc.mipLODBias = -0.5f; + samplerDesc.mipLODBias = -0.25f; // WRAP. samplerDesc.addressU = RenderTextureAddressMode::WRAP; diff --git a/src/shaders/TextureSampler.hlsli b/src/shaders/TextureSampler.hlsli index 78b6d37..09e2da5 100644 --- a/src/shaders/TextureSampler.hlsli +++ b/src/shaders/TextureSampler.hlsli @@ -215,7 +215,7 @@ float4 sampleTexture(OtherMode otherMode, RenderFlags renderFlags, float2 inputU float2 ddxUVxScaled = ddxUVx * gpuTile.tcScale; float2 ddxUVyScaled = ddyUVy * gpuTile.tcScale; float ddMax = max(dot(ddxUVxScaled, ddxUVxScaled), dot(ddxUVyScaled, ddxUVyScaled)); - float mipBias = -0.5f; + float mipBias = -0.25f; mip = 0.5 * log2(ddMax) + mipBias; float maxMip = float(textureLevels - 1); RDPMipLevels[0] = min(floor(mip), maxMip);