Last active
November 4, 2025 09:59
-
-
Save sbOogway/5301846c66e1c5bcd28a025659ee2499 to your computer and use it in GitHub Desktop.
cone of light
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // https://shadertoy.com | |
| // tweak the frequency and let the magic happen dawg | |
| #define FREQUENCY 333. | |
| #define THICKNESS 0.004 | |
| #define Y_SHIFT 0.5 | |
| #define AMPLITUDE 0.2 | |
| #define SPEED 1. | |
| #define PI 3.141592653589793 | |
| #define BLACK vec3(0.,0.,0.) | |
| #define RED vec3(1.,0.,0.) | |
| #define GREEN vec3(0.,1.,0.) | |
| #define BLUE vec3(0.,0.,1.) | |
| vec3 drawSine(vec2 uv, vec3 color, float phase) { | |
| float sine = sin(uv.y * FREQUENCY + iTime * SPEED + phase) * AMPLITUDE + Y_SHIFT; | |
| bool isSineUpper = uv.x <= (sine + THICKNESS) ; | |
| bool isSineLower = uv.x >= (sine - THICKNESS); | |
| if (isSineUpper && isSineLower) { | |
| return color; | |
| } else { | |
| return BLACK; | |
| } | |
| } | |
| void mainImage( out vec4 fragColor, in vec2 fragCoord ) | |
| { | |
| vec2 uv = fragCoord/iResolution.xy; | |
| vec3 col; | |
| vec3 t = vec3(iTime); | |
| col += drawSine(uv, RED , 0.); | |
| col += drawSine(uv, GREEN, 2./3. * PI); | |
| col += drawSine(uv, BLUE, 4./3. * PI); | |
| fragColor = vec4(col,1.0); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment