Question

I`m trying to figure out how to write a equivalent to GLSL(ES)s mix method. I tried to add/divide rgb Values but with no luck yet. Any pointer to how the GLSL method works would be welcome.

Was it helpful?

Solution

mix in GLSL does a linear combination of its two inputs, based on a scaling factor that ranges in [0,1]. From the GLSL specification:

T mix ( T x, T y, T2 a )
{
    return (1-a)*x + a*y;
}

where T represents any valid vector or scalar type in GLSL capable of being modulated by a scalar value (e.g., vec2, mat4, etc.). T2 is either a floating-point type (i.e., float or double), or the type matching T, in which case a is applied component-wise to the components of x and y.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top