Skip to content

Instantly share code, notes, and snippets.

@koji
Created July 15, 2019 16:54
Show Gist options
  • Save koji/215d3118a0b4a54b2135a644ef1af666 to your computer and use it in GitHub Desktop.
Save koji/215d3118a0b4a54b2135a644ef1af666 to your computer and use it in GitHub Desktop.
texture
#ifdef GL_ES
precision mediump float;
#endif
uniform float u_time;
uniform vec2 u_resolution;
uniform sampler2D u_tex0;
const mat2 m=mat2(.80,.60,-.60,.80);
float hash(float n)
{
return fract(sin(n)*43758.5453);
}
float noise(in vec2 x)
{
vec2 p=floor(x);
vec2 f=fract(x);
f=f*f*(3.-2.*f);
float n=p.x+p.y*57.;
return mix(mix(hash(n+0.),hash(n+1.),f.x),
mix(hash(n+57.),hash(n+58.),f.x),f.y);
}
float fbm(vec2 p){
float f=0.;
f+=.5*noise(p);p*=m*2.02;
f+=.25*noise(p);p*=m*2.03;
f+=.125*noise(p);p*=m*2.01;
f+=.0625*noise(p);p*=m*2.04;
f/=.9375;
return f;
}
float N21(vec2 p){
p=fract(p*vec2(233.34,851.73));
p+=dot(p,p+23.45);
return fract(p.x*p.y);
}
vec2 N22(vec2 p){
float n=N21(p);
return vec2(n,N21(p+n));
}
vec2 GetPos(vec2 id,vec2 offset){
vec2 n=N22(id+offset)*u_time;
return offset+sin(n)*.1;
}
void main(){
vec2 uv=gl_FragCoord.xy/u_resolution.xy;
vec3 col=vec3(0.);
vec2 p = GetPos(uv, vec2(.45));
uv = uv * vec2(cos(p.x - p.y), sin(p.x - p.y + u_time));
gl_FragColor = texture2D(u_tex0, uv);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment