2020-10-12 16:33:27 +00:00
|
|
|
|
|
|
|
out vec4 sk_FragColor;
|
|
|
|
vec3 _blend_set_color_luminance(vec3 hueSatColor, float alpha, vec3 lumColor) {
|
2020-12-15 23:06:29 +00:00
|
|
|
float lum = dot(vec3(0.30000001192092896, 0.5899999737739563, 0.10999999940395355), lumColor);
|
2020-12-15 20:21:03 +00:00
|
|
|
|
2020-12-15 23:06:29 +00:00
|
|
|
vec3 result = (lum - dot(vec3(0.30000001192092896, 0.5899999737739563, 0.10999999940395355), hueSatColor)) + hueSatColor;
|
2020-10-12 16:33:27 +00:00
|
|
|
|
|
|
|
float minComp = min(min(result.x, result.y), result.z);
|
|
|
|
float maxComp = max(max(result.x, result.y), result.z);
|
|
|
|
if (minComp < 0.0 && lum != minComp) {
|
|
|
|
result = lum + ((result - lum) * lum) / (lum - minComp);
|
|
|
|
}
|
|
|
|
return maxComp > alpha && maxComp != lum ? lum + ((result - lum) * (alpha - lum)) / (maxComp - lum) : result;
|
|
|
|
}
|
2020-11-23 19:48:06 +00:00
|
|
|
vec3 _blend_set_color_saturation_helper(vec3 minMidMax, float sat) {
|
|
|
|
return minMidMax.x < minMidMax.z ? vec3(0.0, (sat * (minMidMax.y - minMidMax.x)) / (minMidMax.z - minMidMax.x), sat) : vec3(0.0);
|
|
|
|
}
|
2020-10-12 16:33:27 +00:00
|
|
|
vec3 _blend_set_color_saturation(vec3 hueLumColor, vec3 satColor) {
|
2020-12-15 23:06:29 +00:00
|
|
|
float sat = max(max(satColor.x, satColor.y), satColor.z) - min(min(satColor.x, satColor.y), satColor.z);
|
2020-10-12 16:33:27 +00:00
|
|
|
|
|
|
|
if (hueLumColor.x <= hueLumColor.y) {
|
|
|
|
if (hueLumColor.y <= hueLumColor.z) {
|
2020-11-24 03:19:04 +00:00
|
|
|
return _blend_set_color_saturation_helper(hueLumColor, sat);
|
2020-10-12 16:33:27 +00:00
|
|
|
} else if (hueLumColor.x <= hueLumColor.z) {
|
2020-11-24 03:19:04 +00:00
|
|
|
return _blend_set_color_saturation_helper(hueLumColor.xzy, sat).xzy;
|
2020-10-12 16:33:27 +00:00
|
|
|
} else {
|
2020-11-24 03:19:04 +00:00
|
|
|
return _blend_set_color_saturation_helper(hueLumColor.zxy, sat).yzx;
|
2020-10-12 16:33:27 +00:00
|
|
|
}
|
|
|
|
} else if (hueLumColor.x <= hueLumColor.z) {
|
2020-11-24 03:19:04 +00:00
|
|
|
return _blend_set_color_saturation_helper(hueLumColor.yxz, sat).yxz;
|
2020-10-12 16:33:27 +00:00
|
|
|
} else if (hueLumColor.y <= hueLumColor.z) {
|
2020-11-24 03:19:04 +00:00
|
|
|
return _blend_set_color_saturation_helper(hueLumColor.yzx, sat).zxy;
|
2020-10-12 16:33:27 +00:00
|
|
|
} else {
|
2020-11-24 03:19:04 +00:00
|
|
|
return _blend_set_color_saturation_helper(hueLumColor.zyx, sat).zyx;
|
2020-10-12 16:33:27 +00:00
|
|
|
}
|
|
|
|
}
|
2020-11-23 19:48:06 +00:00
|
|
|
vec4 blend_hue(vec4 src, vec4 dst) {
|
|
|
|
float alpha = dst.w * src.w;
|
|
|
|
vec3 sda = src.xyz * dst.w;
|
|
|
|
vec3 dsa = dst.xyz * src.w;
|
|
|
|
return vec4((((_blend_set_color_luminance(_blend_set_color_saturation(sda, dsa), alpha, dsa) + dst.xyz) - dsa) + src.xyz) - sda, (src.w + dst.w) - alpha);
|
|
|
|
}
|
2020-11-18 20:38:39 +00:00
|
|
|
uniform vec4 color;
|
2020-10-12 16:33:27 +00:00
|
|
|
void main() {
|
2020-12-15 23:06:29 +00:00
|
|
|
float _7_a = color.x * color.y;
|
2020-12-15 22:50:21 +00:00
|
|
|
float _8_c;
|
2020-12-15 23:06:29 +00:00
|
|
|
_8_c = _7_a + color.z;
|
2020-12-15 20:21:03 +00:00
|
|
|
|
2020-12-15 23:06:29 +00:00
|
|
|
sk_FragColor = vec4(_8_c);
|
2020-10-12 16:33:27 +00:00
|
|
|
|
|
|
|
|
|
|
|
sk_FragColor *= 1.25;
|
|
|
|
|
2020-12-15 23:06:29 +00:00
|
|
|
sk_FragColor *= color.xxyy * color.w;
|
2020-10-12 16:33:27 +00:00
|
|
|
|
2020-12-15 23:06:29 +00:00
|
|
|
sk_FragColor *= color.zzww * color.y;
|
2020-10-12 16:33:27 +00:00
|
|
|
|
2020-11-23 19:48:06 +00:00
|
|
|
sk_FragColor *= blend_hue(color, color.wwww);
|
|
|
|
sk_FragColor *= blend_hue(color, color.wzyx);
|
2020-10-12 16:33:27 +00:00
|
|
|
}
|