Defines
Code: Select all
#define desat_red 0 //Range 0-inf.
#define desat_green 0 //Range 0-inf.
#define desat_blue 0 //Range 0-inf.
Code: Select all
float WeightedLuma(float3 color)
{
return sqrt( 0.299*( color.r*color.r ) + 0.587*( color.g*color.g ) + 0.114*( color.b*color.b ));
}
Code: Select all
color.rgb = saturate( color.rgb ); //comment out if not using LDR, but this effect should run in LDR.
float gr = WeightedLuma( color.rgb );
float r = color.r;
float g = color.g;
float b = color.b;
float sr = saturate( desat_red * ( r-b-g+r ));
float sg = saturate( desat_green * ( g-r-b+g ));
float sb = saturate( desat_blue * ( b-r-g+b ));
color.rgb = lerp( color.rgb, gr, saturate( sr + sg + sb ));
Example magenta (just out of top of my head, didn't test but should be fairly close)
float sm = saturate( desat_magenta * ( min(r,b)-2*max(r,b)-g+r+b ));
Cheers,
prod80