First commit

master
powertomato 7 years ago
commit 0e23850ebc
  1. 27
      2D/BoxTiling.glsl
  2. 49
      2D/HexTiling.glsl
  3. 43
      2D/Noise.glsl
  4. BIN
      2D/water/sand.jpg
  5. BIN
      2D/water/sand2.jpg
  6. 52
      2D/water/water.glsl

@ -0,0 +1,27 @@
#iChannel0 "https://i.imgur.com/TnmUwCn.jpg"
float XNUM = 10.;
float YNUM = 10.;
vec4 BoxCoords(vec2 uv) {
vec2 gv = fract(uv);
vec2 id = floor(uv);
//standard uv
return vec4(gv.x, gv.y, id.x, id.y);
}
void mainImage ( out vec4 fragColor, in vec2 fragCoord) {
vec2 uv = (fragCoord-0.5*iResolution.xy)/iResolution.y;
vec3 col = vec3(0.0);
uv.x *= 10.0;
uv.y *= 5.0;
vec4 coord = BoxCoords(uv);
col.rgb = texture(iChannel0, coord.xy).rgb;
col.rgb *= vec3(smoothstep(0.09, 0.99, sin(coord.z+coord.w/17.+iTime) ));
fragColor = vec4(col, 1.0);
}

@ -0,0 +1,49 @@
#iChannel0 "https://i.imgur.com/TnmUwCn.jpg"
float SQRT3 = 1.73205080757;
float HexDist(vec2 p) {
p = abs(p);
float c = dot(p, normalize(vec2(1,SQRT3)));
c = max(c, p.x);
return c;
}
vec4 HexCoords(vec2 uv) {
vec2 r = vec2(1, SQRT3);
vec2 h = r/2.0;
vec2 a = mod(uv, r)-h;
vec2 b = mod(uv-h, r)-h;
vec2 gv = length(a) < length(b) ? a : b;
vec2 id = uv-gv;
//standard uv
return vec4(gv.x, gv.y, id.x, id.y);
// polar coord uv
// float x = atan(gv.y, gv.x);
// float y = HexDist(gv);
// return vec4(x, y, id.x, id.y);
// polar coord 2 uv
// float x = atan(gv.y, gv.x);
// float y = 0.5-HexDist(gv);
// return vec4(x, y, id.x, id.y);
}
void mainImage ( out vec4 fragColor, in vec2 fragCoord) {
vec2 uv = (fragCoord-0.5*iResolution.xy)/iResolution.y;
vec3 col = vec3(0.0);
uv *= 10.0;
vec4 hc = HexCoords(uv);
//col.rg = hc(uv).xy;
col.rgb = texture(iChannel0, hc(uv).xy+0.5).rgb;
col.rgb *= vec3(smoothstep(0.09, 0.99, sin(hc.z+hc.w/17.+iTime) ));
fragColor = vec4(col, 1.0);
}

@ -0,0 +1,43 @@
float N21(vec2 p) {
//return fract( sin(p.x*100.0+p.y*6574.0)*5647.0 );
p = fract(p*vec2(233.32, 851.73));
p += dot(p, p+23.45);
return fract(p.x*p.y);
}
float SmoothNoise(vec2 uv) {
vec2 lv = fract(uv);
vec2 id = floor(uv);
lv = smoothstep(0.0,1.0, lv); // = lv*lv*(3.-2.*lv);
float bl = N21(id);
float br = N21(id+vec2(1.0, 0.0));
float b = mix(bl, br, lv.x);
float tl = N21(id+vec2(0.0,1.0));
float tr = N21(id+vec2(1.0,1.0));
float t = mix(tl, tr, lv.x);
return mix(b,t, lv.y);
}
float SmoothNoise2(vec2 uv, int ocataves) {
float c = 0.0;
float norm = 0.0;
float limit = pow(2.0, float(ocataves));
for(float i=1.0; i<=limit; i*=2.0){
float norm_fract = 1.0/i;
c += SmoothNoise(uv*i)*norm_fract;
norm+= norm_fract;
}
return c/norm;
}
void mainImage ( out vec4 fragColor, in vec2 fragCoord) {
vec2 uv = fragCoord/iResolution.xy;
fragColor = vec4( vec3(SmoothNoise2(uv*4.+iTime*2.,3)), 1.0 );
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 88 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 196 KiB

@ -0,0 +1,52 @@
#iChannel0::WrapMode "Repeat"
#iChannel0 "file://./sand2.jpg"
float N21(vec2 p) {
//return fract( sin(p.x*100.0+p.y*6574.0)*5647.0 );
p = fract(p*vec2(233.32, 851.73));
p += dot(p, p+23.45);
return fract(p.x*p.y);
}
float SmoothNoise(vec2 uv) {
vec2 lv = fract(uv);
vec2 id = floor(uv);
lv = smoothstep(0.0,1.0, lv); // = lv*lv*(3.-2.*lv);
float bl = N21(id);
float br = N21(id+vec2(1.0, 0.0));
float b = mix(bl, br, lv.x);
float tl = N21(id+vec2(0.0,1.0));
float tr = N21(id+vec2(1.0,1.0));
float t = mix(tl, tr, lv.x);
return mix(b,t, lv.y);
}
float SmoothNoise2(vec2 uv, int ocataves) {
float c = 0.0;
float norm = 0.0;
float limit = pow(2.0, float(ocataves));
for(float i=1.0; i<=limit; i*=2.0){
float norm_fract = 1.0/i;
c += SmoothNoise(uv*i)*norm_fract;
norm+= norm_fract;
}
return c/norm;
}
void mainImage ( out vec4 fragColor, in vec2 fragCoord) {
vec2 uv = (fragCoord-0.5*iResolution.xy)/iResolution.y;
uv = uv*4.;
float tmp;
float b = SmoothNoise2(uv+iTime*0.5,2)*0.5+SmoothNoise2(uv-iTime*0.2,2)*0.5;
tmp = smoothstep(0.5, 0.505, b);
b = tmp - smoothstep(0.505, 0.51, b);
fragColor = vec4( texture(iChannel0, uv+ SmoothNoise2(uv+iTime*0.5,2)*0.4 ).xyz+b, 1.0 );
}
Loading…
Cancel
Save