亮度(brightness),饱和度(saturation),对比度(contrast)的计算方法
(UnityShader实现)
亮度 - 图片原色乘以亮度系数_Brightness
fixed3 finalColor = texture.rgb * _Brightness
饱和度 - 先计算亮度(luminance),然后每个颜色使用饱和度系数(_Saturation)和亮度进行差值
fixed luminance = texture.r * 0.2125 + texture.g * 0.7154 + texture.b * 0.0721;
fixed3 luminanceColor = fixed3(luminance, luminance, luminance);
fixed3 finalColor = leap(luminanceColor, texture.rgb, _Saturation);
对比度 - 创建一个对比度为0的颜色(rgb = 0.5), 然后每个颜色使用对比度系数(_Contrast)和对比度0进行差值
fixed3 avgColor = fixed3(0.5, 0.5, 0.5);
fixed3 finalColor = leap(avgColor, texture.rgb, _Contrast);