Hello,
I've got this really weird behavior with shaders. There is the following setup

  • ParallaxBackground
  • - ParallaxLayer_1
  • - - TextureRect_1 (solid image)
  • - ParallaxLayer_2
  • - - TextureRect_2 (image with transparency)

Now at some point the two parallax layers are going to become visible and start scrolling. This is to create the illusion of fast motion.
To add to the illusion, I wanted to blur TextureRext_2. So I applied a shader to it inside a material, as is stated in the documentation.
The code of the shader can be found here:
https://pastebin.com/YjQ5Qxv8

Now here's what happens.
1) TextureRect_2 completely disappears. It is no longer visible as soon as the shader is applied to it.
2) TextureRect_1 becomes blurry.
3) If I apply the shader to TextureRect_1 it also disappears.
So how does this work? Do I need to create a separate texture rect for just the shader and it will affect everything before it?
I created a TextureRect_3, added the shader to it and placed it below TextureRect_2, in the same ParallaxLayer and a separate one, but that didn't do anything.
I thought a shader applies to its parent object. Did I misunderstand? If so, why did placing the TextureRect_3 not work?
Is something wrong with the shader code?
What is going on?

Syl20 Okay, so changing SCREEN_UV to UV doesn't do anything. Changing SCREEN_TEXTURE to TEXTURE makes the layer visible and the shader is now applied to the correct object. However, anything that is supposed to be transparent is now white.

    Irolan Hmmmm.... when I tried that shader in a pong demo with a colorrect, i noticed the thing goes completely black when the "samples" in the shader param is at 1. Did you check the params?

    Honestly, this shader isn't terribly great for motion blur. I am betting you could find a better one.

    @Syl20 Okay, thank you. Thanks to the shader you posted it became obvious that there's an issue in the code. Yours works fine. I have no idea what is going on as I don't really know anything about shader coding. However, I was at least able to combine the two into one that works. Code is here:

    @SnapCracklins Truth is I couldn't tell a good shader from a bad one. Don't know enough about themn. If you know a better one that does directional blur/motion blur, please tell me.

      Irolan sadly you kind of have to just play around with them. GodotShaders.com has many good one though.

        SnapCracklins Thanks for the tip. I'll check if I can find one that fits. If not... it looks okay so far and I'm not gonna mess about with shaders at this time. I don't think I'll need any more shaders for the game. 🙂