I found an outline shader that works but I have to manually attach it to every node or use a viewport to draw it over a set of nodes, However this messes up my mouse position and is a chore to deal with in general. How can I convert this shader to instead work on a ColorRect that covers the whole screen?
Note that my background only has 1 colour and can easily be selected as the colour to be transparent.
shader_type canvas_item;
uniform vec4 line_color : hint_color = vec4(1);
uniform float line_thickness : hint_range(0, 10) = 1.0;
void fragment() {
vec2 size = TEXTURE_PIXEL_SIZE * line_thickness;
float outline = texture(TEXTURE, UV + vec2(-size.x, 0)).a;
outline += texture(TEXTURE, UV + vec2(0, size.y)).a;
outline += texture(TEXTURE, UV + vec2(size.x, 0)).a;
outline += texture(TEXTURE, UV + vec2(0, -size.y)).a;
outline += texture(TEXTURE, UV + vec2(-size.x, size.y)).a;
outline += texture(TEXTURE, UV + vec2(-size.x, size.y * 0.5)).a;
outline += texture(TEXTURE, UV + vec2(size.x, size.y)).a;
outline += texture(TEXTURE, UV + vec2(size.x, size.y * 0.5)).a;
outline += texture(TEXTURE, UV + vec2(-size.x, -size.y)).a;
outline += texture(TEXTURE, UV + vec2(-size.x, -size.y * 0.5)).a;
outline += texture(TEXTURE, UV + vec2(size.x, -size.y)).a;
outline += texture(TEXTURE, UV + vec2(size.x, -size.y * 0.5)).a;
outline = min(outline, 1.0);
vec4 color = texture(TEXTURE, UV);
COLOR = mix(color, line_color, outline - color.a);
}
I want to shader to draw an outline over everything that is being rendered including particles and text