// ╔═════════════╦════════════════╗
// ║ Marco Gomez ║ https://mgz.me ║
// ╚═════════════╩════════════════╝
precision highp float;
uniform sampler2D prgm7Texture;
uniform vec2 resolution;
uniform float time;
uniform float fft;
const float reinhardAmount = 0.5;
const float contrast = 1.0;
const float brightness = 2.1;
const float amount = 1.0;
const float saturation = 1.2;
const vec2 vignetteSize = vec2(0.35, 0.35);
const float vignetteRoundness = 0.12;
const float vignetteMix = 0.5;
const float vignetteSmoothness = 0.42;
const float W = 1.2;
const float T = 7.5;
float filmicReinhardCurve(float x) {
float q = (T * T + 1.0) * x * x;
return q / (q + x + T * T);
}
vec3 filmicReinhard(vec3 c) {
float w = filmicReinhardCurve(W);
return vec3(
filmicReinhardCurve(c.r),
filmicReinhardCurve(c.g),
filmicReinhardCurve(c.b)
) / w;
}
vec3 ContrastSaturationBrightness(vec3 color, float brt, float sat, float con) {
const float AvgLumR = 0.5;
const float AvgLumG = 0.5;
const float AvgLumB = 0.5;
const vec3 LumCoeff = vec3(0.2125, 0.7154, 0.0721);
vec3 AvgLumin = vec3(AvgLumR, AvgLumG, AvgLumB);
vec3 brtColor = color * brt;
vec3 intensity = vec3(dot(brtColor, LumCoeff));
vec3 satColor = mix(intensity, brtColor, sat);
vec3 conColor = mix(AvgLumin, satColor, con);
return conColor;
}
float sdSquare(vec2 point, float width) {
vec2 d = abs(point) - width;
return min(max(d.x, d.y), 0.0) + length(max(d, 0.0));
}
float vignette(vec2 uv, vec2 size, float roundness, float smoothness) {
uv -= 0.5;
float minWidth = min(size.x, size.y);
uv.x = sign(uv.x) * clamp(abs(uv.x) - abs(minWidth - size.x), 0.0, 1.0);
uv.y = sign(uv.y) * clamp(abs(uv.y) - abs(minWidth - size.y), 0.0, 1.0);
float boxSize = minWidth * (1.0 - roundness);
float dist = sdSquare(uv, boxSize) - (minWidth * roundness);
return 1.0 - smoothstep(0.0, smoothness, dist);
}
void main(void) {
vec2 uv = gl_FragCoord.xy / resolution.xy;
vec4 prgm7 = texture2D(prgm7Texture, uv);
vec3 reinhard = filmicReinhard(prgm7.rgb);
vec3 color = prgm7.rgb;
color = mix(prgm7.rgb, reinhard, reinhardAmount);
color = ContrastSaturationBrightness(color, brightness, saturation, contrast);
float v = vignette(uv, vignetteSize, vignetteRoundness, vignetteSmoothness);
vec3 vig = color * v;
color = mix(color, vig, vignetteMix);
color = mix(prgm7.xyz, color, amount);
color = clamp(color, 0.0, 1.0);
gl_FragColor = vec4(color, 1.0);
}
// ╔═════════════╦════════════════╗
// ║ Marco Gomez ║ https://mgz.me ║
// ╚═════════════╩════════════════╝
precision highp float;
uniform sampler2D noiseTexture;
uniform vec2 resolution;
uniform vec2 mouselerp;
uniform float time;
uniform float fft;
const float PI = acos(-1.0);
const float TAU = PI * 2.0;
const float bgWaveSpeed = 2.0;
const float xDistMag = 0.05;
const float yDistMag = 0.05;
const float xSineCycles = TAU;
const float ySineCycles = TAU;
const float tPixelSize = 16.0;
const float transitionSpread = 0.5;
const float transitionSpeed = 0.105;
const float transitionIntensity = 8.0;
vec2 warp(vec2 uv, vec2 warpAmount) {
uv = uv * 2.0 - 1.0;
vec2 offset = abs(uv.yx) / vec2(warpAmount.x, warpAmount.y);
uv = uv + uv * offset * offset;
uv = uv * 0.5 + 0.5;
return uv;
}
vec2 hash22(vec2 p) {
vec3 p3 = fract(vec3(p.xyx) * vec3(0.1031, 0.1030, 0.0973));
p3 += dot(p3, p3.yzx + 19.19);
return fract((p3.xx + p3.yz) * p3.zy);
}
vec2 rand(vec2 uv) {
uv = fract(uv * vec2(5.3987, 5.4421));
uv += dot(uv.yx, uv.xy + vec2(21.5351, 14.3137));
float xy = uv.x * uv.y;
return vec2(fract(xy * 95.4307), fract(xy * 75.04961));
}
void main(void) {
vec2 uv = gl_FragCoord.xy / resolution.xy;
float ar = resolution.x / resolution.y;
uv *= vec2(ar, 1.0);
vec4 col = vec4(1.0);
float ti = 256.0;
float mi = 8.0;
uv += mouselerp * vec2(0.25 * ar, 0.25);
uv.y += time * 0.12;
float minRes = min(resolution.x, resolution.y);
vec2 fc = gl_FragCoord.xy / minRes;
float wt = time * bgWaveSpeed;
float xAngle = wt + fc.y * ySineCycles;
float yAngle = wt + fc.x * xSineCycles;
bool bxHalf, byHalf;
vec2 distortOffset = vec2(sin(xAngle), sin(yAngle)) * vec2(xDistMag, yDistMag) * 0.5;
uv += distortOffset;
float uvm = 16.0;
vec2 id = floor(uv * uvm);
vec2 ruv = fract(uv * uvm) - 0.5;
vec2 noiseUV = ruv / resolution.xy;
float noise = texture2D(noiseTexture, noiseUV).x * transitionSpread;
float progress = (time * transitionSpeed) + noiseUV.y + noise;
float peak = cos(progress) * transitionIntensity;
float transition = clamp(peak, 0.0, 1.0);
float f = fft * 0.5;
vec2 hashA = vec2(
(rand(id).x) + f,
(rand(id * 3.0 + 2.0).y) + f
);
vec2 hashB = vec2(
(rand(id).x * 1.5) + f,
(rand(id * 3.0 + 2.0).y * 1.5) + f
);
vec2 hash = mix(hashA, hashB, transition);
vec2 n = vec2(
pow(abs(sin(time * 0.7 + hash.x * 1.5)), 2.0),
pow(abs(cos(time * 2.1 + hash.y * 5.0)), 2.0)
);
float d = max(dot(vec2(0.9, -0.8), n), 0.01);
float c = smoothstep(0.5, 0.1, length(ruv));
vec3 colA = vec3(0.3, 0.0, 0.6);
vec3 colB = vec3(0.0, 0.4, 0.7);
vec3 colC = vec3(0.6, 0.3, 0.3);
vec3 colD = vec3(0.0, 0.3, 0.8);
vec3 mcolA = mix(colA, colB, d) * c * d;
vec3 mcolB = mix(colC, colD, d) * c * d;
vec3 mcol = mix(mcolB, mcolA, transition);
col.xyz = mcol;
gl_FragColor = col;
}
// ╔═════════════╦════════════════╗
// ║ Marco Gomez ║ https://mgz.me ║
// ╚═════════════╩════════════════╝
precision highp float;
uniform sampler2D noiseTexture;
uniform sampler2D prgm1Texture;
uniform vec2 resolution;
uniform float time;
vec4 rgbShift(vec2 p , vec4 shift) {
shift *= 2.0 * shift.w - 1.0;
vec2 rs = vec2(shift.x, -shift.y);
vec2 gs = vec2(shift.y, -shift.z);
vec2 bs = vec2(shift.z, -shift.x);
float r = texture2D(prgm1Texture, p + rs, 0.0).x;
float g = texture2D(prgm1Texture, p + gs, 0.0).y;
float b = texture2D(prgm1Texture, p + bs, 0.0).z;
return vec4(r,g,b,1.0);
}
vec4 noise(vec2 uv) {
return texture2D(noiseTexture, uv, 0.0);
}
vec4 vec4pow(vec4 v, float p) {
return vec4(
pow(v.x, p),
pow(v.y, p),
pow(v.z, p),
v.w
);
}
void main(void) {
vec2 uv = gl_FragCoord.xy / resolution.xy;
vec2 mo = uv * 2.0 - 1.0;
mo *= 0.01;
vec3 chromaticAberration;
chromaticAberration.r = texture2D(prgm1Texture, uv - mo * 0.05, 0.0).r;
chromaticAberration.g = texture2D(prgm1Texture, uv - mo * 0.15, 0.0).g;
chromaticAberration.b = texture2D(prgm1Texture, uv - mo * 0.25, 0.0).b;
vec4 color = vec4(vec3(0.0), 1.0);
color.xyz = mix(color.xyz, chromaticAberration, 0.3);
const float speed = 0.01;
const float amplitude = 0.015;
vec4 shift = vec4pow(
noise(
vec2(speed * time, speed * time / 25.0 )
), 8.0
) * vec4(vec3(amplitude), 1.0);
color += rgbShift(uv, shift);
vec4 prgm1 = texture2D(prgm1Texture, uv);
gl_FragColor = vec4(
clamp(mix(color.xyz, prgm1.xyz, 0.3), 0.0, 1.0),
1.0
);
}
// ╔═════════════╦════════════════╗
// ║ Marco Gomez ║ https://mgz.me ║
// ╚═════════════╩════════════════╝
precision highp float;
uniform sampler2D prgm3Texture;
uniform sampler2D prgm4Texture;
uniform sampler2D prgm2Texture;
uniform vec2 resolution;
uniform vec2 mouse;
uniform float time;
uniform int frame;
void main(void) {
vec2 uv = gl_FragCoord.xy / resolution.xy;
vec2 mp = ((mouse + 1.0) * 0.5) * resolution;
vec3 e = vec3(vec2(1.0) / resolution.xy, 0.0);
vec2 q = uv;
vec4 c = texture2D(prgm3Texture, q);
float p11 = c.x;
float p10 = texture2D(prgm4Texture, q - e.zy).x + texture2D(prgm2Texture, q - e.zy).x * 0.007;
float p01 = texture2D(prgm4Texture, q - e.xz).x + texture2D(prgm2Texture, q - e.xz).x * 0.007;
float p21 = texture2D(prgm4Texture, q + e.xz).x + texture2D(prgm2Texture, q + e.xz).x * 0.007;
float p12 = texture2D(prgm4Texture, q + e.zy).x + texture2D(prgm2Texture, q + e.zy).x * 0.007;
float d = 0.0;
d = smoothstep(86.0, 0.5, length(mp.xy - gl_FragCoord.xy) * 1.5);
d += -(p11 - 0.5) * 2.0 + (p10 + p01 + p21 + p12 - 2.0);
d *= 0.9965;
d *= max(min(1.0, float(frame)), 0.0) * clamp(time - 1.0, 0.0, 1.0);
d = d * 0.5 + 0.5;
gl_FragColor = vec4(d, 0.0, 0.0, 1.0);
}
// ╔═════════════╦════════════════╗
// ║ Marco Gomez ║ https://mgz.me ║
// ╚═════════════╩════════════════╝
precision highp float;
uniform sampler2D prgm3Texture;
uniform sampler2D prgm4Texture;
uniform sampler2D prgm2Texture;
uniform vec2 resolution;
uniform vec2 mouselerp;
uniform float time;
uniform int frame;
void main(void) {
vec2 uv = gl_FragCoord.xy / resolution.xy;
vec2 mp = ((mouselerp + 1.0) * 0.5) * resolution;
vec3 e = vec3(vec2(1.0) / resolution.xy, 0.0);
vec2 q = uv;
vec4 c = texture2D(prgm4Texture, q);
float p11 = c.x;
float p10 = texture2D(prgm3Texture, q - e.zy).x + texture2D(prgm2Texture, q - e.zy).x * 0.0006;
float p01 = texture2D(prgm3Texture, q - e.xz).x + texture2D(prgm2Texture, q - e.xz).x * 0.0006;
float p21 = texture2D(prgm3Texture, q + e.xz).x + texture2D(prgm2Texture, q + e.xz).x * 0.0006;
float p12 = texture2D(prgm3Texture, q + e.zy).x + texture2D(prgm2Texture, q + e.zy).x * 0.0006;
float d = 0.0;
d = smoothstep(212.0, 0.0, length(mp.xy - gl_FragCoord.xy) * resolution.x);
d += -(p11 - 0.5) * 2.0 + (p10 + p01 + p21 + p12 - 2.0);
d *= 0.999;
d *= max(min(1.0, float(frame)), 0.0) * clamp(time - 1.0, 0.0, 1.0);
d = d * 0.5 + 0.5;
gl_FragColor = vec4(d, 0.0, 0.0, 1.0);
}
// ╔═════════════╦════════════════╗
// ║ Marco Gomez ║ https://mgz.me ║
// ╚═════════════╩════════════════╝
precision highp float;
uniform sampler2D prgm3Texture;
uniform sampler2D prgm2Texture;
uniform vec2 resolution;
uniform vec2 mouse;
uniform float time;
void main(void) {
vec2 uv = gl_FragCoord.xy / resolution.xy;
vec2 mp = (( mouse + 1.0) * 0.5) * resolution;
vec3 e = vec3(vec2(1.0) / resolution.xy, 0.0) * 0.17;
float p10 = texture2D(prgm3Texture, uv - e.zy).x;
float p01 = texture2D(prgm3Texture, uv - e.xz).x;
float p21 = texture2D(prgm3Texture, uv + e.xz).x;
float p12 = texture2D(prgm3Texture, uv + e.zy).x;
vec3 grad = normalize(vec3(p21 - p01, p12 - p10, 1.0));
vec4 c = texture2D(prgm2Texture, uv + grad.xy * 0.3);
vec3 light = normalize(vec3(0.2, -0.5, 0.7));
float diffuse = dot(grad, light);
float spec = pow(abs(max(0.0, -reflect(light, grad).z)), 60.0);
vec4 prgm2 = texture2D(prgm2Texture, gl_FragCoord.xy / resolution.xy);
vec4 specCol = mix(vec4(spec), spec * prgm2, 0.75);
vec4 col = mix(c, c * max(diffuse, 0.0) + specCol, 0.5);
col = clamp(col, 0.005, 1.0);
gl_FragColor = vec4(col.rgb, 1.0);
}
// ╔═════════════╦════════════════╗
// ║ Marco Gomez ║ https://mgz.me ║
// ╚═════════════╩════════════════╝
precision highp float;
uniform sampler2D prgm5Texture;
uniform vec2 resolution;
uniform float time;
float hash(vec2 p) {
return fract(sin(dot(p, vec2(41.0, 289.0))) * 45758.5453);
}
void main(void) {
vec2 uv = gl_FragCoord.xy / resolution.xy;
vec4 col = texture2D(prgm5Texture, uv);
float w = 0.1;
vec2 a = vec2(uv.x - 0.5, uv.y - 0.66);
vec2 b = a * 0.15 / float(10.0);
uv += b * (hash(uv.xy + fract(time)) * 2.0);
for (float i = 1.0; i > 0.8; i-= 0.0025) {
uv -= 0.5;
uv *= i;
uv += 0.5;
col += texture2D(prgm5Texture, uv) * w * 1.5;
w *= 0.95;
}
col *= 0.9;
gl_FragColor = col * 2.0;
}
// ╔═════════════╦════════════════╗
// ║ Marco Gomez ║ https://mgz.me ║
// ╚═════════════╩════════════════╝
precision highp float;
uniform sampler2D prgm6Texture;
uniform vec2 resolution;
uniform float time;
const float PI = acos(-1.0);
const float TAU = PI * 2.0;
const float hardscan = -16.0; // -8.0 = soft | -16.0 = medium
const float hardPix = -4.0; // -2.0 = soft | -4.0 = hard
const float maskDark = 0.5;
const float maskLight = 2.5;
float toLinear(float c) {
return (c <= 0.04045) ? c / 12.92 : pow(abs((c + 0.055) / 1.055), 2.4);
}
vec3 toLinear(vec3 c) {
return vec3(toLinear(c.r), toLinear(c.g), toLinear(c.b));
}
float toSRGB(float c) {
return(c < 0.0031308 ? c * 12.92 : 1.055 * pow(abs(c), 0.41666) - 0.055);
}
vec3 toSRGB(vec3 c) {
return vec3(toSRGB(c.r), toSRGB(c.g), toSRGB(c.b));
}
vec3 fetch(vec2 pos, vec2 off, vec2 res) {
pos = floor(pos * res + off) / res;
if (max(abs(pos.x - 0.5), abs(pos.y - 0.5)) > 0.5) {
return vec3(0.0);
}
return toLinear(texture2D(prgm6Texture, pos.xy, -16.0).xyz);
}
vec2 dist(vec2 pos, vec2 res) {
pos = pos * res;
return -((pos - floor(pos)) - vec2(0.5));
}
float gauss(float pos, float scale) {
return exp2(scale * pos * pos);
}
vec3 horz3(vec2 pos, float off, vec2 res) {
vec3 b = fetch(pos, vec2(-1.0, off), res);
vec3 c = fetch(pos, vec2(+0.0, off), res);
vec3 d = fetch(pos, vec2(+1.0, off), res);
float dst = dist(pos, res).x;
float scale = hardPix;
float wb = gauss(dst - 1.0, scale);
float wc = gauss(dst + 0.0, scale);
float wd = gauss(dst + 1.0, scale);
return (b * wb + c * wc + d * wd) / (wb + wc + wd);
}
vec3 horz5(vec2 pos, float off, vec2 res) {
vec3 a = fetch(pos, vec2(-2.0, off), res);
vec3 b = fetch(pos, vec2(-1.0, off), res);
vec3 c = fetch(pos, vec2(+0.0, off), res);
vec3 d = fetch(pos, vec2(+1.0, off), res);
vec3 e = fetch(pos, vec2(+2.0, off), res);
float dst = dist(pos, res).x;
float scale = hardPix;
float wa = gauss(dst - 2.0, scale);
float wb = gauss(dst - 1.0, scale);
float wc = gauss(dst + 0.0, scale);
float wd = gauss(dst + 1.0, scale);
float we = gauss(dst + 2.0, scale);
return (a * wa + b * wb + c * wc + d * wd + e * we) / (wa + wb + wc + wd + we);
}
float scan(vec2 pos, float off, vec2 res) {
float dst = dist(pos, res).y;
return gauss(dst + off, hardscan);
}
vec3 tri(vec2 pos, vec2 res) {
vec3 a = horz3(pos, -1.0, res);
vec3 b = horz5(pos, +0.0, res);
vec3 c = horz3(pos, +1.0, res);
float wa = scan(pos, -1.0, res);
float wb = scan(pos, +0.0, res);
float wc = scan(pos, +1.0, res);
return a * wa + b * wb + c * wc;
}
vec3 mask(vec2 pos) {
pos.x += pos.y * 3.0;
vec3 m = vec3(maskDark, maskDark, maskDark);
pos.x = fract(pos.x / 6.0);
if (pos.x < 0.333) {
m.r = maskLight;
} else if (pos.x < 0.666) {
m.g = maskLight;
} else {
m.b = maskLight;
}
return m;
}
float bar(float pos, float bar) {
pos -= bar;
return pos * pos < 4.0 ? 0.0 : 1.0;
}
float rand(vec2 uv, float t) {
float seed = dot(uv, vec2(12.9898, 78.233));
return fract(sin(seed) * 43758.5453123 + t);
}
float gaussian(float z, float u, float o) {
return (
(1.0 / (o * sqrt(TAU))) *
(exp(-(((z - u) * (z - u)) / (2.0 * (o * o)))))
);
}
vec3 gaussgrain(float t) {
vec2 ps = vec2(1.0) / resolution.xy;
vec2 uv = gl_FragCoord.xy * ps;
float noise = rand(uv, t);
noise = gaussian(noise, 0.0, 0.5);
return vec3(noise);
}
vec2 warp(vec2 uv, vec2 warpAmount) {
uv = uv * 2.0 - 1.0;
vec2 offset = abs(uv.yx) / vec2(warpAmount.x, warpAmount.y);
uv = uv + uv * offset * offset;
uv = uv * 0.5 + 0.5;
return uv;
}
void drawVig(inout vec3 color, vec2 uv) {
float vignette = uv.x * uv.y * (1.0 - uv.x) * (1.0 - uv.y);
vignette = clamp(pow(abs(16.0 * vignette), 0.1), 0.0, 1.0);
color *= vignette;
}
void main(void) {
vec2 warpAmount = vec2(7.0, 5.0);
float resDivisor = 3.0;
vec2 res = vec2(resolution.x / resDivisor, resolution.y / resDivisor);
vec2 uv = gl_FragCoord.xy / resolution.xy;
float vig = (0.0 + 1.0 * 21.0 * uv.x * uv.y * (1.0 - uv.x) * (1.0 - uv.y));
float v = exp(-0.01 * length(uv)) * vig;
float frameScale = 29.97;
float frameTime = floor(time * frameScale) / frameScale;
vec3 g = gaussgrain(frameTime) * 0.07;
vec2 pos = mix(uv, warp(uv, warpAmount), 0.3334);
vec4 color = vec4(tri(pos, res) * mask(gl_FragCoord.xy), 1.0);
color.xyz = toSRGB(color.xyz * 2.0) - g;
color = mix(color, color * v, 0.7);
gl_FragColor = color;
}