Last active
October 15, 2021 12:13
-
-
Save keijiro/79b2f54e34561b83066b386c3391c273 to your computer and use it in GitHub Desktop.
KodeLife fragment shader sketch
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
#version 150 | |
uniform float time; | |
uniform sampler2D prevFrame; | |
uniform vec2 resolution; | |
uniform vec3 spectrum; | |
out vec4 fragColor; | |
float rand(float x, float y) | |
{ | |
return fract(sin(12.9898 * x + 78.233 * y) * 43758.5453); | |
} | |
void main(void) | |
{ | |
vec2 uv = gl_FragCoord.xy / resolution; | |
float aspect = resolution.x / resolution.y; | |
// ellipse | |
float r = length((uv - 0.5) * vec2(aspect, 1)); | |
float c = 1 - step(spectrum.x, r); | |
// displacement | |
float t = floor(time * 2); | |
float phi = rand(t, 0) * 3.14; | |
vec2 d = vec2(cos(phi), sin(phi)); | |
float wd = rand(t, 1) * 100; | |
float sd = floor(wd * dot(uv, d.yx * vec2(-1, 1))); | |
uv += d * 0.02 * (rand(sd, t) - 0.5); | |
// feedback | |
c += texture(prevFrame, uv).b * 0.99; | |
// color gradient | |
float c1 = 0.5 + sin(c * 9.12 + time * 1.11) * 0.5; | |
float c2 = 0.5 + sin(c * 7.33 + time * 1.73) * 0.5; | |
fragColor = vec4(c1, c2, c, 0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment