That problem confuse me for a long time.
If I want to draw a rectangle with a hole manually like this:
Grey grid is the transparent area
Here's the node code
extends Node2D
func _draw():
draw_rect(Rect2(50, 200, 150, 150), Color(1, 0, 0, 0))
draw_circle(Vector2(200, 200), 100, Color(1, 0, 0, 0.9))
and the shader code:
shader_type canvas_item;
void fragment() {
COLOR.a = 1.0 - COLOR.a;
}
Without shader:

With Shader

I think enable the shader, the result should be like this:

The problem is draw() function is not draw all the things on a cache, then apply the shader, then draw it on the screen, it apply the shader after every time you call function like drawcircle(), draw_rect(), etc. So I cant draw some mask effects like the first image shows. And I try light2D, because light2D only support texture, so I cant use custom draw either.
Thanks for any advice :D