Falling rose petal effect

This commit is contained in:
2023-09-13 19:39:10 -07:00
parent 6138957524
commit ce7576731c
16 changed files with 229 additions and 49 deletions

View File

@@ -0,0 +1,79 @@
// Waving Particles shader by Brian Smith (steampunkdemon.itch.io)
// MIT licence
shader_type canvas_item;
// Uncomment the following line if you are using a version of Godot before 4.0:
// const float PI = 3.14159;
// Comment out the following line if you are not applying the shader to a ColorRect:
uniform vec2 dimensions = vec2(1152.0, 648.0); // Resolution of ColorRect in pixels
uniform float rows = 20.0;
uniform float columns = 5.0;
uniform float vertical_scroll : hint_range(-1.0, 1.0, 0.01) = 0.5;
uniform float horizontal_scroll : hint_range(-1.0, 1.0, 0.01) = 0.1;
uniform float size_min : hint_range(0.1, 1.0, 0.1) = 0.3;
uniform float size_max : hint_range(0.1, 1.0, 0.1) = 0.7; // If 'size_max' is larger than 0.7 the corners of the particles will be clipped if they are rotating.
uniform float wave_min : hint_range(0.0, 1.0, 0.1) = 0.1;
uniform float wave_max : hint_range(0.0, 1.0, 0.1) = 1.0; // If the particles are waving into the neighbouring columns reduce 'wave_max'.
uniform float wave_speed : hint_range(0.0, 2.0, 0.1) = 0.5;
uniform float wave_rotation : hint_range(-1.0, 1.0, 0.1) = 1.0;
uniform float fallSpeed = 0.5;
// Replace the below references to 'source_color' with 'hint_color' if you are using a version of Godot before 4.0:
uniform vec4 far_color : source_color = vec4(0.5, 0.5, 0.5, 1.0);
uniform vec4 near_color : source_color = vec4(1.0, 1.0, 1.0, 1.0);
// Remove the below reference to ': source_color, filter_nearest_mipmap' if you are using a version of Godot before 4.0:
uniform sampler2D particle_texture : source_color, filter_nearest_mipmap;
float greater_than(float x, float y) {
return max(sign(x - y), 0.0);
}
void fragment() {
// You can comment out the below line and add a new uniform above as:
// uniform float time = 10000.0;
// You can then update the time uniform from your _physics_process function by adding or subtracting delta. You can also pause the particles' motion by not changing the time uniform.
float time = 10000.0 + TIME;
// Comment out the following two lines if you are not applying the shader to a TextureRect:
// COLOR = texture(TEXTURE,UV); // This line is only required if you are using a version of Godot before 4.0.
// vec2 dimensions = 1.0 / TEXTURE_PIXEL_SIZE;
float row_rn = fract(sin(floor((UV.y - vertical_scroll * time * fallSpeed) * rows)));
float column_rn = fract(sin(floor((UV.x + row_rn - horizontal_scroll * time * fallSpeed) * columns)));
float wave = sin(wave_speed * time * fallSpeed + column_rn * 90.0);
vec2 uv = (vec2(fract((UV.x + row_rn - horizontal_scroll * time * fallSpeed + (wave * (wave_min + (wave_max - wave_min) * column_rn) / columns / 2.0)) * columns), fract((UV.y - vertical_scroll * time * fallSpeed) * rows)) * 2.0 - 1.0) * vec2(dimensions.x / dimensions.y * rows / columns, 1.0);
float size = size_min + (size_max - size_min) * column_rn;
vec4 color = mix(far_color, near_color, column_rn);
// Comment out the below two lines if you do not need or want the particles to rotate:
// float a = ((column_rn + wave) * wave_rotation) * PI;
// uv *= mat2(vec2(sin(a), -cos(a)), vec2(cos(a), sin(a)));
// Render particles as circles with soft edges:
COLOR.rgb = mix(COLOR.rgb, color.rgb, max((size - length(uv)) / size, 0.0) * color.a);
// Render particles as circles with hard edges:
// COLOR.rgb = mix(COLOR.rgb, color.rgb, greater_than(size, length(uv)) * color.a);
// Render particles as crosses with soft edges:
// COLOR.rgb = mix(COLOR.rgb, color.rgb, max((size - length(uv)) / size, 0.0) * (max(greater_than(size / 10.0, abs(uv.x)), greater_than(size / 10.0, abs(uv.y)))) * color.a);
// Render particles as crosses with hard edges:
// COLOR.rgb = mix(COLOR.rgb, color.rgb, max(greater_than(size / 5.0, abs(uv.x)) * greater_than(size, abs(uv.y)), greater_than(size / 5.0, abs(uv.y)) * greater_than(size, abs(uv.x))) * color.a);
// Render particles as squares:
// COLOR.rgb = mix(COLOR.rgb, color.rgb, greater_than(size, abs(uv.x)) * greater_than(size, abs(uv.y)) * color.a);
// Render particles as diamonds:
// COLOR.rgb = mix(COLOR.rgb, color.rgb, greater_than(size, abs(uv.y) + abs(uv.x)) * color.a);
// Render particles using the 'particle_texture':
// The texture should have a border of blank transparent pixels.
vec4 particle_texture_pixel = texture(particle_texture, (uv / size + 1.0) / 2.0) * color;
COLOR.rgb = mix(COLOR.rgb, particle_texture_pixel.rgb, particle_texture_pixel.a);
COLOR.a = min(COLOR.a, particle_texture_pixel.a);
}

View File

@@ -479,7 +479,7 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 3.34053, 0, -3.4541)
shape = SubResource("BoxShape3D_o7d2x")
[node name="Door" type="MeshInstance3D" parent="." node_paths=PackedStringArray("AnimationPlayer")]
transform = Transform3D(1.374, -1.42347e-07, -2.08591e-08, 1.4314e-07, -0.825919, 0.0510564, 3.9862e-07, 0.787235, 0.0535653, -0.666889, 0.665627, 0.217102)
transform = Transform3D(1.374, -1.42347e-07, -2.08591e-08, 1.4314e-07, -0.825919, 0.0510564, 3.9862e-07, 0.787235, 0.0535653, -0.666889, 0.665627, 0.069543)
mesh = SubResource("ArrayMesh_5vvrp")
skeleton = NodePath("")
script = ExtResource("8_ow05j")
@@ -504,7 +504,7 @@ transform = Transform3D(1, -2.84217e-14, -1.27055e-21, 2.84217e-14, 1, 2.98023e-
collision_mask = 32
[node name="CollisionShape3D5" type="CollisionShape3D" parent="Door/StaticBody3D/Door Hitbox"]
transform = Transform3D(-4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, -0.571146, 0.810928, 0.294388)
transform = Transform3D(-4.37114e-08, 2.5411e-21, 1, 1.42109e-14, 1, -2.5411e-21, -1, -2.84217e-14, -4.37114e-08, -0.571146, 0.810928, 0.294388)
shape = SubResource("BoxShape3D_yew2s")
[node name="Exit Portal" parent="." instance=ExtResource("3_2t766")]

View File

@@ -1,10 +1,30 @@
[gd_scene load_steps=13 format=3 uid="uid://bsq7edeueqyjg"]
[gd_scene load_steps=16 format=3 uid="uid://bsq7edeueqyjg"]
[ext_resource type="Script" path="res://Levels/Scripts/Level.cs" id="1_wqwee"]
[ext_resource type="PackedScene" uid="uid://bgf5byqt71kir" path="res://Levels/Models/Stage7/Stage7.tscn" id="2_21i6n"]
[ext_resource type="PackedScene" uid="uid://dahp73fwld24h" path="res://Enemies/RangedEnemy.tscn" id="3_k38yu"]
[ext_resource type="PackedScene" uid="uid://jgf7k1r35km1" path="res://Levels/ExitPortal.tscn" id="3_sjnhq"]
[ext_resource type="PackedScene" uid="uid://bt5rolsyjmx55" path="res://Enemies/MeleeEnemy.tscn" id="4_i8hlv"]
[ext_resource type="Shader" path="res://Levels/Scenes/FallingLeaves.gdshader" id="6_biibx"]
[ext_resource type="Texture2D" uid="uid://jb30lo7r5ev4" path="res://Textures/rose petal 1.png" id="7_it0x1"]
[sub_resource type="ShaderMaterial" id="ShaderMaterial_qgv5j"]
shader = ExtResource("6_biibx")
shader_parameter/dimensions = Vector2(1152, 648)
shader_parameter/rows = 75.0
shader_parameter/columns = 3.0
shader_parameter/vertical_scroll = 0.5
shader_parameter/horizontal_scroll = 0.34
shader_parameter/size_min = 1.0
shader_parameter/size_max = 1.0
shader_parameter/wave_min = 0.5
shader_parameter/wave_max = 1.0
shader_parameter/wave_speed = 1.3
shader_parameter/wave_rotation = 1.0
shader_parameter/fallSpeed = 0.1
shader_parameter/far_color = Color(0.5, 0.5, 0.5, 1)
shader_parameter/near_color = Color(1, 1, 1, 1)
shader_parameter/particle_texture = ExtResource("7_it0x1")
[sub_resource type="BoxShape3D" id="BoxShape3D_ny8q1"]
size = Vector3(5, 20, 27.822)
@@ -31,6 +51,25 @@ size = Vector3(4.32001, 3, 4.24331)
process_mode = 3
script = ExtResource("1_wqwee")
[node name="Container" type="Control" parent="."]
use_parent_material = true
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
[node name="ColorRect" type="ColorRect" parent="Container"]
z_index = -1
material = SubResource("ShaderMaterial_qgv5j")
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
[node name="STAGE 7" parent="." instance=ExtResource("2_21i6n")]
transform = Transform3D(1.04, 0, 0, 0, 1.04, 0, 0, 0, 1.04, -0.601425, 0, 0)
@@ -80,10 +119,10 @@ shape = SubResource("BoxShape3D_tj084")
[node name="Enemies" type="Node3D" parent="."]
[node name="RangedEnemy" parent="Enemies" instance=ExtResource("3_k38yu")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -4.85384, 0, 2.31457)
transform = Transform3D(-1, 0, -8.74228e-08, 0, 1, 0, 8.74228e-08, 0, -1, -4.85384, 0, 2.31457)
[node name="RangedEnemy2" parent="Enemies" instance=ExtResource("3_k38yu")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 3.38654, 0, 2.40798)
transform = Transform3D(-1, 0, -8.74228e-08, 0, 1, 0, 8.74228e-08, 0, -1, 3.38654, 0, 2.40798)
[node name="Melee Enemy" parent="Enemies" instance=ExtResource("4_i8hlv")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 3.55692, 0, 1.39133)
@@ -95,22 +134,22 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -5.06656, 0, 1.27775)
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.737402, 0, -0.439096)
[node name="RangedEnemy3" parent="Enemies" instance=ExtResource("3_k38yu")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 4.37518, 0.999847, -5.54545)
transform = Transform3D(-1, 0, -8.74228e-08, 0, 1, 0, 8.74228e-08, 0, -1, 2.87835, 0.552559, -4.46606)
[node name="RangedEnemy4" parent="Enemies" instance=ExtResource("3_k38yu")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 2.6339, 0.999847, -5.22149)
transform = Transform3D(-1, 0, -8.74228e-08, 0, 1, 0, 8.74228e-08, 0, -1, 1.43271, 0.54106, -4.59394)
[node name="RangedEnemy5" parent="Enemies" instance=ExtResource("3_k38yu")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -3.62257, 0.999847, -5.26199)
transform = Transform3D(-1, 0, -8.74228e-08, 0, 1, 0, 8.74228e-08, 0, -1, -3.62257, 0.525391, -4.57564)
[node name="RangedEnemy6" parent="Enemies" instance=ExtResource("3_k38yu")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -5.3436, 0.999847, -5.72768)
transform = Transform3D(-1, 0, -8.74228e-08, 0, 1, 0, 8.74228e-08, 0, -1, -5.3436, 0.564535, -4.33553)
[node name="Melee Enemy4" parent="Enemies" instance=ExtResource("4_i8hlv")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.7193, 0, -6.94253)
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.7193, 0, -6.27177)
[node name="Melee Enemy5" parent="Enemies" instance=ExtResource("4_i8hlv")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.366184, 0, -6.90203)
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.366184, 0, -6.28619)
[node name="Exit Portal" parent="." instance=ExtResource("3_sjnhq")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.484857, 0.170241, -5.15013)