• Godot Help
  • Need help converting basic Shader to Godot 4

Hey Friends!

I'm currently trying to convert this really basic blur shader to Godot 4.
I've been scratching my head on why it's wrong, but I'm also pretty terrible at shaders.

If anyone has any thoughts, it would be much apricated!

shader_type canvas_item;

uniform float blur_amount : hint_range(0, 5);

void fragment() {
	COLOR = textureLod(SCREEN_TEXTURE, SCREEN_UV, blur_amount);
}
  • Gowydot replied to this.
  • Look in the error console, it should tell you how to fix it.

    Look in the error console, it should tell you how to fix it.

      shader_type canvas_item;
      
      uniform float blur_amount : hint_range(0, 5);
      uniform sampler2D SCREEN_TEXTURE : hint_screen_texture, filter_linear_mipmap;
      
      void fragment() {
      	COLOR = textureLod(SCREEN_TEXTURE, SCREEN_UV, blur_amount);
      }

      Basically SCREEN_TEXTURE doesn't exist in Godot 4.0, so you have make a workaround for it.

      cybereality

      Thanks for the recommendation. I must of had an error somewhere else at first because the error console didn't tell me anything right away.
      But I just did it and here was the solution, just in-case anyone wants to know!

      Thanks everyone!

      shader_type canvas_item;
      
      uniform sampler2D SCREEN_TEXTURE : hint_screen_texture, filter_linear_mipmap;
      uniform float blur_amount = 2;
      
      void fragment() {
      	COLOR = textureLod(SCREEN_TEXTURE, SCREEN_UV, blur_amount);
      }
        8 months later
        10 months later