Random, tiles
This commit is contained in:
parent
608e44b82a
commit
85657e00a2
@ -9,6 +9,11 @@ uniform float u_canvasHeight;
|
|||||||
|
|
||||||
out vec4 fragColor;
|
out vec4 fragColor;
|
||||||
|
|
||||||
|
// See https://thebookofshaders.com/10/
|
||||||
|
float random (vec2 st) {
|
||||||
|
return fract(sin(dot(st.xy, vec2(12.9898,78.233)))* 43758.5453123);
|
||||||
|
}
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
vec2 uv = gl_FragCoord.xy/vec2(u_canvasWidth, u_canvasHeight);
|
vec2 uv = gl_FragCoord.xy/vec2(u_canvasWidth, u_canvasHeight);
|
||||||
|
|
||||||
@ -16,12 +21,19 @@ void main() {
|
|||||||
vec3 green = vec3(0.0, 1.0, 0.0);
|
vec3 green = vec3(0.0, 1.0, 0.0);
|
||||||
vec3 blue = vec3(0.0, 0.0, 1.0);
|
vec3 blue = vec3(0.0, 0.0, 1.0);
|
||||||
|
|
||||||
if (uv.x < 0.33) {
|
float size = 0.05;
|
||||||
fragColor = vec4(red, 1.0);
|
|
||||||
} else if (uv.x < 0.66) {
|
uv.x = floor(uv.x / size) * size;
|
||||||
fragColor = vec4(green, 1.0);
|
uv.y = floor(uv.y / size) * size;
|
||||||
} else {
|
|
||||||
fragColor = vec4(blue, 1.0);
|
float rand = random(uv);
|
||||||
}
|
|
||||||
|
float period = 5.0;
|
||||||
|
float mask = mod(u_time / period, 1.0);
|
||||||
|
|
||||||
|
float x = rand < mask ? uv.x : 0.0;
|
||||||
|
float y = rand < mask ? uv.y : 0.0;
|
||||||
|
|
||||||
|
fragColor = vec4(x, 0.0, y, 1.0);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user