skia2/tests/sksl/blend/BlendLuminosityStandaloneSettings.glsl

54 lines
2.4 KiB
Plaintext
Raw Normal View History

out vec4 sk_FragColor;
uniform vec4 src;
uniform vec4 dst;
vec3 blend_set_color_saturation_helper_Qh3h3h(vec3 minMidMax, float sat) {
if (minMidMax.x < minMidMax.z) {
return vec3(0.0, (sat * (minMidMax.y - minMidMax.x)) / (minMidMax.z - minMidMax.x), sat);
} else {
return vec3(0.0);
}
}
vec4 blend_hslc_h4h4h4hb(vec4 src, vec4 dst, float flip, bool saturate) {
float alpha = dst.w * src.w;
vec3 sda = src.xyz * dst.w;
vec3 dsa = dst.xyz * src.w;
vec3 l = mix(sda, dsa, flip);
vec3 r = mix(dsa, sda, flip);
if (saturate) {
vec3 _2_blend_set_color_saturation;
float _3_sat = max(max(r.x, r.y), r.z) - min(min(r.x, r.y), r.z);
if (l.x <= l.y) {
if (l.y <= l.z) {
_2_blend_set_color_saturation = blend_set_color_saturation_helper_Qh3h3h(l, _3_sat);
} else if (l.x <= l.z) {
_2_blend_set_color_saturation = blend_set_color_saturation_helper_Qh3h3h(l.xzy, _3_sat).xzy;
} else {
_2_blend_set_color_saturation = blend_set_color_saturation_helper_Qh3h3h(l.zxy, _3_sat).yzx;
}
} else if (l.x <= l.z) {
_2_blend_set_color_saturation = blend_set_color_saturation_helper_Qh3h3h(l.yxz, _3_sat).yxz;
} else if (l.y <= l.z) {
_2_blend_set_color_saturation = blend_set_color_saturation_helper_Qh3h3h(l.yzx, _3_sat).zxy;
} else {
_2_blend_set_color_saturation = blend_set_color_saturation_helper_Qh3h3h(l.zyx, _3_sat).zyx;
}
l = _2_blend_set_color_saturation;
r = dsa;
}
float _4_lum = dot(vec3(0.30000001192092896, 0.5899999737739563, 0.10999999940395355), r);
vec3 _5_result = (_4_lum - dot(vec3(0.30000001192092896, 0.5899999737739563, 0.10999999940395355), l)) + l;
float _6_minComp = min(min(_5_result.x, _5_result.y), _5_result.z);
float _7_maxComp = max(max(_5_result.x, _5_result.y), _5_result.z);
if (_6_minComp < 0.0 && _4_lum != _6_minComp) {
_5_result = _4_lum + (_5_result - _4_lum) * (_4_lum / (_4_lum - _6_minComp));
}
if (_7_maxComp > alpha && _7_maxComp != _4_lum) {
_5_result = _4_lum + ((_5_result - _4_lum) * (alpha - _4_lum)) / (_7_maxComp - _4_lum);
}
return vec4((((_5_result + dst.xyz) - dsa) + src.xyz) - sda, (src.w + dst.w) - alpha);
}
void main() {
sk_FragColor = blend_hslc_h4h4h4hb(src, dst, 1.0, false);
}