mirror of
https://codeberg.org/Melon-Bread/Comets.gd.git
synced 2024-11-28 15:08:20 -05:00
Made a explosion shader for crashing
This commit is contained in:
parent
3ad6004836
commit
7d0e076298
45
assets/shaders/PixelExplosion.gdshader
Normal file
45
assets/shaders/PixelExplosion.gdshader
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
shader_type canvas_item;
|
||||||
|
|
||||||
|
uniform sampler2D noise_tex_normal;
|
||||||
|
uniform sampler2D noise_tex;
|
||||||
|
uniform float progress : hint_range(0.0, 1.0);
|
||||||
|
uniform float strength = 1.0;
|
||||||
|
|
||||||
|
// If your sprite doesn't have enough space and the explosion gets clipped,
|
||||||
|
// you can uncomment this and adjust the scale
|
||||||
|
//void vertex() {
|
||||||
|
// float scale = 3.0;
|
||||||
|
// VERTEX *= scale;
|
||||||
|
//
|
||||||
|
// UV *= scale;
|
||||||
|
// UV -= (scale - 1.0) / 2.0;
|
||||||
|
//}
|
||||||
|
|
||||||
|
void fragment() {
|
||||||
|
vec2 direction = texture(noise_tex_normal, UV).xy; // We're using normal map as direction
|
||||||
|
direction -= 0.5; // Since our normal map is a texture, it ranges from 0.0 to 1.0...
|
||||||
|
direction *= 2.0; // ...so we're going to make it range from -1.0 to 1.0.
|
||||||
|
direction = direction * strength * progress;
|
||||||
|
|
||||||
|
// UV for exploded texture
|
||||||
|
vec2 tex_size = 1.0 / TEXTURE_PIXEL_SIZE; // Real texture size in pixels
|
||||||
|
vec2 uv = floor(UV * tex_size) / (tex_size - 1.0); // Pixelate UV to snap pixels
|
||||||
|
uv = uv - direction; // Distort UV
|
||||||
|
|
||||||
|
// Texture with exploded UV
|
||||||
|
vec4 tex = texture(TEXTURE, uv);
|
||||||
|
|
||||||
|
// Dissolve alpha
|
||||||
|
float dissolve = texture(noise_tex, UV).x;
|
||||||
|
dissolve = step(progress, dissolve);
|
||||||
|
tex.a *= dissolve;
|
||||||
|
|
||||||
|
// Border (in case the edge of your sprite stretches, otherwise you can remove this block)
|
||||||
|
vec2 border_uv = uv * 2.0 - 1.0;
|
||||||
|
border_uv = clamp(abs(border_uv), 0.0, 1.0);
|
||||||
|
float border = max(border_uv.x, border_uv.y);
|
||||||
|
border = ceil(1.0 - border);
|
||||||
|
tex.a *= border;
|
||||||
|
|
||||||
|
COLOR = tex;
|
||||||
|
}
|
@ -1,10 +1,37 @@
|
|||||||
[gd_scene load_steps=8 format=3 uid="uid://cbo47ftx0vcro"]
|
[gd_scene load_steps=14 format=3 uid="uid://cbo47ftx0vcro"]
|
||||||
|
|
||||||
[ext_resource type="Script" path="res://scripts/ship.gd" id="1_japvq"]
|
[ext_resource type="Script" path="res://scripts/ship.gd" id="1_japvq"]
|
||||||
[ext_resource type="Texture2D" uid="uid://qcnuvee2jcp0" path="res://assets/img/ship.png" id="1_ymcdl"]
|
[ext_resource type="Texture2D" uid="uid://qcnuvee2jcp0" path="res://assets/img/ship.png" id="1_ymcdl"]
|
||||||
|
[ext_resource type="Shader" path="res://assets/shaders/PixelExplosion.gdshader" id="2_pn2x0"]
|
||||||
[ext_resource type="AudioStream" uid="uid://cg6v2xvf4jkkv" path="res://assets/sfx/shoot.wav" id="3_kvryg"]
|
[ext_resource type="AudioStream" uid="uid://cg6v2xvf4jkkv" path="res://assets/sfx/shoot.wav" id="3_kvryg"]
|
||||||
[ext_resource type="AudioStream" uid="uid://cycpanck51dqd" path="res://assets/sfx/crash.wav" id="4_i4skj"]
|
[ext_resource type="AudioStream" uid="uid://cycpanck51dqd" path="res://assets/sfx/crash.wav" id="4_i4skj"]
|
||||||
|
|
||||||
|
[sub_resource type="FastNoiseLite" id="FastNoiseLite_dlo0u"]
|
||||||
|
seed = 13
|
||||||
|
|
||||||
|
[sub_resource type="NoiseTexture2D" id="NoiseTexture2D_gyado"]
|
||||||
|
width = 64
|
||||||
|
height = 64
|
||||||
|
generate_mipmaps = false
|
||||||
|
noise = SubResource("FastNoiseLite_dlo0u")
|
||||||
|
|
||||||
|
[sub_resource type="FastNoiseLite" id="FastNoiseLite_t7wfq"]
|
||||||
|
noise_type = 0
|
||||||
|
seed = 3
|
||||||
|
|
||||||
|
[sub_resource type="NoiseTexture2D" id="NoiseTexture2D_2qoa7"]
|
||||||
|
width = 64
|
||||||
|
height = 64
|
||||||
|
generate_mipmaps = false
|
||||||
|
noise = SubResource("FastNoiseLite_t7wfq")
|
||||||
|
|
||||||
|
[sub_resource type="ShaderMaterial" id="ShaderMaterial_lba6n"]
|
||||||
|
shader = ExtResource("2_pn2x0")
|
||||||
|
shader_parameter/progress = 0.0
|
||||||
|
shader_parameter/strength = 1.0
|
||||||
|
shader_parameter/noise_tex_normal = SubResource("NoiseTexture2D_2qoa7")
|
||||||
|
shader_parameter/noise_tex = SubResource("NoiseTexture2D_gyado")
|
||||||
|
|
||||||
[sub_resource type="Animation" id="Animation_qfhr1"]
|
[sub_resource type="Animation" id="Animation_qfhr1"]
|
||||||
length = 0.001
|
length = 0.001
|
||||||
tracks/0/type = "value"
|
tracks/0/type = "value"
|
||||||
@ -19,6 +46,30 @@ tracks/0/keys = {
|
|||||||
"update": 1,
|
"update": 1,
|
||||||
"values": [false]
|
"values": [false]
|
||||||
}
|
}
|
||||||
|
tracks/1/type = "value"
|
||||||
|
tracks/1/imported = false
|
||||||
|
tracks/1/enabled = true
|
||||||
|
tracks/1/path = NodePath("Sprite2D:material:shader_parameter/progress")
|
||||||
|
tracks/1/interp = 1
|
||||||
|
tracks/1/loop_wrap = true
|
||||||
|
tracks/1/keys = {
|
||||||
|
"times": PackedFloat32Array(0),
|
||||||
|
"transitions": PackedFloat32Array(1),
|
||||||
|
"update": 0,
|
||||||
|
"values": [0.0]
|
||||||
|
}
|
||||||
|
tracks/2/type = "value"
|
||||||
|
tracks/2/imported = false
|
||||||
|
tracks/2/enabled = true
|
||||||
|
tracks/2/path = NodePath("Sprite2D/CPUParticles2D:visible")
|
||||||
|
tracks/2/interp = 1
|
||||||
|
tracks/2/loop_wrap = true
|
||||||
|
tracks/2/keys = {
|
||||||
|
"times": PackedFloat32Array(0),
|
||||||
|
"transitions": PackedFloat32Array(1),
|
||||||
|
"update": 1,
|
||||||
|
"values": [true]
|
||||||
|
}
|
||||||
|
|
||||||
[sub_resource type="Animation" id="Animation_ctlro"]
|
[sub_resource type="Animation" id="Animation_ctlro"]
|
||||||
resource_name = "crash"
|
resource_name = "crash"
|
||||||
@ -48,6 +99,30 @@ tracks/1/keys = {
|
|||||||
"method": &"queue_free"
|
"method": &"queue_free"
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
|
tracks/2/type = "value"
|
||||||
|
tracks/2/imported = false
|
||||||
|
tracks/2/enabled = true
|
||||||
|
tracks/2/path = NodePath("Sprite2D:material:shader_parameter/progress")
|
||||||
|
tracks/2/interp = 1
|
||||||
|
tracks/2/loop_wrap = true
|
||||||
|
tracks/2/keys = {
|
||||||
|
"times": PackedFloat32Array(0, 0.5),
|
||||||
|
"transitions": PackedFloat32Array(1, 1),
|
||||||
|
"update": 0,
|
||||||
|
"values": [0.0, 1.0]
|
||||||
|
}
|
||||||
|
tracks/3/type = "value"
|
||||||
|
tracks/3/imported = false
|
||||||
|
tracks/3/enabled = true
|
||||||
|
tracks/3/path = NodePath("Sprite2D/CPUParticles2D:visible")
|
||||||
|
tracks/3/interp = 1
|
||||||
|
tracks/3/loop_wrap = true
|
||||||
|
tracks/3/keys = {
|
||||||
|
"times": PackedFloat32Array(0),
|
||||||
|
"transitions": PackedFloat32Array(1),
|
||||||
|
"update": 1,
|
||||||
|
"values": [false]
|
||||||
|
}
|
||||||
|
|
||||||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_3jmf3"]
|
[sub_resource type="AnimationLibrary" id="AnimationLibrary_3jmf3"]
|
||||||
_data = {
|
_data = {
|
||||||
@ -61,6 +136,7 @@ collision_mask = 2
|
|||||||
script = ExtResource("1_japvq")
|
script = ExtResource("1_japvq")
|
||||||
|
|
||||||
[node name="Sprite2D" type="Sprite2D" parent="."]
|
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||||
|
material = SubResource("ShaderMaterial_lba6n")
|
||||||
texture = ExtResource("1_ymcdl")
|
texture = ExtResource("1_ymcdl")
|
||||||
|
|
||||||
[node name="CPUParticles2D" type="CPUParticles2D" parent="Sprite2D"]
|
[node name="CPUParticles2D" type="CPUParticles2D" parent="Sprite2D"]
|
||||||
@ -71,6 +147,7 @@ spread = 105.9
|
|||||||
gravity = Vector2(0, 0)
|
gravity = Vector2(0, 0)
|
||||||
|
|
||||||
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="."]
|
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="."]
|
||||||
|
visible = false
|
||||||
position = Vector2(0, -1)
|
position = Vector2(0, -1)
|
||||||
polygon = PackedVector2Array(-3, -31, 4, -31, 32, 28, 32, 33, 28, 33, 1, 16, -24, 33, -32, 33, -32, 27)
|
polygon = PackedVector2Array(-3, -31, 4, -31, 32, 28, 32, 33, 28, 33, 1, 16, -24, 33, -32, 33, -32, 27)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user