Godot 4
Hello! I am trying to make a shader that is contained in a circle that I change the raidus of with ease. however I ran with problems in my code and instead of the shader being contained inside the circle it’s just contained in the Rectcolor node instead. meaning it’s being contained outside the circle making the circle that I made useless. how do I fix this? (note: I am trying to make an invert color shader which is supposed to be inside of the circle only, and this would also really help with other shaders)
My code:
shader_type canvas_item;
uniform sampler2D SCREEN_TEXTURE : hint_screen_texture, filter_linear_mipmap;
uniform float size;
uniform vec2 center;
uniform float force;
uniform float thickness;
void vertex() {
// Called for every vertex the material is visible on.
}
void fragment() {
float ratio = SCREEN_PIXEL_SIZE.x / SCREEN_PIXEL_SIZE.y;
vec2 scaledUV = ( UV- vec2(0.5, 0.0) ) / vec2(ratio, 1.0) + vec2(0.5, 0.0);
float mask = 1.0 - step(size, length(scaledUV - center));
vec2 disp = normalize(scaledUV - center) * force;
vec4 inverted_color = texture(SCREEN_TEXTURE, SCREEN_UV - disp);
COLOR = vec4(1.0 - inverted_color.rgb, inverted_color.a);
//COLOR = texture(SCREEN_TEXTURE, SCREEN_UV - disp);
//COLOR.rgb = vec3(mask);
}