Godot Version
v4.2.2.stable.mono.official [15073afe3]
Question
Hey hey! I’m coming here after several hours of trying to figure something out but failing unfortunately. I’m looking for a way to add blur to a shader I modified, based on a Gradient texture that I give it. What I’m looking for specifically, is if I set the gradient texture to be 50% black and 50% alpha (or black), to have the shader gradually fade out at the half point, no matter how large the Item’s surface is where the shader is applied to.
This is the shader that it needs to work in:
shader_type canvas_item;
uniform sampler2D screen : hint_screen_texture, filter_nearest;
uniform vec2 scale = vec2(1.0, 1.0);
uniform float y_zoom;
uniform vec4 reflection_color: source_color;
uniform sampler2D fadeGradient;
void fragment() {
float uv_height = SCREEN_PIXEL_SIZE.y / TEXTURE_PIXEL_SIZE.y;
vec2 reflected_screenuv = vec2(SCREEN_UV.x, SCREEN_UV.y - uv_height * UV.y * scale.y * y_zoom * 2.0);
vec4 reflection = texture(screen, reflected_screenuv) / 2.0;
COLOR.rgb = mix(reflection.rgb, reflection_color.rgb, reflection.a);
}
I’ve already addded the sampler2D for the Gradient texture, but even after reading up some docs and watching some videos, I can’t really figure out how to apply the texture to the “blur amount”.