diff options
Diffstat (limited to 'Userland/Libraries/LibGL/Tex')
-rw-r--r-- | Userland/Libraries/LibGL/Tex/Sampler2D.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/Userland/Libraries/LibGL/Tex/Sampler2D.cpp b/Userland/Libraries/LibGL/Tex/Sampler2D.cpp index d72fc0fe82..caf3efc1cb 100644 --- a/Userland/Libraries/LibGL/Tex/Sampler2D.cpp +++ b/Userland/Libraries/LibGL/Tex/Sampler2D.cpp @@ -68,7 +68,7 @@ FloatVector4 Sampler2D::sample(FloatVector2 const& uv) const // Sampling implemented according to https://www.khronos.org/registry/OpenGL/specs/gl/glspec121.pdf Chapter 3.8 if (m_mag_filter == GL_NEAREST) { - return mip.texel(static_cast<unsigned>(x) % mip.width(), static_cast<unsigned>(y) % mip.height()); + return mip.texel(static_cast<unsigned>(x), static_cast<unsigned>(y)); } else if (m_mag_filter == GL_LINEAR) { // FIXME: Implement different sampling points for wrap modes other than GL_REPEAT @@ -88,8 +88,11 @@ FloatVector4 Sampler2D::sample(FloatVector2 const& uv) const float frac_x = x - floorf(x); float frac_y = y - floorf(y); + float one_minus_frac_x = 1 - frac_x; - return t0 * (1 - frac_x) * (1 - frac_y) + t1 * frac_x * (1 - frac_y) + t2 * (1 - frac_x) * frac_y + t3 * frac_x * frac_y; + auto h1 = t0 * one_minus_frac_x + t1 * frac_x; + auto h2 = t2 * one_minus_frac_x + t3 * frac_x; + return h1 * (1 - frac_y) + h2 * frac_y; } else { VERIFY_NOT_REACHED(); } |