2
\$\begingroup\$

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));
\$\endgroup\$

1 Answer 1

4
\$\begingroup\$

The return value is computed as x*(1−a)+y*a.

in other words if a is -1 then the result will be 2*x-y

\$\endgroup\$
1
  • 1
    \$\begingroup\$ A mix is a linear interpolation between x and y when a is between 0 and 1. Outside of that domain it's an linear extrapolation. \$\endgroup\$ Feb 3, 2015 at 13:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .