Screentone – Black spaced pixels

This shader creates the screentone effect – lots of black dots put close together to create the illusion of being gray that you see in manga. I copied the screentone patterns from Lady Werewolf’s Screentone pack here.

Shader code
shader_type canvas_item;

bool is_white(float average, ivec2 pixel_pos){
	bool pixel_bools[] = {
	bool result = false;
	int max_i = int(average*17.0);
	for (int i = 0; i < max_i; i++){
		result = result||pixel_bools[i];
	return result;

void fragment() {
    vec4 cur_pixel = texture(TEXTURE, UV);
	ivec2 pixel_pos = ivec2(UV / TEXTURE_PIXEL_SIZE);
    float average = (cur_pixel.r + cur_pixel.g + cur_pixel.b) / 3.0;
	if(is_white(average, pixel_pos)){
		COLOR = vec4(1.0, 1.0, 1.0, cur_pixel.a);
	} else {
		COLOR = vec4(0.0, 0.0, 0.0, cur_pixel.a);
manga, screentone
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 Exuin

Square Pixelation

Palette Swap (no recolor / recolor)

Scrolling background

Related shaders

Screentone scene transition

Newest Most Voted
Inline Feedbacks
View all comments
1 year ago

It seems it doesn’t work with GLE2. On the 4th line it says:
Array initialization is supported only on high-end platform!
Can you help with it?