You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
thebookofshaders/10/ikeda-03.frag

63 lines
1.8 KiB
GLSL

// Author @patriciogv - 2015
// Title: Ikeda Data Stream
#ifdef GL_ES
precision mediump float;
#endif
// Copyright (c) Patricio Gonzalez Vivo, 2015 - http://patriciogonzalezvivo.com/
// I am the sole copyright owner of this Work.
//
// You cannot host, display, distribute or share this Work in any form,
// including physical and digital. You cannot use this Work in any
// commercial or non-commercial product, website or project. You cannot
// sell this Work and you cannot mint an NFTs of it.
// I share this Work for educational purposes, and you can link to it,
// through an URL, proper attribution and unmodified screenshot, as part
// of your educational material. If these conditions are too restrictive
// please contact me and we'll definitely work it out.
uniform vec2 u_resolution;
uniform vec2 u_mouse;
uniform float u_time;
float random (in float x) {
return fract(sin(x)*1e4);
}
float random (in vec2 st) {
return fract(sin(dot(st.xy, vec2(12.9898,78.233)))* 43758.5453123);
}
float pattern(vec2 st, vec2 v, float t) {
vec2 p = floor(st+v);
return step(t, random(100.+p*.000001)+random(p.x)*0.5 );
}
void main() {
vec2 st = gl_FragCoord.xy/u_resolution.xy;
st.x *= u_resolution.x/u_resolution.y;
vec2 grid = vec2(100.0,50.);
st *= grid;
vec2 ipos = floor(st); // integer
vec2 fpos = fract(st); // fraction
vec2 vel = vec2(u_time*2.*max(grid.x,grid.y)); // time
vel *= vec2(-1.,0.0) * random(1.0+ipos.y); // direction
// Assign a random value base on the integer coord
vec2 offset = vec2(0.1,0.);
vec3 color = vec3(0.);
color.r = pattern(st+offset,vel,0.5+u_mouse.x/u_resolution.x);
color.g = pattern(st,vel,0.5+u_mouse.x/u_resolution.x);
color.b = pattern(st-offset,vel,0.5+u_mouse.x/u_resolution.x);
// Margins
color *= step(0.2,fpos.y);
gl_FragColor = vec4(1.0-color,1.0);
}