thebookofshaders/10/ikeda-00.frag

47 lines
1.0 KiB
GLSL
Raw Normal View History

2015-07-21 20:25:41 +00:00
// Author @patriciogv - 2015
2016-04-24 15:26:26 +00:00
// Title: Ikeda Test patterns
2015-07-21 20:25:41 +00:00
#ifdef GL_ES
precision mediump float;
#endif
uniform vec2 u_resolution;
uniform vec2 u_mouse;
uniform float u_time;
float random (in float x) {
return fract(sin(x)*1e4);
}
2017-08-19 10:11:58 +00:00
float random (in vec2 st) {
2015-07-21 20:25:41 +00:00
return fract(sin(dot(st.xy, vec2(12.9898,78.233)))* 43758.5453123);
}
float randomSerie(float x, float freq, float t) {
return step(.8,random( floor(x*freq)-floor(t) ));
}
void main() {
vec2 st = gl_FragCoord.xy/u_resolution.xy;
st.x *= u_resolution.x/u_resolution.y;
2017-08-19 10:11:58 +00:00
2015-07-21 20:25:41 +00:00
vec3 color = vec3(0.0);
float cols = 2.;
float freq = random(floor(u_time))+abs(atan(u_time)*0.1);
float t = 60.+u_time*(1.0-freq)*30.;
2015-07-23 14:02:53 +00:00
if (fract(st.y*cols* 0.5) < 0.5){
2015-07-21 20:25:41 +00:00
t *= -1.0;
}
2015-07-23 14:02:53 +00:00
freq += random(floor(st.y));
2015-07-21 20:25:41 +00:00
float offset = 0.025;
2015-07-23 14:02:53 +00:00
color = vec3(randomSerie(st.x, freq*100., t+offset),
randomSerie(st.x, freq*100., t),
randomSerie(st.x, freq*100., t-offset));
2015-07-21 20:25:41 +00:00
2015-07-23 14:02:53 +00:00
gl_FragColor = vec4(1.0-color,1.0);
2017-08-19 10:11:58 +00:00
}