31 lines
No EOL
975 B
Text
31 lines
No EOL
975 B
Text
shader_type canvas_item;
|
|
render_mode skip_vertex_transform;
|
|
|
|
uniform vec4 color_1 : hint_color = vec4(1.0, 1.0, 1.0, 1.0);
|
|
uniform vec4 color_2 : hint_color = vec4(0.0, 0.0, 0.0, 1.0);
|
|
uniform vec2 checker_size = vec2(8.0, 8.0);
|
|
uniform vec2 pan_speed = vec2(0.0, 0.0);
|
|
uniform vec2 cycle_speed = vec2(0.0, 0.0);
|
|
uniform vec2 cycle_alternation = vec2(0.0, 0.0);
|
|
uniform mat2 uv_transform = mat2(1.0);
|
|
|
|
float checker(vec2 uv) {
|
|
vec2 div_uv = floor((uv) / checker_size);
|
|
float fmodResult = mod(div_uv.x + div_uv.y, 2.0);
|
|
return max(sign(fmodResult), 0.0);
|
|
}
|
|
|
|
void vertex() {
|
|
UV = VERTEX;
|
|
VERTEX = (WORLD_MATRIX * (EXTRA_MATRIX * vec4(VERTEX, 0.0, 1.0))).xy;
|
|
}
|
|
|
|
void fragment() {
|
|
vec2 uv = uv_transform * (UV - pan_speed * TIME);
|
|
vec2 alternation = mix(vec2(1.0), vec2(
|
|
(checker(vec2(uv.y, 0.0)) - 0.5) * 2.0,
|
|
(checker(vec2(0.0, uv.x)) - 0.5) * 2.0
|
|
), cycle_alternation);
|
|
uv = uv - cycle_speed * alternation * TIME;
|
|
COLOR = mix(color_1, color_2, checker(uv));
|
|
} |