I want to draw a line across a sprite that is consistently 1 screen pixel wide, here is a simplified version of the shader code (just use this on a sprite):
shader_type canvas_item;
render_mode blend_mix ;
void fragment() {
float topedge = (0.5); // top edge of line
float bottomedge = topedge + SCREEN_PIXEL_SIZE.y; // bottom edge of line
if ((UV.y >= topedge) && (UV.y < bottomedge)) {COLOR = vec4(1.,0.,0.,1.);}
else {COLOR = texture(TEXTURE, UV);} // default colour
}
The code just detects if the UV y coord is between the centre of the sprite or the centre of the sprite + 1 screen pixel and changes the colour to red if it is. Scaling the sprite makes the line appear and disappear. Oddly I also noticed that, when the project is run, changing the window size also makes it appear and disappear. Any ideas what I am doing wrong here?