nice wavey pattern
This commit is contained in:
parent
d5829527c1
commit
1e0c44cc3d
1 changed files with 22 additions and 11 deletions
|
|
@ -29,14 +29,15 @@ float rand(vec2 v, vec2 offset) {
|
||||||
return float(hash) * (1.0/float(0xffffffffu));
|
return float(hash) * (1.0/float(0xffffffffu));
|
||||||
}
|
}
|
||||||
|
|
||||||
float cell_size = 0.01;
|
float cell_size = 0.04;
|
||||||
#define PI 3.1415926538
|
#define PI 3.1415926538
|
||||||
|
|
||||||
// whatever that corner contributes
|
// whatever that corner contributes
|
||||||
float c_dot(vec2 point, vec2 corner) {
|
// vector_offset and angle_offset are optional variation variables
|
||||||
|
float c_dot(vec2 point, vec2 corner, vec2 vector_offset, float angle_offset) {
|
||||||
vec2 c = vec2(ivec2(round(corner * 100.0)));
|
vec2 c = vec2(ivec2(round(corner * 100.0)));
|
||||||
float angle = rand(c, vec2(0.0, 0.0)) * 2.0*PI;
|
float angle = rand(c, vec2(0.0, 0.0)) * 2.0*PI + angle_offset;
|
||||||
vec2 random_corner_vec = vec2(cos(angle), sin(angle));
|
vec2 random_corner_vec = vec2(cos(angle), sin(angle)) + vector_offset;
|
||||||
vec2 offset = (point - corner) / cell_size;
|
vec2 offset = (point - corner) / cell_size;
|
||||||
float dot_product = dot(random_corner_vec, offset);
|
float dot_product = dot(random_corner_vec, offset);
|
||||||
// for now just return something
|
// for now just return something
|
||||||
|
|
@ -48,17 +49,17 @@ float fade(float t) {
|
||||||
return ((6.0*t - 15.0)*t + 10.0)*t*t*t;
|
return ((6.0*t - 15.0)*t + 10.0)*t*t*t;
|
||||||
}
|
}
|
||||||
|
|
||||||
float perlin_noise(vec2 uv) {
|
float perlin_noise(vec2 uv, vec2 vector_offset, float angle_offset) {
|
||||||
vec2 grid_edge_offset = mod(uv, cell_size);
|
vec2 grid_edge_offset = mod(uv, cell_size);
|
||||||
// c: corner
|
// c: corner
|
||||||
vec2 c_tl = uv - grid_edge_offset;
|
vec2 c_tl = uv - grid_edge_offset;
|
||||||
vec2 c_tr = uv - grid_edge_offset + vec2(cell_size, 0);
|
vec2 c_tr = uv - grid_edge_offset + vec2(cell_size, 0);
|
||||||
vec2 c_bl = uv - grid_edge_offset + vec2(0, cell_size);
|
vec2 c_bl = uv - grid_edge_offset + vec2(0, cell_size);
|
||||||
vec2 c_br = uv - grid_edge_offset + vec2(cell_size, cell_size);
|
vec2 c_br = uv - grid_edge_offset + vec2(cell_size, cell_size);
|
||||||
float c_tl_dot = c_dot(uv, c_tl);
|
float c_tl_dot = c_dot(uv, c_tl, vector_offset, angle_offset);
|
||||||
float c_tr_dot = c_dot(uv, c_tr);
|
float c_tr_dot = c_dot(uv, c_tr, vector_offset, angle_offset);
|
||||||
float c_bl_dot = c_dot(uv, c_bl);
|
float c_bl_dot = c_dot(uv, c_bl, vector_offset, angle_offset);
|
||||||
float c_br_dot = c_dot(uv, c_br);
|
float c_br_dot = c_dot(uv, c_br, vector_offset, angle_offset);
|
||||||
|
|
||||||
// the uv within the tile (0 to 1)
|
// the uv within the tile (0 to 1)
|
||||||
vec2 tile_uv = (uv - c_tl) / cell_size;
|
vec2 tile_uv = (uv - c_tl) / cell_size;
|
||||||
|
|
@ -76,6 +77,16 @@ void main() {
|
||||||
// We'll make origin in the top-left.
|
// We'll make origin in the top-left.
|
||||||
uv.y = 1.0 - uv.y;
|
uv.y = 1.0 - uv.y;
|
||||||
uv.x *= WindowSize.x / WindowSize.y;
|
uv.x *= WindowSize.x / WindowSize.y;
|
||||||
float out_val = perlin_noise(uv);
|
uv.y += sin(uv.x * 2.0 + time * 0.2) * 0.47;
|
||||||
color = vec4(out_val, out_val, out_val, 1.0);
|
uv.y += sin(uv.x * 4.3 + time * 1.34) * 0.09;
|
||||||
|
uv += 100.0;
|
||||||
|
//uv.x += time / 20.0;
|
||||||
|
float out_val = perlin_noise(uv, vec2(0.0, 0.0), time / 1.0);
|
||||||
|
float min = 0.42;
|
||||||
|
float max = 0.58;
|
||||||
|
out_val = out_val + sin(uv.y + time) / 15.2;
|
||||||
|
out_val = clamp(out_val, min, max);
|
||||||
|
out_val -= min;
|
||||||
|
out_val *= (1.0 - (max - min)) / (max - min);
|
||||||
|
color = vec4(out_val, 0.4, 0.8, 1.0);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue