add shader rotation and dof effect to menu bg

This commit is contained in:
interfisch 2024-12-27 15:04:24 +01:00
parent 5a734a3c21
commit bc53034a1c
3 changed files with 29 additions and 60 deletions

View file

@ -1,10 +1,9 @@
[gd_scene load_steps=11 format=3 uid="uid://cu7olkgkyy2tq"]
[gd_scene load_steps=10 format=3 uid="uid://cu7olkgkyy2tq"]
[ext_resource type="Texture2D" uid="uid://csknopg1cbqbq" path="res://sprites/background/green_gradient.png" id="1_nq5g7"]
[ext_resource type="Texture2D" uid="uid://5l1t6nyjn022" path="res://sprites/road/road_border.png" id="3_mivmq"]
[ext_resource type="Script" path="res://scripts/roadborder.gd" id="4_8hrwh"]
[ext_resource type="Texture2D" uid="uid://gydxil7qf7jc" path="res://sprites/road/road_trim.png" id="5_5a0eo"]
[ext_resource type="Texture2D" uid="uid://cakbnxin6c6ba" path="res://sprites/smooth_fields/fields_flower_006.png" id="6_0rmma"]
[ext_resource type="Script" path="res://scripts/generate_road_polyon.gd" id="6_vdo8x"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_daqun"]
@ -144,11 +143,3 @@ shape = SubResource("RectangleShape2D_82iti")
z_index = 20
texture_filter = 1
position = Vector2(0, 1)
[node name="FieldsFlower006" type="Sprite2D" parent="Scenery2D"]
position = Vector2(1088, -705)
texture = ExtResource("6_0rmma")
[node name="FieldsFlower007" type="Sprite2D" parent="Scenery2D"]
position = Vector2(1024, -769)
texture = ExtResource("6_0rmma")

View file

@ -1,4 +1,4 @@
[gd_scene load_steps=17 format=3 uid="uid://b1uhymisifcho"]
[gd_scene load_steps=14 format=3 uid="uid://b1uhymisifcho"]
[ext_resource type="Script" path="res://scripts/menu.gd" id="1_fushn"]
[ext_resource type="Script" path="res://scripts/menudisplay.gd" id="2_jc4pv"]
@ -15,47 +15,11 @@
[sub_resource type="ShaderMaterial" id="ShaderMaterial_kpdum"]
shader = ExtResource("3_vry7a")
shader_parameter/strength = 1.0
shader_parameter/rotationpivot = Vector2(0.5, 0.49)
shader_parameter/speed = 0.1
shader_parameter/strength = 8.5
shader_parameter/iChannel0 = ExtResource("10_equk1")
[sub_resource type="Animation" id="Animation_l7n24"]
length = 0.001
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("MenuBg:rotation")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [0.0]
}
[sub_resource type="Animation" id="Animation_hwlp0"]
resource_name = "menu_idle"
length = 60.0
loop_mode = 1
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("MenuBg:rotation")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0, 60),
"transitions": PackedFloat32Array(1, 1),
"update": 0,
"values": [0.0, -6.28319]
}
[sub_resource type="AnimationLibrary" id="AnimationLibrary_1aer6"]
_data = {
"RESET": SubResource("Animation_l7n24"),
"menu_idle": SubResource("Animation_hwlp0")
}
[node name="Menu" type="Node"]
script = ExtResource("1_fushn")
@ -218,12 +182,6 @@ offset_bottom = 26.0
theme_override_constants/outline_size = 10
text = "Rounds:"
[node name="AnimationPlayer" type="AnimationPlayer" parent="MenuDisplay"]
libraries = {
"": SubResource("AnimationLibrary_1aer6")
}
autoplay = "menu_idle"
[node name="Timer" type="Timer" parent="."]
wait_time = 5.0

View file

@ -4,7 +4,9 @@ shader_type canvas_item;
#define iResolution vec2(0.001,0.001)
uniform sampler2D iChannel0;
uniform float strength : hint_range(0.0, 5.0, 0.1) = 1.0;
uniform vec2 rotationpivot=vec2(0.5,0.5);
uniform float speed=0.1;
uniform float strength : hint_range(0.0, 20.0, 0.1) = 1.0;
const float pi = atan(1.0) * 4.0;
const int samples = 35;
const float sigma = float(samples) * 0.25;
@ -31,10 +33,28 @@ vec3 blur(sampler2D sp, vec2 uv, vec2 scale) {
return col / accum;
}
vec2 rotateUV(vec2 uv, vec2 pivot, float rotation) {
float cosa = cos(rotation);
float sina = sin(rotation);
uv -= pivot;
return vec2(
cosa * uv.x - sina * uv.y,
cosa * uv.y + sina * uv.x
) + pivot;
}
void fragment() {
vec2 ps = vec2(1.0) / iResolution.xy * .000001 * strength;
vec2 uv = UV ;
vec2 uv = UV ;
vec2 rotuv=rotateUV(uv,rotationpivot,TIME*speed);
float _strength=abs(0.47-uv.y)*strength;
vec2 ps = vec2(1.0) / iResolution.xy * .000001 * _strength;
COLOR.rgb = blur(iChannel0, uv, ps );
//COLOR.rgb=texture(iChannel0, uv).rgb;
COLOR.rgb = blur(iChannel0, rotuv, ps );
COLOR.a = 1.0;
}