Code: Select all
ncolor = normalize(color);
scolor = color/ncolor;
ncolor = pow(ncolor, saturation);
color = ncolor*scolor;
So I tried another math which I found by googling:
Code: Select all
float sGray = dot(color.xyz, float3(0.27,0.67,0.06));
color.xyz = saturation*color.xyz + (1.0-saturation)*sGray;
I also tried combining both: use pow to saturate then calculate and scale luma back to its original level, but the combining effect changes hue. Or I may have done something wrong, need to review the code again, did it in a haste.
I haven't tried converting to HSV. Because S in HSV also caps at [0,1], it's additional to adjust saturation while keep it restrained to a strict range. makes things complicated.
Any good ideas?