shader_type spatial; render_mode blend_add, depth_draw_never, cull_disabled, unshaded; uniform sampler2D depth_texture : hint_depth_texture, filter_nearest; uniform sampler2D noise_texture : repeat_enable, filter_linear; uniform vec3 ray_color : source_color = vec3(1.0, 0.9, 0.7); uniform float base_alpha : hint_range(0.0, 1.0) = 0.5; group_uniforms Noise_Stretching; uniform float noise_stretching : hint_range(1.0, 50.0) = 20.0; uniform float noise_scale : hint_range(0.1, 10.0) = 1.0; uniform vec2 scrolling_speed = vec2(0.0, -0.1); group_uniforms Fades; uniform float depth_softness = 1.0; uniform float edge_fade_power = 2.0; uniform float intensity_multiplier : hint_range(0.0, 1.0) = 0.0; void fragment() { vec2 stretchy_uv = UV * noise_scale; stretchy_uv.x *= noise_stretching; stretchy_uv += TIME * scrolling_speed; float noise = texture(noise_texture, stretchy_uv).r; float depth = textureLod(depth_texture, SCREEN_UV, 0.0).r; vec4 upos = INV_PROJECTION_MATRIX * vec4(SCREEN_UV * 2.0 - 1.0, depth, 1.0); vec3 pixel_position = upos.xyz / upos.w; float depth_fade = clamp((VERTEX.z - pixel_position.z) / depth_softness, 0.0, 1.0); float edge_fade = smoothstep(0.0, 0.5, UV.x) * smoothstep(1.0, 0.5, UV.x); edge_fade = pow(edge_fade, edge_fade_power); // Rende la sfumatura più o meno aggressiva float vertical_fade = smoothstep(0.0, 0.2, UV.y) * smoothstep(1.0, 0.7, UV.y); ALBEDO = ray_color; ALPHA = noise * base_alpha * depth_fade * edge_fade * vertical_fade * intensity_multiplier; }