shader_type canvas_item; // Reads the screen behind this object uniform sampler2D screen_texture : hint_screen_texture, filter_linear_mipmap; // Set to (1.0, 0.0) for Horizontal pass, and (0.0, 1.0) for Vertical pass uniform vec2 direction = vec2(1.0, 0.0); // How far the blur spreads uniform float size = 2.0; void fragment() { // FIX: Grab the exact texture dimensions from our screen sampler vec2 pixel_size = 1.0 / vec2(textureSize(screen_texture, 0)); vec2 screen_uv = SCREEN_UV; // Center pixel weight vec4 color = texture(screen_texture, screen_uv) * 0.2270270270; // First neighbor (using hardware filtering to sample 2 pixels at once) vec2 offset1 = pixel_size * direction * 1.3846153846 * size; color += texture(screen_texture, screen_uv + offset1) * 0.3162162162; color += texture(screen_texture, screen_uv - offset1) * 0.3162162162; // Second neighbor vec2 offset2 = pixel_size * direction * 3.2307692308 * size; color += texture(screen_texture, screen_uv + offset2) * 0.0702702703; color += texture(screen_texture, screen_uv - offset2) * 0.0702702703; COLOR = color; }