GhosttyConfig/ghostty-shaders/shader-art.glsl
2025-09-29 15:34:29 +02:00

47 lines
1.6 KiB
GLSL

/* This animation is the material of my first youtube tutorial about creative
coding, which is a video in which I try to introduce programmers to GLSL
and to the wonderful world of shaders, while also trying to share my recent
passion for this community.
Video URL: https://youtu.be/f4s1h2YETNY
*/
const float timeMultiplier = 0.1f;
#define BLACK_BLEND_THRESHOLD .4 // This is controls the dim of the screen
//https://iquilezles.org/articles/palettes/
vec3 palette(float t) {
vec3 a = vec3(0.5, 0.5, 0.5);
vec3 b = vec3(0.5, 0.5, 0.5);
vec3 c = vec3(1.0, 1.0, 1.0);
vec3 d = vec3(0.263, 0.416, 0.557);
return a + b * cos(6.28318 * (c * t + d));
}
//https://www.shadertoy.com/view/mtyGWy
void mainImage(out vec4 fragColor, in vec2 fragCoord) {
vec2 uv = (fragCoord * 2.0 - iResolution.xy) / iResolution.y;
vec2 uv0 = uv;
vec3 finalColor = vec3(0.0);
for (float i = 0.0; i < 4.0; i++) {
uv = fract(uv * 1.5) - 0.5;
float d = length(uv) * exp(-length(uv0));
vec3 col = palette(length(uv0) + i * .4 + iTime * timeMultiplier * .4);
d = sin(d * 8. + iTime * timeMultiplier) / 8.;
d = abs(d);
d = pow(0.01 / d, 1.2);
finalColor += col * d;
}
vec2 termUV = fragCoord.xy / iResolution.xy;
vec4 terminalColor = texture(iChannel0, termUV);
float alpha = step(length(terminalColor.rgb), BLACK_BLEND_THRESHOLD);
vec3 blendedColor = mix(terminalColor.rgb * 1.0, finalColor.rgb * 0.3, alpha);
fragColor = vec4(blendedColor, terminalColor.a);
}