Subpixelizer

Splits each pixel into its red, green, and blue channels. Since it does it per screen pixel and not per generated pixel, it’s not actually using the same color data for each screen pixel within each generated pixel (look at the second attached image at the bottom edge of the cube to see what I mean). This isn’t noticable if you keep the generated pixel size small, but becomes apparent if it’s set unreasonably large.

Shader code
shader_type canvas_item;

uniform float PIXEL_SIZE = 3.;

void fragment() {

	vec2 screen_size = 1. / SCREEN_PIXEL_SIZE;

	int x = int(UV.x * screen_size.x / PIXEL_SIZE);
	int y = int(UV.y * screen_size.y / PIXEL_SIZE);

	if (x % 3 == 0 || y % 3 == 0) {

		COLOR = vec4(0, 0, 0, 1);

	} else if (x % 3 == 1) {

		if (y % 3 == 1) {
			COLOR = vec4(COLOR.r, 0, 0, 1);
		} else {
			COLOR = vec4(0, COLOR.g, 0, 1);
		}

	} else {

		if (y % 3 == 1) {
			COLOR = vec4(0, 0, COLOR.b, 1);
		} else {
			COLOR = vec4(0, 0, 0, 1);
		}
	}
}
Live Preview
Tags
CRT, pixel, screen, ScreenSpace
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 dairycultist

guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments