Ratamacue9112 Make a ColorRect
node and assign this shader to it:
shader_type canvas_item;
uniform vec2 holeCenter;
uniform float holeRadius;
varying vec2 p;
void vertex(){
p = (MODEL_MATRIX * vec4(VERTEX, 0.0, 1.0) ).xy;
}
void fragment(){
COLOR.a = step(holeRadius, length(p - holeCenter));
}
Set center/radius uniform values from script as needed by calling set_shader_parameter()
on ColorRect
's material
For fun, here's also a soft edge version. Change the penumbra
parameter to adjust the soft zone:
shader_type canvas_item;
uniform vec2 holeCenter;
uniform float holeRadius;
uniform float penumbra = 20.0;
varying vec2 p;
void vertex(){
p = (MODEL_MATRIX * vec4(VERTEX, 0.0, 1.0) ).xy;
}
void fragment(){
COLOR.a = smoothstep(holeRadius - penumbra/2.0, holeRadius + penumbra/2.0, length(p - holeCenter));
}