From ade45b5b9930b52b6a1d399306539073e8e2196d Mon Sep 17 00:00:00 2001 From: wwylele Date: Mon, 17 Apr 2017 10:01:45 +0300 Subject: pica/swrasterizer: implement procedural texture --- src/common/vector_math.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/common/vector_math.h') diff --git a/src/common/vector_math.h b/src/common/vector_math.h index 7ca8e15f5..c7a461a1e 100644 --- a/src/common/vector_math.h +++ b/src/common/vector_math.h @@ -652,6 +652,16 @@ static inline decltype((X{} * int{} + X{} * int{}) / base) LerpInt(const X& begi return (begin * (base - t) + end * t) / base; } +// bilinear interpolation. s is for interpolating x00-x01 and x10-x11, and t is for the second +// interpolation. +template +inline auto BilinearInterp(const X& x00, const X& x01, const X& x10, const X& x11, const float s, + const float t) { + auto y0 = Lerp(x00, x01, s); + auto y1 = Lerp(x10, x11, s); + return Lerp(y0, y1, t); +} + // Utility vector factories template static inline Vec2 MakeVec(const T& x, const T& y) { -- cgit v1.2.3