I have a control node that I draw a circle on. I want to apply a shader to that custom drawing and so I attach a shader to the Control node. Nothing is happening. Is there a way to fix this?

The shader code is:

shader_type canvas_item;
uniform float outline_width = 2.0;
uniform vec4 outline_color: hint_color;

void fragment(){
    vec4 col = texture(TEXTURE, UV);
    vec2 ps = TEXTURE_PIXEL_SIZE * outline_width;
    float a;
    float maxa = col.a;
    float mina = col.a;


    for(float x = -1.0; x <= 1.0; x+=0.05) {
        float y = 1.0 - (x*x);
        if(vec2(x,y) == vec2(0.0)) {
            continue; // ignore the center of kernel
        }

        a = texture(TEXTURE, UV + vec2(x,y)*ps).a;
        maxa = max(a, maxa); 
        mina = min(a, mina);
    }

    for(float x = -1.0; x <= 1.0; x+=0.05) {
        float y = -1.0 + (x*x);
        if(vec2(x,y) == vec2(0.0)) {
            continue; // ignore the center of kernel
        }

        a = texture(TEXTURE, UV + vec2(x,y)*ps).a;
        maxa = max(a, maxa); 
        mina = min(a, mina);
    }


    // Fill transparent pixels only, don't overlap texture
    if(col.a < 0.5) {
        COLOR = mix(col, outline_color, maxa-mina);
    } else {
        COLOR = col;
    }
}

I think you need to assign this to a node that has a texture that can be assigned to it, as otherwise TEXTURE will be blank. A Control node doesn't have any texture, but you could use a TextureRect and then it may work, since a texture can be assigned to it.

I just tried that with a TextureRect node with no luck. I can draw a circle, but doesn't apply the shader to the circle

How are you drawing the circle? Is it through the _draw function?

Also, you may want to look at this issue on GitHub. I'm not sure if it's related though, but if you are using _draw then it may be helpful.

Ok, I am trying it with a rectangle now and still get no shader effect.

a year later