xxxxxxxxxx
64
precision highp float;
// glslsandbox uniforms
uniform float iTime;
uniform vec2 iResolution;
uniform sampler2D iChannel0;
vec2 ouv;
float rand(vec2 p) {
return fract(sin(dot(p, vec2(12.99, 78.233))) * 43758.545);
}
float noise(vec2 p) {
vec2 f = fract(p);
vec2 u = f * f * (3. - 2. * f);
vec2 i = floor(p);
float a = rand(i);
float b = rand(i + vec2(1, 0));
float c = rand(i + vec2(0, 1));
float d = rand(i + vec2(1, 1));
return mix(a, b, u.x) + (c - a)* u.y * (1. - u.x) +(d - b) * u.x * u.y;
}
float fbm(vec2 p) {
float v = 0.;
float a = 1.;
for(int i = 0; i < 3; ++i) {
p = 2. * p + 5.;
p+= texture2D(iChannel0,ouv).xy;
a *= 0.5;
v += a * noise(p);
}
return v;
}
void mainImage(out vec4 fragColor, in vec2 fragCoord) {
vec2 p = fragCoord.xy / iResolution.xy ;
p.y = 1.-p.y;
ouv = p;
vec2 q = vec2(fbm(p + 0.02 * iTime), fbm(p + 0.05 * iTime));
vec2 r = vec2(fbm(p + 10. * q + vec2(1., 9.2) + 0.15 * iTime),
fbm(p + 12. * q + vec2(5., 2.8) + 0.126 * iTime));
float f = fbm(p + r);
fragColor = vec4(1.6 * pow(f, 2.) + 0.03);
}
void main(void)
{
mainImage(gl_FragColor, gl_FragCoord.xy);
}