- mystery of desaturation shader solved: The old code passed '1-desaturation' to the shader, the new code 'desaturation', so for the 'mix' function to work its arguments must be swapped.

This commit is contained in:
Christoph Oelckers 2014-05-21 15:25:25 +02:00
parent 54425ee2ef
commit 39775cc904

View file

@ -31,13 +31,8 @@ vec4 desaturate(vec4 texel)
{
if (uDesaturationFactor > 0.0)
{
float gray = (texel.r * 0.3 + texel.g * 0.56 + texel.b * 0.14) * uDesaturationFactor;
vec4 desaturated = vec4(gray,gray,gray,texel.a);
// I have absolutely no idea why this works and 'mix' doesn't...
texel *= (1.0-uDesaturationFactor);
return texel + desaturated;
//return mix (desaturated, texel, uDesaturationFactor);
float gray = (texel.r * 0.3 + texel.g * 0.56 + texel.b * 0.14);
return mix (texel, vec4(gray,gray,gray,texel.a), uDesaturationFactor);
}
else
{