Skip to content

Instantly share code, notes, and snippets.

@b0o
Created December 6, 2024 02:03
Show Gist options
  • Save b0o/1171b9d9931f348d8d08cca0148debbd to your computer and use it in GitHub Desktop.
Save b0o/1171b9d9931f348d8d08cca0148debbd to your computer and use it in GitHub Desktop.
// Loosely based on postprocessing shader by inigo quilez, License Creative
// Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.
vec2 curve(vec2 uv) {
uv = (uv - 0.5) * 2.0;
uv *= 1.05; // Reduced from 1.1
uv.x *= 1.0 + pow((abs(uv.y) / 6.0), 2.0); // Reduced curve from 5.0 to 6.0
uv.y *= 1.0 + pow((abs(uv.x) / 5.0), 2.0); // Reduced curve from 4.0 to 5.0
uv = (uv / 2.0) + 0.5;
uv = uv * 0.95 + 0.025; // Less aggressive edge scaling
return uv;
}
void mainImage(out vec4 fragColor, in vec2 fragCoord) {
vec2 q = fragCoord.xy / iResolution.xy;
vec2 uv = q;
uv = curve(uv);
vec3 oricol = texture(iChannel0, vec2(q.x, q.y)).xyz;
vec3 col;
float x = sin(0.3 * iTime + uv.y * 21.0) * sin(0.7 * iTime + uv.y * 29.0) *
sin(0.3 + 0.33 * iTime + uv.y * 31.0) * 0.0017;
col.r = texture(iChannel0, vec2(x + uv.x + 0.0005, uv.y + 0.0005)).x + 0.03;
col.g = texture(iChannel0, vec2(x + uv.x + 0.000, uv.y - 0.001)).y + 0.03;
col.b = texture(iChannel0, vec2(x + uv.x - 0.001, uv.y + 0.000)).z + 0.03;
col.r += 0.04 * texture(iChannel0, 0.75 * vec2(x + 0.015, -0.017) +
vec2(uv.x + 0.0005, uv.y + 0.0005))
.x;
col.g += 0.025 * texture(iChannel0, 0.75 * vec2(x + -0.012, -0.01) +
vec2(uv.x + 0.000, uv.y - 0.001))
.y;
col.b += 0.04 * texture(iChannel0, 0.75 * vec2(x + -0.01, -0.008) +
vec2(uv.x - 0.001, uv.y + 0.000))
.z;
col = clamp(col * 0.7 + 0.3 * col * col * 1.0, 0.0, 1.0);
float vig = (0.0 + 1.0 * 12.0 * uv.x * uv.y * (1.0 - uv.x) * (1.0 - uv.y));
col *= vec3(pow(vig, 0.4));
col *= vec3(0.97, 1.03, 0.97);
col *= 2.2;
float scans = clamp(0.6 + 0.2 * sin(3.5 * iTime + uv.y * iResolution.y * 1.5),
0.0, 1.0);
float s = pow(scans, 1.5);
col = col * vec3(0.6 + 0.4 * s);
col *= 1.0 + 0.01 * sin(110.0 * iTime);
if (uv.x < 0.0 || uv.x > 1.0)
col *= 0.0;
if (uv.y < 0.0 || uv.y > 1.0)
col *= 0.0;
col *=
1.0 - 0.35 * vec3(clamp((mod(fragCoord.x, 2.0) - 1.0) * 2.0, 0.0, 1.0));
float comp = smoothstep(0.1, 0.9, sin(iTime));
// Remove the next line to stop cross-fade between original and postprocess
// col = mix( col, oricol, comp );
fragColor = vec4(col, 1.0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment