R2 Shaders
R2Bilinear.h
Go to the documentation of this file.
1 #ifndef R2_BILINEAR_H
2 #define R2_BILINEAR_H
3 
4 ///
5 /// \file R2Bilinear.h
6 /// \brief Functions for performing bilinear interpolation.
7 ///
8 
9 ///
10 /// Bilinearly interpolate between the set of four vectors.
11 /// Iff \a p == (0,0) then the function yields \a x0y0. Iff
12 /// \a p == (1,1) then the function yields \a x1y1. Any intermediate
13 /// values of \a p yield a bilinear mix of the four vectors.
14 ///
15 /// @param x0y0 The upper left vector
16 /// @param x1y0 The upper right vector
17 /// @param x0y1 The lower left vector
18 /// @param x1y1 The lower right vector
19 /// @param p The interpolation vector
20 ///
21 
22 vec3
24  const vec3 x0y0,
25  const vec3 x1y0,
26  const vec3 x0y1,
27  const vec3 x1y1,
28  const vec2 p)
29 {
30  vec3 u0 = mix (x0y0, x1y0, p.x);
31  vec3 u1 = mix (x0y1, x1y1, p.x);
32  return mix (u0, u1, p.y);
33 }
34 
35 #endif // R2_BILINEAR_H
vec3 R2_bilinearInterpolate3(const vec3 x0y0, const vec3 x1y0, const vec3 x0y1, const vec3 x1y1, const vec2 p)
Definition: R2Bilinear.h:23