├── .gitignore
├── GodotProject
├── BigExplosionScene.tscn
├── ExplosionMaterial.tres
├── ExplosionShader.tres
├── normal+.png
├── normal-.png
├── project.godot
└── smokesprite.png
├── LICENSE.txt
├── demo.gif
├── demo2.gif
└── readme.md
/.gitignore:
--------------------------------------------------------------------------------
1 | **.import
--------------------------------------------------------------------------------
/GodotProject/BigExplosionScene.tscn:
--------------------------------------------------------------------------------
1 | [gd_scene load_steps=4 format=3 uid="uid://goh3vkv8vodf"]
2 |
3 | [ext_resource type="Material" uid="uid://cxhaa6i7bto07" path="res://ExplosionMaterial.tres" id="1_an4hs"]
4 |
5 | [sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_rva4e"]
6 | angle_max = 1.0
7 | initial_velocity_min = 0.5
8 | initial_velocity_max = 1.0
9 | angular_velocity_max = 10.0
10 | gravity = Vector3(0, 0, 0)
11 | linear_accel_min = -1.0
12 | linear_accel_max = -1.0
13 |
14 | [sub_resource type="QuadMesh" id="QuadMesh_16uck"]
15 |
16 | [node name="Node3D" type="Node3D"]
17 |
18 | [node name="Explosion1" type="GPUParticles3D" parent="."]
19 | transform = Transform3D(0.996103, 0, 0, 0, 0.996103, 0, 0, 0, 1, -0.00112057, -0.00427759, -0.00190479)
20 | material_override = ExtResource("1_an4hs")
21 | amount = 20
22 | lifetime = 2.13
23 | explosiveness = 0.91
24 | randomness = 0.84
25 | fixed_fps = 60
26 | visibility_aabb = AABB(-4, -4, -4.79199, 8, 8, 8)
27 | process_material = SubResource("ParticleProcessMaterial_rva4e")
28 | draw_pass_1 = SubResource("QuadMesh_16uck")
29 |
30 | [node name="Explosion2" type="GPUParticles3D" parent="."]
31 | transform = Transform3D(0.996103, 0, 0, 0, 0.996103, 0, 0, 0, 1, -0.00112057, -0.00427759, -0.00190479)
32 | material_override = ExtResource("1_an4hs")
33 | amount = 5
34 | lifetime = 2.13
35 | randomness = 0.84
36 | fixed_fps = 60
37 | visibility_aabb = AABB(-4, -4, -4.79199, 8, 8, 8)
38 | process_material = SubResource("ParticleProcessMaterial_rva4e")
39 | draw_pass_1 = SubResource("QuadMesh_16uck")
40 |
--------------------------------------------------------------------------------
/GodotProject/ExplosionMaterial.tres:
--------------------------------------------------------------------------------
1 | [gd_resource type="ShaderMaterial" load_steps=13 format=3 uid="uid://cxhaa6i7bto07"]
2 |
3 | [ext_resource type="Shader" uid="uid://bfrlkbjyfakqt" path="res://ExplosionShader.tres" id="1_c4nbu"]
4 | [ext_resource type="Texture2D" uid="uid://cp7mt63pvqla" path="res://normal+.png" id="2_b2ebq"]
5 | [ext_resource type="Texture2D" uid="uid://uyri6m5dwm7q" path="res://normal-.png" id="3_rbvhi"]
6 | [ext_resource type="Texture2D" uid="uid://d20w6nd6rhnk1" path="res://smokesprite.png" id="4_254cs"]
7 |
8 | [sub_resource type="Gradient" id="Gradient_3pf84"]
9 | offsets = PackedFloat32Array(0.13, 0.448, 0.724)
10 | colors = PackedColorArray(0, 0, 0, 1, 0.741176, 0.741176, 0.741176, 1, 1, 1, 1, 1)
11 |
12 | [sub_resource type="GradientTexture1D" id="GradientTexture1D_yjpaa"]
13 | gradient = SubResource("Gradient_3pf84")
14 | width = 2048
15 |
16 | [sub_resource type="Gradient" id="Gradient_pmxlp"]
17 | offsets = PackedFloat32Array(0, 0.043, 0.32)
18 | colors = PackedColorArray(0, 0, 0, 1, 0.439216, 0.439216, 0.439216, 1, 1, 1, 1, 1)
19 |
20 | [sub_resource type="GradientTexture1D" id="GradientTexture1D_nfn0e"]
21 | gradient = SubResource("Gradient_pmxlp")
22 | width = 64
23 |
24 | [sub_resource type="Gradient" id="Gradient_prd1g"]
25 | offsets = PackedFloat32Array(0.0169492, 0.38, 0.461, 0.55, 0.602)
26 | colors = PackedColorArray(0, 0, 0, 0, 0.964706, 0.964706, 0.964706, 1, 1, 0.8, 0.501961, 1, 1, 0, 0, 1, 0, 0, 0, 1)
27 |
28 | [sub_resource type="GradientTexture1D" id="GradientTexture1D_awksa"]
29 | gradient = SubResource("Gradient_prd1g")
30 |
31 | [sub_resource type="Gradient" id="Gradient_lyt3e"]
32 |
33 | [sub_resource type="GradientTexture1D" id="GradientTexture1D_xiex5"]
34 | gradient = SubResource("Gradient_lyt3e")
35 |
36 | [resource]
37 | render_priority = 0
38 | shader = ExtResource("1_c4nbu")
39 | shader_parameter/particle_h_frames = 8.0
40 | shader_parameter/particle_v_frames = 8.0
41 | shader_parameter/particles_anim_loop = false
42 | shader_parameter/still_frame = -1.0
43 | shader_parameter/Soft_limit = 0.1
44 | shader_parameter/blend_scale = 0.1
45 | shader_parameter/emission_falloff_multiplier = 0.5
46 | shader_parameter/tex_frg_2 = ExtResource("4_254cs")
47 | shader_parameter/tex_frg_27 = SubResource("GradientTexture1D_xiex5")
48 | shader_parameter/tex_frg_24 = SubResource("GradientTexture1D_yjpaa")
49 | shader_parameter/tex_frg_25 = SubResource("GradientTexture1D_nfn0e")
50 | shader_parameter/tex_frg_26 = SubResource("GradientTexture1D_awksa")
51 | shader_parameter/tex_frg_16 = ExtResource("2_b2ebq")
52 | shader_parameter/tex_frg_17 = ExtResource("3_rbvhi")
53 |
--------------------------------------------------------------------------------
/GodotProject/ExplosionShader.tres:
--------------------------------------------------------------------------------
1 | [gd_resource type="Shader" format=3 uid="uid://bfrlkbjyfakqt"]
2 |
3 | [resource]
4 | code = "shader_type spatial;
5 | render_mode blend_mix, depth_draw_opaque, cull_back, diffuse_lambert, specular_schlick_ggx;
6 |
7 | uniform float particle_h_frames = 8;
8 | uniform float particle_v_frames = 8;
9 | uniform bool particles_anim_loop = false;
10 | uniform float still_frame = -1;
11 | uniform sampler2D tex_frg_2;
12 | uniform sampler2D tex_frg_27 : source_color;
13 | uniform sampler2D tex_frg_24;
14 | uniform float Soft_limit = 0.10000000149012;
15 | uniform float blend_scale = 0.10000000149012;
16 | uniform float emission_falloff_multiplier = 1;
17 | uniform sampler2D tex_frg_25 : source_color;
18 | uniform sampler2D tex_frg_26 : source_color;
19 | uniform sampler2D tex_frg_16;
20 | uniform sampler2D tex_frg_17;
21 | uniform sampler2D depth_texture : source_color, hint_depth_texture;
22 |
23 |
24 |
25 |
26 | void vertex() {
27 | // Input:3
28 | vec3 n_out3p0 = VERTEX;
29 |
30 |
31 | // FloatParameter:5
32 | float n_out5p0 = particle_h_frames;
33 |
34 |
35 | // FloatParameter:6
36 | float n_out6p0 = particle_v_frames;
37 |
38 |
39 | // BooleanParameter:7
40 | bool n_out7p0 = particles_anim_loop;
41 |
42 |
43 | // Input:8
44 | float n_out8p0 = TIME;
45 |
46 |
47 | // FloatParameter:10
48 | float n_out10p0 = still_frame;
49 |
50 |
51 | vec3 n_out2p0;
52 | // Expression:2
53 | n_out2p0 = vec3(0.0, 0.0, 0.0);
54 | {
55 | mat4 mat_world = mat4(normalize(INV_VIEW_MATRIX[0])*length(MODEL_MATRIX[0]),normalize(INV_VIEW_MATRIX[1])*length(MODEL_MATRIX[0]),normalize(INV_VIEW_MATRIX[2])*length(MODEL_MATRIX[2]),MODEL_MATRIX[3]);
56 | //mat_world = mat_world * mat4( vec4(cos(INSTANCE_CUSTOM.x),-sin(INSTANCE_CUSTOM.x), 0.0, 0.0), vec4(sin(INSTANCE_CUSTOM.x), cos(INSTANCE_CUSTOM.x), 0.0, 0.0),vec4(0.0, 0.0, 1.0, 0.0),vec4(0.0, 0.0, 0.0, 1.0));
57 | MODELVIEW_MATRIX = VIEW_MATRIX * mat_world;
58 |
59 | float h_frames = float(particle_h_frames);
60 | float v_frames = float(particle_v_frames);
61 | float particle_total_frames = float(particle_h_frames * particle_v_frames);
62 | float particle_frame = floor(INSTANCE_CUSTOM.y * float(particle_total_frames));
63 | if(still_frame > -0.01f){
64 | particle_frame = floor(still_frame);
65 | }else if (!particles_anim_loop) {
66 | particle_frame = clamp(particle_frame, 0.0, particle_total_frames - 1.0);
67 | } else {
68 | particle_frame = mod(particle_frame, particle_total_frames);
69 | }
70 | UV /= vec2(h_frames, v_frames);
71 | UV += vec2(mod(particle_frame, h_frames) / h_frames, floor(particle_frame / h_frames) / v_frames);
72 |
73 | n_out2p0=INSTANCE_CUSTOM.xyz;
74 |
75 | }
76 |
77 |
78 | // Output:0
79 | COLOR.rgb = n_out2p0;
80 |
81 |
82 | }
83 |
84 | void fragment() {
85 | // Texture2D:2
86 | vec4 n_out2p0 = texture(tex_frg_2, UV);
87 | float n_out2p4 = n_out2p0.a;
88 |
89 |
90 | vec3 n_out10p0;
91 | // ColorFunc:10
92 | {
93 | vec3 c = vec3(n_out2p0.xyz);
94 | float max1 = max(c.r, c.g);
95 | float max2 = max(max1, c.b);
96 | n_out10p0 = vec3(max2, max2, max2);
97 | }
98 |
99 |
100 | // Texture2D:27
101 | vec4 n_out27p0 = texture(tex_frg_27, vec2(n_out10p0.xy));
102 |
103 |
104 | // Texture2D:24
105 | vec4 n_out24p0 = texture(tex_frg_24, vec2(n_out10p0.xy));
106 |
107 |
108 | // FloatParameter:22
109 | float n_out22p0 = Soft_limit;
110 |
111 |
112 | // FloatParameter:23
113 | float n_out23p0 = blend_scale;
114 |
115 |
116 | float n_out19p0;
117 | // Expression:19
118 | n_out19p0 = 0.0;
119 | {
120 |
121 |
122 |
123 | //float depth = texture(depth_texture, SCREEN_UV, 0.0).r;
124 | float depth = texture(depth_texture, SCREEN_UV).x;
125 |
126 | vec4 upos = INV_PROJECTION_MATRIX * vec4(SCREEN_UV * 2.0 - 1.0, depth * 2.0 - 1.0, 1.0);
127 | float pixel_position = upos.z / upos.w;
128 |
129 | vec4 zpos = INV_PROJECTION_MATRIX * vec4(SCREEN_UV * 2.0 - 1.0, FRAGCOORD.z * 2.0 - 1.0, 1.0);
130 | float cur_pos = zpos.z/zpos.w;
131 | n_out22p0 = n_out22p0+(1.0-n_out24p0.x)*n_out23p0;
132 | float help = clamp(abs(cur_pos-pixel_position)*(1.0/n_out22p0),0.0,1.0);
133 | n_out19p0 = help;
134 | }
135 |
136 |
137 | // FloatOp:20
138 | float n_out20p0 = n_out2p4 * n_out19p0;
139 |
140 |
141 | // FloatParameter:15
142 | float n_out15p0 = emission_falloff_multiplier;
143 |
144 |
145 | // Input:5
146 | vec4 n_out5p0 = COLOR;
147 |
148 |
149 | vec2 n_out6p0;
150 | // Expression:6
151 | n_out6p0 = vec2(0.0, 0.0);
152 | {
153 | //n_out6p0.z = 0.0;
154 | n_out6p0.xy = vec2(vec2(n_out5p0.xy).y);
155 | }
156 |
157 |
158 | // Texture2D:25
159 | vec4 n_out25p0 = texture(tex_frg_25, n_out6p0);
160 |
161 |
162 | // FloatOp:13
163 | float n_out13p0 = n_out15p0 * n_out25p0.x;
164 |
165 |
166 | // FloatOp:14
167 | float n_out14p0 = n_out10p0.x + n_out13p0;
168 |
169 |
170 | // Texture2D:26
171 | vec4 n_out26p0 = texture(tex_frg_26, vec2(n_out14p0));
172 |
173 |
174 | // VectorOp:12
175 | vec3 n_in12p1 = vec3(5.00000, 5.00000, 5.00000);
176 | vec3 n_out12p0 = vec3(n_out26p0.xyz) * n_in12p1;
177 |
178 |
179 | // Texture2D:16
180 | vec4 n_out16p0 = texture(tex_frg_16, UV);
181 |
182 |
183 | // Texture2D:17
184 | vec4 n_out17p0 = texture(tex_frg_17, UV);
185 |
186 |
187 | // VectorOp:18
188 | vec3 n_out18p0 = vec3(n_out16p0.xyz) - vec3(n_out17p0.xyz);
189 |
190 |
191 | // Output:0
192 | ALBEDO = vec3(n_out27p0.xyz);
193 | ALPHA = n_out20p0;
194 | EMISSION = n_out12p0;
195 | NORMAL = n_out18p0;
196 |
197 |
198 | }
199 | "
200 |
--------------------------------------------------------------------------------
/GodotProject/normal+.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/memo1918/GodotExplosionVFX/49c16eb40349bfe64210bb748137e4e33925e189/GodotProject/normal+.png
--------------------------------------------------------------------------------
/GodotProject/normal-.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/memo1918/GodotExplosionVFX/49c16eb40349bfe64210bb748137e4e33925e189/GodotProject/normal-.png
--------------------------------------------------------------------------------
/GodotProject/project.godot:
--------------------------------------------------------------------------------
1 | ; Engine configuration file.
2 | ; It's best edited using the editor UI and not directly,
3 | ; since the parameters that go here are not all obvious.
4 | ;
5 | ; Format:
6 | ; [section] ; section goes between []
7 | ; param=value ; assign values to parameters
8 |
9 | config_version=5
10 |
11 | [application]
12 |
13 | config/name="Explosion"
14 | run/main_scene="res://BigExplosionScene.tscn"
15 | config/features=PackedStringArray("4.2")
16 | config/icon="res://icon.png"
17 |
--------------------------------------------------------------------------------
/GodotProject/smokesprite.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/memo1918/GodotExplosionVFX/49c16eb40349bfe64210bb748137e4e33925e189/GodotProject/smokesprite.png
--------------------------------------------------------------------------------
/LICENSE.txt:
--------------------------------------------------------------------------------
1 | Copyright 2020 Duarte David
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4 |
5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6 |
7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
8 |
--------------------------------------------------------------------------------
/demo.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/memo1918/GodotExplosionVFX/49c16eb40349bfe64210bb748137e4e33925e189/demo.gif
--------------------------------------------------------------------------------
/demo2.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/memo1918/GodotExplosionVFX/49c16eb40349bfe64210bb748137e4e33925e189/demo2.gif
--------------------------------------------------------------------------------
/readme.md:
--------------------------------------------------------------------------------
1 | # Notice
2 | This repository is a fork of GodotSimpleExpolsionVFX by drcd1 (https://github.com/drcd1/GodotSimpleExplosionVFX).
3 | Original repository works with godot 3.2 but not with godot 4.2. This repository inlcudes the same VFX that works in 4.2
4 |
5 | This is a simple version transition that aims only for VFX to work and nothing more. I won't be supporting this repo by any means :)
6 |
7 | # Godot Explosion VFX
8 |
9 | A very simple way to setup realistic explosions in the Godot game engine that react to lighting.
10 |
11 |
12 |
13 |
14 | ## Dependencies
15 | - Godot 4.2
16 |
17 | ## How to use
18 | (Parameter names are different, please use try and error approach. Parameters might not affect as expected.)
19 | - Edit properties of the explosion by editing "ExplosionMaterial.tres".
20 | - Emission Fallof Multiplier and Emission Falloff control how fast the flames disappear. (Emission Fallof Multiplier can result in visual problems, I keep it at 0.5)
21 | - Emission Color Ramp allows to modify the color of the flames.
22 | - Smoke Color Ramp allows to modify the color of the smoke.
23 |
--------------------------------------------------------------------------------