84 {
85 u = repeat_horizontal ? u - std::floor(u) : std::clamp(u, 0.0f, 1.0f);
86 v = std::clamp(v, 0.0f, 1.0f);
87 const float texture_x = u *
static_cast<float>(repeat_horizontal ?
width :
width - 1);
88 const float texture_y = v *
static_cast<float>(
height - 1);
89 const int first_x = static_cast<int>(std::floor(texture_x));
90 const int first_y = static_cast<int>(std::floor(texture_y));
91 const int second_x = repeat_horizontal ? (first_x + 1) %
width : std::min(first_x + 1,
width - 1);
92 const int second_y = std::min(first_y + 1,
height - 1);
93 const float x_fraction = texture_x - static_cast<float>(first_x);
94 const float y_fraction = texture_y - static_cast<float>(first_y);
95 const auto texel = [this](int x, int y) {
96 return pixels[
static_cast<std::size_t
>(y) *
static_cast<std::size_t
>(
width) +
static_cast<std::size_t
>(x)];
97 };
101 }
mxvk::MXCOLOR interpolate_color(mxvk::MXCOLOR first, mxvk::MXCOLOR second, float fraction)
std::uint32_t MXCOLOR
Packed 32-bit color in ARGB byte order.
std::vector< mxvk::MXCOLOR > pixels