128 lines
3.7 KiB
Forth
128 lines
3.7 KiB
Forth
|
#version 330 core
|
||
|
|
||
|
out vec4 FragColor;
|
||
|
|
||
|
in vec3 ourColor;
|
||
|
in vec2 TexCoord;
|
||
|
|
||
|
uniform float time;
|
||
|
uniform bool fusion;
|
||
|
uniform float alpha;
|
||
|
uniform sampler2D bgMap;
|
||
|
uniform sampler2D maskMap;
|
||
|
uniform sampler2D sourceMap;
|
||
|
uniform sampler2D textMap;
|
||
|
uniform sampler2D netWorkTextMap;
|
||
|
uniform sampler2D bgMapMask;
|
||
|
|
||
|
vec3 rgb2hsl(vec3 color) {
|
||
|
float h, s, l;
|
||
|
float r = color.r;
|
||
|
float g = color.g;
|
||
|
float b = color.b;
|
||
|
float Cmax = max(max(r, g), b);
|
||
|
float Cmin = min(min(r, g), b);
|
||
|
|
||
|
l = (Cmax + Cmin) / 2.0;
|
||
|
if (Cmax == Cmin) {
|
||
|
h = 0.0;
|
||
|
s = 0.0;
|
||
|
} else {
|
||
|
float delta = Cmax - Cmin;
|
||
|
s = (l > 0.5) ? delta / (2.0 - l * 2.0) : delta / (l * 2.0);
|
||
|
|
||
|
if (r > g && r > b) {
|
||
|
h = (g - b) / delta + ((g < b) ? 6.0 : 0.0);
|
||
|
} else if (g > b) {
|
||
|
h = (b - r) / delta + 2.0;
|
||
|
} else {
|
||
|
h = (r - g) / delta + 4.0;
|
||
|
}
|
||
|
h = h / 6.0;
|
||
|
}
|
||
|
return vec3(h, s, l);
|
||
|
}
|
||
|
|
||
|
float hue2rgb(float M1, float M2, float hue) {
|
||
|
float c;
|
||
|
if (hue < 0.0) {
|
||
|
hue += 1.0;
|
||
|
} else if (hue > 1.0) {
|
||
|
hue -= 1.0;
|
||
|
}
|
||
|
|
||
|
if ((6.0 * hue) < 1.0) {
|
||
|
c = (M1 + (M2 - M1) * hue * 6.0);
|
||
|
} else if ((2.0 * hue) < 1.0) {
|
||
|
c = M2;
|
||
|
} else if ((3.0 * hue) < 2.0) {
|
||
|
c = (M1 + (M2 - M1) * ((2.0/3.0) - hue) * 6.0);
|
||
|
} else {
|
||
|
c = M1;
|
||
|
}
|
||
|
return c;
|
||
|
}
|
||
|
|
||
|
vec3 hsl2rgb(vec3 hsl) {
|
||
|
float M1, M2;
|
||
|
float hue = hsl.x;
|
||
|
float saturation = hsl.y;
|
||
|
float lightness = hsl.z;
|
||
|
vec3 color;
|
||
|
if (saturation == 0.0) {
|
||
|
color.r = lightness;
|
||
|
color.g = lightness;
|
||
|
color.b = lightness;
|
||
|
} else {
|
||
|
if (lightness < 0.5) {
|
||
|
M2 = lightness * (1.0 + saturation);
|
||
|
} else {
|
||
|
M2 = lightness + saturation - lightness * saturation;
|
||
|
}
|
||
|
M1 = (2.0 * lightness - M2);
|
||
|
color.r = hue2rgb(M1, M2, hue + (1.0/3.0));
|
||
|
color.g = hue2rgb(M1, M2, hue);
|
||
|
color.b = hue2rgb(M1, M2, hue - (1.0/3.0));
|
||
|
}
|
||
|
return color;
|
||
|
}
|
||
|
|
||
|
void main() {
|
||
|
vec3 bgColor = texture2D( bgMap, TexCoord ).rgb;
|
||
|
vec4 bgMaskColor = texture2D( bgMapMask, TexCoord );
|
||
|
// vec3 hsl = rgb2hsl(bgColor);
|
||
|
// hsl.y *= 0.4;
|
||
|
// bgColor = hsl2rgb(hsl);
|
||
|
vec3 frgColor = vec3(1.0);
|
||
|
if (fusion) {
|
||
|
vec3 sourceColor = texture2D(sourceMap, TexCoord).rgb;
|
||
|
vec3 maskColor = texture2D(maskMap, TexCoord).rgb;
|
||
|
vec3 textColor = texture2D(textMap, TexCoord).rgb;
|
||
|
|
||
|
float x = abs((TexCoord.x - 0.5) * 2.0);
|
||
|
vec3 sourceMix = sourceColor * (1 - x * 2.5 ) * maskColor ; // mix(sourceColor, maskColor, maskColor);
|
||
|
|
||
|
// color = a * 0.3 + b*(1-0.3)
|
||
|
//vec3 circle = invBaseColor * maskColor * 2.5;
|
||
|
//sourceMix = sourceMix + circle;
|
||
|
bgColor = mix(bgColor, bgMaskColor.rgb, bgMaskColor.a * 1.6 * alpha);
|
||
|
sourceMix = mix(bgColor, sourceMix, maskColor * alpha);
|
||
|
// vec3 networkTextColor = texture2D(netWorkTextMap, TexCoord).rgb;
|
||
|
|
||
|
frgColor = sourceMix + textColor * alpha;
|
||
|
// clamp(mix(bgColor, sourceMix, sourceColor.a * alpha) + textColor * alpha + networkTextColor, 0, 1);
|
||
|
// if (TexCoord.x <= 0.2 || TexCoord.s >= 0.8) {
|
||
|
// frgColor = bgColor;
|
||
|
// } else {
|
||
|
// frgColor = clamp(mix(bgColor, sourceMix, maskColor * alpha) + textColor * alpha + networkTextColor, 0, 1);
|
||
|
// // clamp(mix(bgMix, sourceMix, maskColor * alpha) + textColor * alpha + networkTextColor, 0, 1);
|
||
|
// //mix (color, mix(sourceColor, maskColor, invBaseColor), 1);
|
||
|
// }
|
||
|
} else {
|
||
|
vec3 networkTextColor = texture2D(netWorkTextMap, TexCoord).rgb;
|
||
|
frgColor = networkTextColor + bgColor;
|
||
|
}
|
||
|
|
||
|
FragColor = vec4(frgColor , 1.0);
|
||
|
}
|