framebuffer formalitites
[carveJwlIkooP6JGAAIwe30JlM.git] / shaders / noise.glsl
1 uniform sampler2D uTexNoise;
2
3 float noise( vec3 x )
4 {
5 vec3 i = floor(x);
6 vec3 f = fract(x);
7 f = f*f*(3.0-2.0*f);
8 vec2 uv = (i.xy+vec2(37.0,17.0)*i.z) + f.xy;
9 vec2 rg = texture( uTexNoise, (uv+0.5)/256.0).yx;
10 return mix( rg.x, rg.y, f.z );
11 }
12
13 const mat3 m = mat3( 0.00, 0.80, 0.60,
14 -0.80, 0.36, -0.48,
15 -0.60, -0.48, 0.64 );
16
17 float fractalNoise( vec3 x )
18 {
19 vec3 q = 8.0*x;
20 float f;
21 f = 0.5000*noise( q ); q = m*q*2.01;
22 f += 0.2500*noise( q ); q = m*q*2.02;
23 f += 0.1250*noise( q ); q = m*q*2.03;
24 f += 0.0625*noise( q ); q = m*q*2.01;
25 return f;
26 }