mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-20 09:49:15 +03:00
LibSoftGPU: Shift U/V coordinates just once in Sampler
This commit is contained in:
parent
bca1b9f475
commit
a362a95912
Notes:
sideshowbarker
2024-07-17 21:41:06 +09:00
Author: https://github.com/gmta Commit: https://github.com/SerenityOS/serenity/commit/a362a959121 Pull-request: https://github.com/SerenityOS/serenity/pull/11612
@ -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<unsigned>(floorf(u - 0.5f)) % width : floorf(u - 0.5f);
|
||||
int j0 = m_config.texture_wrap_v == TextureWrapMode::Repeat ? static_cast<unsigned>(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<unsigned>(floorf(u)) % width : floorf(u);
|
||||
int j0 = m_config.texture_wrap_v == TextureWrapMode::Repeat ? static_cast<unsigned>(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);
|
||||
|
Loading…
Reference in New Issue
Block a user