I've been working on a shader that should make a viewport display whatever is in it like those old LCD grid screens. The real low pixel ones. It almost works. I can cut it in lines going in one direction fine, but not a full grid cut.
shader_type canvas_item;
uniform float y_float;
uniform float size = 200.0;
void fragment() {
vec2 ratio = vec2(1.0, TEXTURE_PIXEL_SIZE.x / TEXTURE_PIXEL_SIZE.y);
vec2 pixelated_uv = floor(UV * ratio * size) / (size * ratio);
vec2 pixels = (fract(UV * size * ratio) - vec2(.5)) * 4.5;
pixels = (1.0 - dots) * 10.0;
pixels = clamp(dots, 0.0, 1.0);
pixels = floor(dots);
vec4 matrix1 = mix(texture(SCREEN_TEXTURE, SCREEN_UV), texture(TEXTURE, pixelated_uv), pixels.x);
vec4 matrix2 = mix(texture(SCREEN_TEXTURE, SCREEN_UV), texture(TEXTURE, pixelated_uv), pixels.y);
vec3 ledMatrix = mix(matrix1.rgb, matrix2.rgb, 0.5);
COLOR.rgb = ledMatrix;
COLOR.a = texture(TEXTURE, pixelated_uv).a;
}
As you can see, I'm using mix for now to combine the horizontal and vertical lines, but it's, well, mixing. I don't want to interpolate between the two.
To the right is what's supposed to be displayed, the left is what I'm getting due to mix and not knowing what a lot of the words in the shader docs mean.