18.5
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
extends Node3D
|
||||
|
||||
signal fire_destroyed()
|
||||
|
||||
func _on_area_3d_area_entered(area: Area3D) -> void:
|
||||
fire_destroyed.emit()
|
||||
self.queue_free()
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
var shader_mat := $GPUParticles3D.material_override as ShaderMaterial
|
||||
print(scale.x)
|
||||
shader_mat.set_shader_parameter("scale", scale.x)
|
||||
@@ -0,0 +1 @@
|
||||
uid://ditgg1m25jqb
|
||||
@@ -0,0 +1,123 @@
|
||||
shader_type spatial;
|
||||
render_mode unshaded, cull_disabled;
|
||||
uniform sampler2D fire_tex_1;
|
||||
uniform sampler2D fire_tex_2;
|
||||
uniform sampler2D fire_mask;
|
||||
uniform vec4 inner_color;
|
||||
uniform vec4 outer_color;
|
||||
// fire uniforms
|
||||
uniform float detail_strength = 3.0;
|
||||
uniform float scroll_speed = 1.2;
|
||||
uniform float fire_height = 1.0;
|
||||
uniform float fire_shape = 1.5;
|
||||
uniform float fire_thickness = 0.55;
|
||||
uniform float fire_sharpness = 1.0;
|
||||
uniform float intensity = 1.0;
|
||||
|
||||
// noise uniforms
|
||||
uniform int noise_octaves = 6;
|
||||
uniform float noise_lacunarity = 3.0;
|
||||
uniform float noise_gain = 0.5;
|
||||
uniform float noise_amplitude = 1.0;
|
||||
uniform float noise_frequency = 1.5;
|
||||
uniform float scale = 1.0;
|
||||
|
||||
|
||||
float hash(vec2 p) {
|
||||
p = fract(p * 0.3183099 + vec2(0.1, 0.1));
|
||||
p *= 17.0;
|
||||
return fract(p.x * p.y * (p.x + p.y));
|
||||
}
|
||||
|
||||
float noise(vec2 x) {
|
||||
vec2 p = floor(x);
|
||||
vec2 f = fract(x);
|
||||
|
||||
float n =
|
||||
hash(p) * (1.0 - f.x) * (1.0 - f.y) +
|
||||
hash(p + vec2(1.0, 0.0)) * f.x * (1.0 - f.y) +
|
||||
hash(p + vec2(0.0, 1.0)) * (1.0 - f.x) * f.y +
|
||||
hash(p + vec2(1.0, 1.0)) * f.x * f.y;
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
float fbm(vec2 p) {
|
||||
int octaves = noise_octaves;
|
||||
float lacunarity = noise_lacunarity;
|
||||
float gain = noise_gain;
|
||||
float amplitude = noise_amplitude;
|
||||
float frequency = noise_frequency;
|
||||
float total = 0.0;
|
||||
|
||||
for (int i = 0; i < octaves; i++) {
|
||||
total += noise(p * frequency) * amplitude;
|
||||
frequency *= lacunarity;
|
||||
amplitude *= gain;
|
||||
}
|
||||
|
||||
return total * 0.5;
|
||||
}
|
||||
|
||||
|
||||
float random (vec2 uv) {
|
||||
return fract(sin(dot(uv.xy,
|
||||
vec2(12.9898,78.233))) * 43758.5453123);
|
||||
}
|
||||
void vertex() {
|
||||
VERTEX *= scale;
|
||||
mat4 modified_model_view = VIEW_MATRIX * mat4(
|
||||
INV_VIEW_MATRIX[0],
|
||||
MODEL_MATRIX[1],
|
||||
INV_VIEW_MATRIX[2],
|
||||
MODEL_MATRIX[3]
|
||||
);
|
||||
|
||||
MODELVIEW_MATRIX = modified_model_view;
|
||||
}
|
||||
|
||||
|
||||
void fragment() {
|
||||
vec2 uv = UV;
|
||||
|
||||
// modified_uv for offset and animating UVs for fire
|
||||
vec2 modified_uv = -uv;
|
||||
modified_uv.x = mod(modified_uv.x, 1.0) - 0.5;
|
||||
modified_uv.y += 0.84; // size vertical
|
||||
|
||||
// fire noise scroll effect
|
||||
float scroll = scroll_speed * detail_strength * TIME;
|
||||
|
||||
// sample noise for fire
|
||||
float n = fbm(detail_strength * modified_uv - vec2(0.0, scroll));
|
||||
|
||||
// Threshold to create a mask-like edge
|
||||
float mask2 = smoothstep(0.4, 0.6, n);
|
||||
|
||||
vec3 noise_1 = texture(fire_tex_1, vec2(UV.x, UV.y + TIME * 0.7)).rgb * n;
|
||||
vec3 noise_2 = texture(fire_tex_2, vec2(UV.x, UV.y + TIME * 1.2)).rgb * n;
|
||||
vec3 mask = texture(fire_mask, UV).rgb - 0.2;
|
||||
vec3 col = (noise_1 + noise_2) * mask * mask2;
|
||||
|
||||
float fire_intensity = intensity - 16.0 * fire_sharpness * pow(
|
||||
max(
|
||||
0.0,
|
||||
length(
|
||||
modified_uv * vec2((1.0 / fire_thickness) + modified_uv.y * fire_shape, 1.0 / fire_height)
|
||||
) - n * max(0.0, modified_uv.y + 0.25)
|
||||
),
|
||||
1.2
|
||||
);
|
||||
float fire_intensity1 = n * fire_intensity * (1.5 - pow(1.0 * uv.y, 14.0));
|
||||
float alpha = fire_intensity * (1.0 - pow(uv.y, 3.0));
|
||||
fire_intensity1 = clamp(fire_intensity1, 0.0, 1.0);
|
||||
|
||||
ALBEDO = vec3(step(0.015, col.r));
|
||||
ALBEDO *= mix(outer_color.rgb, inner_color.rgb, step(0.15, col.r)) * alpha;
|
||||
ALPHA = step(0.015, col.r) * (alpha * 2.0);
|
||||
}
|
||||
|
||||
//void light() {
|
||||
// // Called for every pixel for every light affecting the material.
|
||||
// // Uncomment to replace the default light processing function with this one.
|
||||
//}
|
||||
@@ -0,0 +1 @@
|
||||
uid://dh1ojfq5wjssr
|
||||
@@ -0,0 +1,60 @@
|
||||
[gd_scene load_steps=11 format=3 uid="uid://cd400imcxfedx"]
|
||||
|
||||
[ext_resource type="Shader" uid="uid://dh1ojfq5wjssr" path="res://assets/fire/fire.gdshader" id="1_7tybv"]
|
||||
[ext_resource type="Script" uid="uid://ditgg1m25jqb" path="res://assets/fire/fire.gd" id="1_2358p"]
|
||||
[ext_resource type="Texture2D" uid="uid://bjhe12vumm36l" path="res://assets/fire/fire_mask.png" id="2_u4s6h"]
|
||||
[ext_resource type="Texture2D" uid="uid://q2qah83jlqud" path="res://assets/fire/fire_tex_1.png" id="3_2358p"]
|
||||
[ext_resource type="Texture2D" uid="uid://l3yqk4echy8y" path="res://assets/fire/fire_tex_2.png" id="4_hmhxn"]
|
||||
[ext_resource type="PackedScene" uid="uid://bn6uprm55d3tt" path="res://game/game_state.tscn" id="6_hmhxn"]
|
||||
|
||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_4depb"]
|
||||
render_priority = 0
|
||||
shader = ExtResource("1_7tybv")
|
||||
shader_parameter/fire_tex_1 = ExtResource("3_2358p")
|
||||
shader_parameter/fire_tex_2 = ExtResource("4_hmhxn")
|
||||
shader_parameter/fire_mask = ExtResource("2_u4s6h")
|
||||
shader_parameter/inner_color = Vector4(1.079, 0.638, 0.168, 0.82)
|
||||
shader_parameter/outer_color = Vector4(0.988, 0.357, 0.259, 0)
|
||||
shader_parameter/detail_strength = 3.0
|
||||
shader_parameter/scroll_speed = 1.2
|
||||
shader_parameter/fire_height = 1.0
|
||||
shader_parameter/fire_shape = 1.5
|
||||
shader_parameter/fire_thickness = 0.55
|
||||
shader_parameter/fire_sharpness = 1.0
|
||||
shader_parameter/intensity = 1.0
|
||||
shader_parameter/noise_octaves = 6
|
||||
shader_parameter/noise_lacunarity = 3.0
|
||||
shader_parameter/noise_gain = 0.5
|
||||
shader_parameter/noise_amplitude = 1.0
|
||||
shader_parameter/noise_frequency = 1.5
|
||||
shader_parameter/scale = 1.0
|
||||
|
||||
[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_pbcvv"]
|
||||
gravity = Vector3(0, 0, 0)
|
||||
|
||||
[sub_resource type="QuadMesh" id="QuadMesh_7tybv"]
|
||||
|
||||
[sub_resource type="SphereShape3D" id="SphereShape3D_u4s6h"]
|
||||
radius = 0.17174505
|
||||
|
||||
[node name="Fire" type="Node3D"]
|
||||
script = ExtResource("1_2358p")
|
||||
|
||||
[node name="GPUParticles3D" type="GPUParticles3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.38733134, 0)
|
||||
material_override = SubResource("ShaderMaterial_4depb")
|
||||
amount = 1
|
||||
lifetime = 5.0
|
||||
process_material = SubResource("ParticleProcessMaterial_pbcvv")
|
||||
draw_pass_1 = SubResource("QuadMesh_7tybv")
|
||||
|
||||
[node name="Area3D" type="Area3D" parent="."]
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="Area3D"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.07229382, 0)
|
||||
shape = SubResource("SphereShape3D_u4s6h")
|
||||
|
||||
[node name="GameState" parent="." instance=ExtResource("6_hmhxn")]
|
||||
|
||||
[connection signal="fire_destroyed" from="." to="GameState" method="_on_fire_fire_destroyed"]
|
||||
[connection signal="area_entered" from="Area3D" to="." method="_on_area_3d_area_entered"]
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 8.5 KiB |
@@ -0,0 +1,42 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://bjhe12vumm36l"
|
||||
path.s3tc="res://.godot/imported/fire_mask.png-7b2abd2b81f7d797a8f5555e2eeb7d71.s3tc.ctex"
|
||||
path.etc2="res://.godot/imported/fire_mask.png-7b2abd2b81f7d797a8f5555e2eeb7d71.etc2.ctex"
|
||||
metadata={
|
||||
"imported_formats": ["s3tc_bptc", "etc2_astc"],
|
||||
"vram_texture": true
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/fire/fire_mask.png"
|
||||
dest_files=["res://.godot/imported/fire_mask.png-7b2abd2b81f7d797a8f5555e2eeb7d71.s3tc.ctex", "res://.godot/imported/fire_mask.png-7b2abd2b81f7d797a8f5555e2eeb7d71.etc2.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=2
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/uastc_level=0
|
||||
compress/rdo_quality_loss=0.0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=true
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/channel_remap/red=0
|
||||
process/channel_remap/green=1
|
||||
process/channel_remap/blue=2
|
||||
process/channel_remap/alpha=3
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=0
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 30 KiB |
@@ -0,0 +1,42 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://q2qah83jlqud"
|
||||
path.s3tc="res://.godot/imported/fire_tex_1.png-cefef1e67bbb945a669896483220fb46.s3tc.ctex"
|
||||
path.etc2="res://.godot/imported/fire_tex_1.png-cefef1e67bbb945a669896483220fb46.etc2.ctex"
|
||||
metadata={
|
||||
"imported_formats": ["s3tc_bptc", "etc2_astc"],
|
||||
"vram_texture": true
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/fire/fire_tex_1.png"
|
||||
dest_files=["res://.godot/imported/fire_tex_1.png-cefef1e67bbb945a669896483220fb46.s3tc.ctex", "res://.godot/imported/fire_tex_1.png-cefef1e67bbb945a669896483220fb46.etc2.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=2
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/uastc_level=0
|
||||
compress/rdo_quality_loss=0.0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=true
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/channel_remap/red=0
|
||||
process/channel_remap/green=1
|
||||
process/channel_remap/blue=2
|
||||
process/channel_remap/alpha=3
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=0
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 30 KiB |
@@ -0,0 +1,42 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://l3yqk4echy8y"
|
||||
path.s3tc="res://.godot/imported/fire_tex_2.png-7b804eaf97d0fd311b39db7905126cbf.s3tc.ctex"
|
||||
path.etc2="res://.godot/imported/fire_tex_2.png-7b804eaf97d0fd311b39db7905126cbf.etc2.ctex"
|
||||
metadata={
|
||||
"imported_formats": ["s3tc_bptc", "etc2_astc"],
|
||||
"vram_texture": true
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/fire/fire_tex_2.png"
|
||||
dest_files=["res://.godot/imported/fire_tex_2.png-7b804eaf97d0fd311b39db7905126cbf.s3tc.ctex", "res://.godot/imported/fire_tex_2.png-7b804eaf97d0fd311b39db7905126cbf.etc2.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=2
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/uastc_level=0
|
||||
compress/rdo_quality_loss=0.0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=true
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/channel_remap/red=0
|
||||
process/channel_remap/green=1
|
||||
process/channel_remap/blue=2
|
||||
process/channel_remap/alpha=3
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=0
|
||||
@@ -0,0 +1,4 @@
|
||||
extends GPUParticles3D
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
self.process_material.set("shader_parameter/fire_mask", Texture2D.new());
|
||||
@@ -0,0 +1 @@
|
||||
uid://ckylavsg60e7i
|
||||
Reference in New Issue
Block a user