Multiple (blur) shader issue

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By bruteforce


My simiplified node tree is:

poly_1 (Polygon2D)
- blur_1 (Polygon2D)
poly_2 (Polygon2D)
- blur_2 (Polygon2D)

blur_1 and blur_2 (sub)nodes have ShaderMaterials (unique), with this simple shader code:

shader_type canvas_item;

void fragment() {

The first blur works properly, but the second is fully transparent… :frowning:

enter image description here

Sample project: google drive

(Godot v3.3 stable official, GLES3, Win10 64bit)

I don’t know what I’m doing wrong.
Can you help me?

Thank you!

Does the second shader have the same problem when it is used alone? Or does it depend on the number of shaders?

Bubu | 2021-05-05 15:46

The second shader works alone :slight_smile:

And it works immediately, when I hide the first one (no other changes):
enter image description here

I really don’t understand, what’s going on here…

bruteforce | 2021-05-05 15:53

Me either. I should probably check whole shader to see what’s going on.

Bubu | 2021-05-05 15:58

Whole shader? What do you mean?
This shader code has only 5 lines…

A changed it to:

COLOR = vec4(1,0,0,1);

And it works… interesting.
enter image description here

bruteforce | 2021-05-05 16:09

I thought it was one of the complex blur shaders where interpolation is causing the problem. But if this is the shader, then this could be a bug.

Bubu | 2021-05-05 16:15

I think the SCREEN_TEXTURE is where the problem appears, maybe screen reading cannot be used more than once so the second shader just fails and returns nothing.

Bubu | 2021-05-05 16:18

You are probably right.

I modified the code (without SCREEN_*):

COLOR = textureLod(TEXTURE, UV, 3);

… and the problem was somehow solved :slight_smile:

Please write this again as an answer (not comment) , and I can select it as “best asnwer”!

Thank you!

bruteforce | 2021-05-05 19:43

:bust_in_silhouette: Reply From: Bubu

The SCREEN_TEXTURE is causing the problem, screen reading shaders cannot be used more than once so the second shader just fails and returns nothing.

:bust_in_silhouette: Reply From: Inces

There is a node called BackBufferCopy, it should be set inbetween screen shaders in scene tree, and it should provide both of them with correct SCREEN_TEXURE. Did You try it ?