lerp(a,b,w) 根据w返回a到b之间的插值.
float3 lerp(float3 a, float3 b, float w) { return a + w*(b-a); }
saturate(x)的作用是如果x取值小于0,则返回值为0。如果x取值大于1,则返回值为1.
fmod(x, y): 返回 x / y 的小数部分. 如: x = i * y + f
frac(x): 返回x的小数部分.
fract
returns the fractional part of x
. This is calculated as x
- floor(x
).
genUType clamp(
genUType x, genUType minVal, genUType maxVal)
;
取三个数中大小排序后的中间数
clamp
returns the value of x
constrained to the range minVal
to maxVal
. The returned value is computed as min(max(x
, minVal
), maxVal
). The result is undefined if minVal
≥ maxVal
.
更多官方API说明:OpenGL ES Shading Language (GLSL ES) Reference Pages