Last active
April 8, 2021 20:18
-
-
Save marioecg/b163c5b4f7f5086137defd78dbb34e1f to your computer and use it in GitHub Desktop.
This file contains 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
#define PI 3.1415926538 | |
uniform float time; | |
varying vec2 vUv; | |
float map(float value, float inMin, float inMax, float outMin, float outMax) { | |
return outMin + (outMax - outMin) * (value - inMin) / (inMax - inMin); | |
} | |
// https://iquilezles.org/www/articles/distgradfunctions2d/distgradfunctions2d.htm | |
vec3 sdgCircle(in vec2 p, in float r) { | |
float d = length(p); | |
return vec3( d-r, p/d ); | |
} | |
void main () { | |
vec2 uv = vUv - 0.5; | |
vec3 color = vec3(0.0); | |
vec3 circle = vec3(1.0); | |
float amp = map(cos(time), -1.0, 1.0, 0.15, 0.35); | |
float t = time * 1.0; | |
const int n = 1; | |
for (int i = 0; i <= n; i++) { | |
float offset = map(float(i), 0.0, float(n), 0.0, PI * 1.0); | |
circle *= sdgCircle( | |
uv + vec2(cos(t + offset), sin(t + offset)) * amp, | |
1.0 | |
); | |
} | |
float goff = map(sin(time), -1.0, 1.0, 0.0, 0.6); | |
circle = mix(vec3(1.0, goff, 0.5), vec3(1.0), circle * 1.0); | |
gl_FragColor = vec4(circle, 1.0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment