This commit is contained in:
Rakarake 2025-12-10 19:07:35 +01:00
parent 1a190594fe
commit 90d565ff8d
3 changed files with 67 additions and 11 deletions

View file

@ -1,6 +1,5 @@
#version 330 core
out vec4 FragColor;
in vec2 uv;
uniform vec2 WindowSize;
uniform float time;
@ -8,7 +7,28 @@ float rand(vec2 co){
return fract(sin(dot(co, vec2(12.9898, 78.233))) * 43758.5453);
}
float cell_size = 0.1;
void main() {
float glob = rand(gl_FragCoord.xy / WindowSize + time);
FragColor = vec4(glob * (sin(time)/2 + 0.5), glob, 1.0, 1.0); //vec4(gl_FragCoord.xy / WindowSize, 0.0, 1.0);
// We'll make origin in the top-left.
vec2 uv = gl_FragCoord.xy / WindowSize;
uv.y = 1.0 - uv.y;
vec2 grid_edge_offset = mod(uv, cell_size);
// c: corner
vec2 c_tl = uv - grid_edge_offset;
vec2 c_tr = uv - grid_edge_offset + vec2(cell_size, 0);
vec2 c_bl = uv - grid_edge_offset + vec2(0, cell_size);
vec2 c_br = uv - grid_edge_offset + vec2(cell_size, cell_size);
// random vectors
vec2 c_tl_ran = rand(c_tl);
vec2 c_tr_ran = rand(c_tr);
vec2 c_bl_ran = rand(c_bl);
vec2 c_br_ran = rand(c_br);
// offset vectors
vec2 c_tl_off = c_tl - uv;
vec2 c_tr_off = c_tr - uv;
vec2 c_bl_off = c_bl - uv;
vec2 c_br_off = c_br - uv;
FragColor =
}