There's two magnificent intrisincs: mix()
in GLSL and clamp()
in HLSL, which are used to implement linear interpolation. Let's say we have a variable:
float v = ?; // where ? can be [-FLOAT_MAX, +FLOAT_MAX]
and then we do:
gl_FragColor = mix(value1, value2, v);
So, the question is: does it works the correct way under GL or DirectX? Should I EXPLICITLY normalize the value of v like this:
gl_FragColor = mix(value1, value2, clamp(v, 0.0, 1.0));