78 lines
2.5 KiB
Text
78 lines
2.5 KiB
Text
[gd_scene format=3 uid="uid://bfg4q1t8s06vv"]
|
|
|
|
[ext_resource type="Shader" uid="uid://dfocpicc6jowx" path="res://shaders/optimized_blur.gdshader" id="1_fuoj5"]
|
|
|
|
[sub_resource type="ShaderMaterial" id="ShaderMaterial_3ikdx"]
|
|
shader = ExtResource("1_fuoj5")
|
|
shader_parameter/direction = Vector2(1, 0)
|
|
shader_parameter/size = 2.0
|
|
|
|
[sub_resource type="Shader" id="Shader_fuoj5"]
|
|
code = "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;
|
|
}"
|
|
|
|
[sub_resource type="ShaderMaterial" id="ShaderMaterial_igp3v"]
|
|
shader = SubResource("Shader_fuoj5")
|
|
shader_parameter/direction = Vector2(0, 1)
|
|
shader_parameter/size = 2.0
|
|
|
|
[node name="OptimizedBlurPanel" type="Control" unique_id=1779763293]
|
|
layout_mode = 3
|
|
anchors_preset = 15
|
|
anchor_right = 1.0
|
|
anchor_bottom = 1.0
|
|
grow_horizontal = 2
|
|
grow_vertical = 2
|
|
|
|
[node name="CaptureScreen" type="BackBufferCopy" parent="." unique_id=1195446396]
|
|
copy_mode = 2
|
|
|
|
[node name="HorizontalBlur" type="ColorRect" parent="." unique_id=170203162]
|
|
material = SubResource("ShaderMaterial_3ikdx")
|
|
layout_mode = 1
|
|
anchors_preset = 15
|
|
anchor_right = 1.0
|
|
anchor_bottom = 1.0
|
|
grow_horizontal = 2
|
|
grow_vertical = 2
|
|
|
|
[node name="CatchHorizontalBlur" type="BackBufferCopy" parent="." unique_id=110780185]
|
|
copy_mode = 2
|
|
|
|
[node name="VerticalBlur" type="ColorRect" parent="." unique_id=505478202]
|
|
material = SubResource("ShaderMaterial_igp3v")
|
|
layout_mode = 1
|
|
anchors_preset = 15
|
|
anchor_right = 1.0
|
|
anchor_bottom = 1.0
|
|
grow_horizontal = 2
|
|
grow_vertical = 2
|