diff --git a/Userland/Libraries/LibSoftGPU/Sampler.cpp b/Userland/Libraries/LibSoftGPU/Sampler.cpp index 986fe33213..296ebc6ba7 100644 --- a/Userland/Libraries/LibSoftGPU/Sampler.cpp +++ b/Userland/Libraries/LibSoftGPU/Sampler.cpp @@ -86,8 +86,11 @@ FloatVector4 Sampler::sample_2d(FloatVector2 const& uv) const return image.texel(layer, level, i, j, 0); } - int i0 = m_config.texture_wrap_u == TextureWrapMode::Repeat ? static_cast(floorf(u - 0.5f)) % width : floorf(u - 0.5f); - int j0 = m_config.texture_wrap_v == TextureWrapMode::Repeat ? static_cast(floorf(v - 0.5f)) % height : floorf(v - 0.5f); + u -= 0.5f; + v -= 0.5f; + + int i0 = m_config.texture_wrap_u == TextureWrapMode::Repeat ? static_cast(floorf(u)) % width : floorf(u); + int j0 = m_config.texture_wrap_v == TextureWrapMode::Repeat ? static_cast(floorf(v)) % height : floorf(v); int i1 = m_config.texture_wrap_u == TextureWrapMode::Repeat ? (i0 + 1) % width : i0 + 1; int j1 = m_config.texture_wrap_v == TextureWrapMode::Repeat ? (j0 + 1) % height : j0 + 1; @@ -108,8 +111,8 @@ FloatVector4 Sampler::sample_2d(FloatVector2 const& uv) const t3 = (i1 < 0 || i1 >= w || j1 < 0 || j1 >= h) ? m_config.border_color : image.texel(layer, level, i1, j1, 0); } - float const alpha = fracf(u - 0.5f); - float const beta = fracf(v - 0.5f); + float const alpha = fracf(u); + float const beta = fracf(v); auto const lerp_0 = mix(t0, t1, alpha); auto const lerp_1 = mix(t2, t3, alpha);