weird: added another iteration of ikeda games; utils: added a perlin noise-like noise function

This commit is contained in:
2017-06-09 18:41:01 -04:00
parent 95f6ab8c6b
commit 478cf7b56a
2 changed files with 46 additions and 0 deletions

View File

@@ -3,3 +3,9 @@ float random(vec2 st) {
vec2(12.9898,78.233)))*
43758.5453123);
}
float noise(float x) {
float i = floor(x);
float f = fract(x);
return mix(rand(i), rand(i + 1.0), smoothstep(0.,1.,f));
}

40
weird/ikeda3.glsl Normal file
View File

@@ -0,0 +1,40 @@
#ifdef GL_ES
precision mediump float;
#endif
uniform vec2 u_resolution;
uniform float u_time;
uniform vec2 u_mouse;
float random(in float x) {
return fract(sin(x)*1e6);
}
float randcol(float x, float f, float t) {
return step(0.75,random(floor(x*f)-floor(t)));
}
void main() {
vec2 st = gl_FragCoord.xy/u_resolution.xy;
st.x *= u_resolution.x/u_resolution.y;
float cols = 64.;
float freq = random(floor(u_time))+abs(atan(u_time)*.1);
float t = 40.*u_time*(1.-freq);
if (gl_FragCoord.y < u_mouse.y && st.y < 0.9) {
gl_FragColor = vec4(1.);
return;
}
if (fract(st.y*cols*.5) < .5) t *= -1.;
freq += random(floor(st.y*20.));
float offset = .025;
vec3 color = vec3(randcol(st.x, freq*100.+random(freq), t+offset),
randcol(st.x, freq*100., t),
randcol(st.x, freq*100.+random(freq), t-offset));
gl_FragColor = vec4(1.-color,1.);
}