I have a CPUParticle2D node that I want to make invisible within a certain area. I tried using a Light2D node set to mask, but there is no way to change the shape of the texture without setting a completely new texture. I need to be able to make small changes to the shape of the invisible area through code.
I also tried using a shader, but I was confused because UV was affecting each particle individually instead of the entire Particles node. Im pretty shaky on shaders so I'd love a non-shader solution, but I have a feeling a shader is the only way to achieve this effect. below is what I have attempted so far:
shader_type canvas_item;
uniform vec2 topRight = vec2(0,100);
uniform vec2 topLeft = vec2(0,0);
uniform vec2 bottomRight = vec2(100,100);
uniform vec2 bottomLeft = vec2(0,100);
void fragment() {
if (this pixel is inside uniform points){
// everything below is intended to make the pixel invisible. I found this online though and I dont fully understand it
vec2 backgroundUV = FRAGCOORD.xy * SCREEN_PIXEL_SIZE.xy;
vec4 backColR = texture(SCREEN_TEXTURE, SCREEN_UV);
vec4 backColG = texture(SCREEN_TEXTURE, SCREEN_UV);
vec4 backColB = texture(SCREEN_TEXTURE, SCREEN_UV);
vec4 texCol = texture(TEXTURE, UV);
COLOR = mix(texCol, texCol.a * vec4(backColR.r, backColG.g, backColB.b, 1.0), 1.);
}
}