This might seem like quite a few lines of code, but the concept behind blending is actually quite simple. For the technique to work, we have to employ the built-in lerp() function from the CgFX standard library. This function allows us to pick a value between argument one and argument two using argument three as the blend amount:
Function |
Description |
lerp(a, b, f ) |
This involves linear interpolation: (1 - f )* a + b * f Here, a and b are matching vector or scalar types. The f parameter can be either a scalar or vector of the same type as a and b. |
So, for example, if we wanted to find the mid-value between 1 and 2, we could feed the value 0.5 as the third argument to the lerp() function and it would return ...