diff --git a/fragment.glsl b/fragment.glsl index 8d51e66..fb96349 100644 --- a/fragment.glsl +++ b/fragment.glsl @@ -7,7 +7,7 @@ float rand(vec2 co){ return fract(sin(dot(co, vec2(12.9898, 78.233))) * 43758.5453); } -float cell_size = 0.05; +float cell_size = 0.1; #define PI 3.1415926538 @@ -15,7 +15,7 @@ float cell_size = 0.05; float c_dot(vec2 point, vec2 corner) { float angle = rand(corner) * 2*PI; vec2 random_corner_vec = vec2(cos(angle), sin(angle)); - vec2 offset = point - corner; + vec2 offset = (point - corner) / cell_size; float dot_product = dot(random_corner_vec, offset); // for now just return something return dot_product; @@ -44,16 +44,21 @@ void main() { float c_bl_dot = c_dot(uv, c_bl); float c_br_dot = c_dot(uv, c_br); - // lerp index + // the uv within the tile (0 to 1) vec2 tile_uv = (uv - c_tl) / cell_size; + + // lerp index float u = fade(tile_uv.x); float v = fade(tile_uv.y); + //float u = tile_uv.x; + //float v = tile_uv.y; //float val = smoothstep(tile_uv.x, smoothstep(tile_uv.y, c_bl_dot, c_tl_dot), smoothstep(tile_uv.y, c_br_dot, c_tr_dot)); float val = lerp(lerp(c_tl_dot, c_bl_dot, v), lerp(c_tr_dot, c_br_dot, v), u); //float val = tile_uv.y; //float val = c_bl_dot*2 + 0.5; - val = val * 20; - FragColor = vec4(val, val, val, 1); + //val = val * 20; + float out_val = val /2 + 0.5; + FragColor = vec4(out_val, out_val, out_val, 1); //float yes = 0.5 + (c_dot(uv, c_tl) + c_dot(uv, c_tr) + c_dot(uv, c_bl) + c_dot(uv, c_br)) / 2; //FragColor = vec4(yes, yes, yes, 1);