easy checkerboard

this is the most simplest checkerboard shader (i made it that you can modify the modulos for custom results)

Shader code
shader_type canvas_item;

uniform int bands = 20;
uniform int black_spacing = 1;
uniform int white_spacing = 1;

uniform vec4 color1 : source_color = vec4(0.0, 0.0, 0.0, 1.0);
uniform vec4 color2 : source_color = vec4(1.0);

void fragment() {
	float x = floor(UV.x * float(bands));
	float y = floor(UV.y * float(bands));

	float total = float(black_spacing + white_spacing);

	float cell_x = mod(x, total);
	float cell_y = mod(y, total);

	bool black = (cell_x < float(black_spacing)) == (cell_y < float(black_spacing));

	COLOR = black ? color1 : color2;
}
Live Preview
Tags
Data/Generation
The shader code and all code snippets in this post are under CC0 license and can be used freely without the author's permission. Images and videos, and assets depicted in those, do not fall under this license. For more info, see our License terms.

More from stryck33

Related shaders

Comments 0

No comments yet.