Hint_screen_texture with clip children doesnt work

Godot Version

v4.2.1.stable.mono.official [b09f793f5]

Question

I’m using this blur shader for the panel node background:

shader_type canvas_item;

uniform float lod: hint_range(0.0, 10.0) = 1.0;
uniform sampler2D SCREEN_TEXTURE: hint_screen_texture, filter_linear_mipmap;

void fragment() {
	vec3 color = texture(SCREEN_TEXTURE, SCREEN_UV, lod).rgb;
	COLOR = vec4(color, 1.0);
}

For some reason, when I turn on Clip Children (Clip + Draw) in Panel, both Panel and ColorRect with the shader become invisible. I found that they become invisible when using SCREEN_TEXTURE, or rather hint_screen_texture.

Try “Clip Contents” in the Control portion of your Panel instead of Clip Children. Despite the similar names, they don’t behave the same way.

1 Like

It works, but it doesn’t suit me. I need a clipping with rounded corners from the Panel.

The clipping behavior of the panel is implemented as a shader of its own, and uses the back-buffer you need for your blur pass. See the Back-buffer Logic explanation for info.

There are some limited ways to run sequential back buffer operations (i.e. the BackBufferCopy node), but not (as far as I know) cascade them in the way you’d need for this use case.

You can probably achieve this by combining the blur effect and rounded corners into a single shader, but that’s obviously easier said than done and may still not fully solve the problem.

Hopefully someone has a clever workaround.

Having already decided to add rounded corners to my shader, I accidentally discovered that I could apply a shader not to TextureRect, but to an additional Panel and it worked! A fairly simple workaround.

Just create a second Panel and add a rounded corner style to it, and then apply a shader to it.

Nice! How is the overall working structure set up? Nested panels or siblings?

I’ve left them nested so far, but maybe I’ll make them siblings, I haven’t decided yet. You can turn on Clip Children at the blur panel and it will work, the main thing is that there are no nested blurs. I made a special node responsible for blurring and for the panel in my game.

1 Like

(Unfortunately, I can’t attach two images in one message)
Here’s what the result looks like:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.