The Code Therapy

N.E.O.N Strings

Simple usage of sinusoids

Created by lpg2709 on Mon, 11 Dec 2023 12:30:45 GMT.


#version 300 es
precision highp float;

uniform vec2 resolution;
uniform float time;
out vec4 fragColor;

void main(void) {
    vec3 r = vec3(0.9, 0.0, 0.3);
    vec3 g = vec3(0.0, 0.9, 0.3);
    vec3 b = vec3(0.0, 0.3, 0.9);
    vec3 y = vec3(0.9, 0.9, 0.3);

    vec2 p = (gl_FragCoord.xy * 2.0) - resolution.xy;
    p /= min(resolution.x, resolution.y);

    float sr = 0.01 / abs(p.x + sin(p.y * 0.5 - time * 0.1) / 2.0);
    float sg = 0.01 / abs(p.x + sin(p.y * 0.5 - time * 0.2) / 2.0);
    float sb = 0.01 / abs(p.x + sin(p.y * 0.5 - time * 0.4 + 3.14) / 2.0);
    float sy = 0.01 / abs(p.x + sin(p.y * 0.5 - time * 0.5 + 3.14) / 2.0);

    vec3 finalColor = r * sr + g * sg + b * sb + y * sy;
    // Output to screen
    fragColor = vec4(finalColor,1.0);
}