add wind + dust

This commit is contained in:
Matteo Sonaglioni
2026-03-13 16:42:54 +01:00
parent 6801df2103
commit 6e11a95a3e
15 changed files with 202 additions and 55 deletions

View File

@@ -1,17 +0,0 @@
shader_type canvas_item;
// Cattura tutto quello che c'è sotto questo nodo
uniform sampler2D screen_texture : hint_screen_texture, filter_linear_mipmap;
uniform float blur_amount : hint_range(0.0, 5.0) = 2.5;
uniform float focus_size : hint_range(0.0, 1.0) = 0.4;
uniform float transition_softness : hint_range(0.01, 1.0) = 0.3;
void fragment() {
float dist_from_center = abs(SCREEN_UV.y - 0.5);
float mask = smoothstep(focus_size / 2.0, (focus_size / 2.0) + transition_softness, dist_from_center);
// Applica il blur
vec4 blurred_screen = textureLod(screen_texture, SCREEN_UV, blur_amount * mask);
COLOR = blurred_screen;
}

View File

@@ -1 +0,0 @@
uid://bl1dwh2k06yy5

View File

@@ -30,6 +30,7 @@
[ext_resource type="Shader" uid="uid://cglb64vpwpgpu" path="res://Shaders/Water2.gdshader" id="19_6k3cw"]
[ext_resource type="PackedScene" uid="uid://cpebna545ihfh" path="res://Scenes/Chunk_Scene/Chunk/Foresta/Chunk_F_L_2.tscn" id="20_00nhk"]
[ext_resource type="PackedScene" uid="uid://bp5gnv0noxcpc" path="res://Scenes/Test/Scogliera_Blockout.tscn" id="20_16mw0"]
[ext_resource type="TubeTrailMesh" uid="uid://2wmnftxwg8wt" path="res://Assets/Meshes/Wind.tres" id="21_l1dl0"]
[ext_resource type="PackedScene" uid="uid://dk85mk0hapngf" path="res://Assets/Test/rock2.glb" id="21_qdxup"]
[ext_resource type="Shader" uid="uid://c0dy1aqj1b4q3" path="res://Shaders/trunk_shader.gdshader" id="22_tbvi6"]
[ext_resource type="Texture2D" uid="uid://8sdgkykyg5l5" path="res://Assets/Textures/rock_color.png" id="23_4udcq"]
@@ -47,8 +48,8 @@
[ext_resource type="PackedScene" uid="uid://jqqiendhdgqq" path="res://Scenes/Test/Test_Chunk_Rettilineo.tscn" id="33_mvcuv"]
[ext_resource type="PackedScene" uid="uid://bhcut7ndtdo2w" path="res://Assets/Test/SK_Mannequin.FBX" id="34_3nw1o"]
[ext_resource type="PackedScene" uid="uid://xebpudhewwwj" path="res://Scenes/Chunk_Scene/Chunk/Campagna/Chunk_C_L_2.tscn" id="35_n33lw"]
[ext_resource type="Shader" uid="uid://bl1dwh2k06yy5" path="res://Scenes/Blur.gdshader" id="46_nonqo"]
[ext_resource type="Shader" uid="uid://bttmyh64kihyr" path="res://Scenes/Nebbia2D.gdshader" id="47_7j5hj"]
[ext_resource type="Shader" uid="uid://bl1dwh2k06yy5" path="res://Shaders/Blur.gdshader" id="46_nonqo"]
[ext_resource type="Shader" uid="uid://bttmyh64kihyr" path="res://Shaders/Nebbia2D.gdshader" id="47_7j5hj"]
[sub_resource type="NoiseTexture2D" id="NoiseTexture2D_10fbe"]
noise = ExtResource("6_00nhk")
@@ -257,24 +258,51 @@ shader_parameter/cast_shadow_strength = 0.6
[sub_resource type="PlaneMesh" id="PlaneMesh_gsfny"]
[sub_resource type="FastNoiseLite" id="FastNoiseLite_oqwsk"]
[sub_resource type="Gradient" id="Gradient_u10x4"]
offsets = PackedFloat32Array(0, 0.49127907, 1)
colors = PackedColorArray(0, 0, 0, 0, 1, 0.89900386, 0.37477228, 1, 1, 1, 1, 0)
[sub_resource type="NoiseTexture2D" id="NoiseTexture2D_8vrnd"]
noise = SubResource("FastNoiseLite_oqwsk")
seamless = true
[sub_resource type="GradientTexture1D" id="GradientTexture1D_l1dl0"]
gradient = SubResource("Gradient_u10x4")
[sub_resource type="ShaderMaterial" id="ShaderMaterial_l1dl0"]
render_priority = 0
shader = ExtResource("23_u10x4")
shader_parameter/fog_noise = SubResource("NoiseTexture2D_8vrnd")
shader_parameter/use_red_as_alpha = true
shader_parameter/fog_color = Color(0.8, 0.8509804, 0.9019608, 1)
shader_parameter/scroll_speed = Vector2(0.01, 0.01)
shader_parameter/texture_scale = Vector2(1, 1)
shader_parameter/edge_softness_y = 0.5
shader_parameter/edge_softness_x = 0.5
shader_parameter/night_intensity = 0.0
shader_parameter/sun_color = Color(1, 1, 1, 1)
[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_kjb07"]
emission_shape = 3
emission_box_extents = Vector3(15, 3, 15)
gravity = Vector3(0, 0.2, 0)
color_ramp = SubResource("GradientTexture1D_l1dl0")
turbulence_enabled = true
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_on20a"]
transparency = 1
shading_mode = 0
vertex_color_use_as_albedo = true
billboard_mode = 3
particles_anim_h_frames = 1
particles_anim_v_frames = 1
particles_anim_loop = false
[sub_resource type="QuadMesh" id="QuadMesh_6k3cw"]
material = SubResource("StandardMaterial3D_on20a")
size = Vector2(0.1, 0.1)
[sub_resource type="Gradient" id="Gradient_kjb07"]
offsets = PackedFloat32Array(0, 0.49709302, 1)
colors = PackedColorArray(0, 0, 0, 0, 1, 1, 1, 0.7647059, 1, 1, 1, 0)
[sub_resource type="GradientTexture1D" id="GradientTexture1D_on20a"]
gradient = SubResource("Gradient_kjb07")
[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_6k3cw"]
lifetime_randomness = 0.5
emission_shape_scale = Vector3(5, 5, 5)
emission_shape = 3
emission_box_extents = Vector3(1, 1, 1)
direction = Vector3(0, 1, 0)
spread = 0.0
initial_velocity_min = 6.0
initial_velocity_max = 6.0
gravity = Vector3(0, 0, 0)
color_ramp = SubResource("GradientTexture1D_on20a")
[sub_resource type="Curve3D" id="Curve3D_bedag"]
closed = true
@@ -287,6 +315,12 @@ point_count = 93
[sub_resource type="PlaneMesh" id="PlaneMesh_l1dl0"]
[sub_resource type="FastNoiseLite" id="FastNoiseLite_oqwsk"]
[sub_resource type="NoiseTexture2D" id="NoiseTexture2D_8vrnd"]
noise = SubResource("FastNoiseLite_oqwsk")
seamless = true
[sub_resource type="ShaderMaterial" id="ShaderMaterial_kjb07"]
render_priority = 0
shader = ExtResource("23_u10x4")
@@ -672,9 +706,9 @@ shadow_mesh = SubResource("ArrayMesh_odcbb")
[sub_resource type="ShaderMaterial" id="ShaderMaterial_u10x4"]
shader = ExtResource("47_7j5hj")
shader_parameter/fog_color = Color(0.85, 0.9, 0.95, 1)
shader_parameter/clear_center_radius = 0.4
shader_parameter/edge_softness = 0.25000001117647996
shader_parameter/max_opacity = 0.150000007125
shader_parameter/clear_center_radius = 0.4650000220875
shader_parameter/edge_softness = 0.30900001397898
shader_parameter/max_opacity = 0.1350000064125
[sub_resource type="ShaderMaterial" id="ShaderMaterial_kwbnj"]
shader = ExtResource("46_nonqo")
@@ -682,7 +716,7 @@ shader_parameter/blur_amount = 0.70000003325
shader_parameter/focus_size = 0.450000021375
shader_parameter/transition_softness = 0.3
[node name="DemoForest" type="Node3D" unique_id=265279494 node_paths=PackedStringArray("nodo_polvere")]
[node name="DemoForest" type="Node3D" unique_id=265279494 node_paths=PackedStringArray("nodo_polvere", "particelle_lucciole", "particelle_vento")]
script = ExtResource("1_cr3ar")
color_pomeriggio = Color(0.9999996, 0.6887105, 0.42199263, 1)
color_notte = Color(0.18353948, 0.18552834, 0.48496485, 1)
@@ -705,6 +739,11 @@ godray_spawn_radius = 100.0
godray_spawn_offset = Vector3(20, 80, 20)
godray_rotation_degrees = Vector3(50, 30, 0)
godray_scale = Vector3(2, 25, 50)
particelle_lucciole = NodePath("SubViewportContainer/SubViewport/World/Camere/CameraPivot/Lucciole")
quantita_lucciole = 400
raggio_spawn_lucciole = 40.0
particelle_vento = NodePath("SubViewportContainer/SubViewport/World/Camere/CameraPivot/Wind")
quantita_vento = 50
[node name="CanvasLayer" type="CanvasLayer" parent="." unique_id=427161585]
@@ -878,17 +917,22 @@ mesh = SubResource("PlaneMesh_gsfny")
skeleton = NodePath("../../../../../..")
surface_material_override/0 = ExtResource("2_4xv0h")
[node name="Fog3" type="MeshInstance3D" parent="SubViewportContainer/SubViewport/World/Camere/CameraPivot" unique_id=1510712731]
transform = Transform3D(0.23348677, 23.566315, 10.13246, 0.16955252, 16.852575, -13.287166, -85.35561, 20.688768, -0.20234334, -40.737335, -6.168863, 49.11189)
mesh = SubResource("PlaneMesh_gsfny")
skeleton = NodePath("../../../../../..")
surface_material_override/0 = SubResource("ShaderMaterial_l1dl0")
[node name="Lucciole" type="GPUParticles3D" parent="SubViewportContainer/SubViewport/World/Camere/CameraPivot" unique_id=1589413685]
transform = Transform3D(1, 0, 0, 0, 0.99999976, 0, 0, 0, 0.99999976, 0, 1.9999999, 4.7141495)
amount = 50
lifetime = 4.0
process_material = SubResource("ParticleProcessMaterial_kjb07")
draw_pass_1 = SubResource("QuadMesh_6k3cw")
[node name="Fog4" type="MeshInstance3D" parent="SubViewportContainer/SubViewport/World/Camere/CameraPivot" unique_id=1074990597]
transform = Transform3D(-4.157295, -22.59027, -10.13105, 0.16955031, 16.852552, -13.287153, 85.25453, -21.750288, -0.2636921, 34.739395, -6.168857, 49.111843)
mesh = SubResource("PlaneMesh_gsfny")
skeleton = NodePath("../../../../../..")
surface_material_override/0 = SubResource("ShaderMaterial_l1dl0")
[node name="Wind" type="GPUParticles3D" parent="SubViewportContainer/SubViewport/World/Camere/CameraPivot" unique_id=1116712570]
transform = Transform3D(-0.9999765, 4.341205e-08, -0.006824123, -0.006824125, 4.400863e-08, 0.9999762, 4.3711378e-08, 0.99999934, -4.371136e-08, 0, 4.5733867, 21.045607)
cast_shadow = 0
emitting = false
amount = 25
lifetime = 3.0
fixed_fps = 60
process_material = SubResource("ParticleProcessMaterial_6k3cw")
draw_pass_1 = ExtResource("21_l1dl0")
[node name="CameraIso" type="Camera3D" parent="SubViewportContainer/SubViewport/World/Camere/CameraPivot" unique_id=375499667]
transform = Transform3D(0.5778576, -0.57709634, 0.57709634, 0, 0.7071067, 0.7071067, -0.8161376, -0.408607, 0.408607, 231.45, 290, 173.79)

View File

@@ -1,29 +0,0 @@
shader_type canvas_item;
// Colore della tua nebbia (scegli un colore che stia bene col tuo Skybox)
uniform vec4 fog_color : source_color = vec4(0.85, 0.9, 0.95, 1.0);
// Quanto è grande lo spazio pulito al centro per il treno
uniform float clear_center_radius : hint_range(0.0, 1.0) = 0.4;
// Quanto è morbida la sfumatura della nebbia verso i bordi
uniform float edge_softness : hint_range(0.01, 1.0) = 0.5;
// Opacità massima ai bordi estremi dello schermo
uniform float max_opacity : hint_range(0.0, 1.0) = 0.8;
void fragment() {
// Calcola la distanza del pixel dal centro dello schermo (0.5, 0.5)
float dist_from_center = distance(SCREEN_UV, vec2(0.5));
// Crea una maschera morbida circolare
// Al centro (distanza < clear_center) sarà 0.0 (trasparente)
// Verso i bordi salirà dolcemente fino a 1.0 (opaco)
float fog_amount = smoothstep(clear_center_radius, clear_center_radius + edge_softness, dist_from_center);
// Moltiplica per l'opacità massima desiderata
fog_amount *= max_opacity;
// Applica il colore della nebbia solo dove serve
COLOR = vec4(fog_color.rgb, fog_color.a * fog_amount);
}

View File

@@ -1 +0,0 @@
uid://bttmyh64kihyr

View File

@@ -1,85 +0,0 @@
shader_type canvas_item;
uniform sampler2D screen_texture : hint_screen_texture, filter_linear_mipmap;
// --- 1. COLORE E VISIBILITÀ ---
// Ho alzato un po' l'Alpha base per renderli più visibili fin da subito
uniform vec4 dust_color : source_color = vec4(1.0, 0.9, 0.7, 0.6);
// --- 2. VENTO E MOVIMENTO ---
// X negativo = verso sinistra. Y positivo = verso il basso.
uniform vec2 wind_velocity = vec2(-0.2, 0.05);
uniform float wind_oscillation : hint_range(0.0, 1.0) = 0.3;
uniform float dust_speed : hint_range(0.01, 1.0) = 0.15;
// --- 3. DIMENSIONI E DENSITÀ ---
uniform float size_min : hint_range(0.001, 0.1) = 0.02;
uniform float size_max : hint_range(0.01, 0.5) = 0.2;
uniform float dust_density : hint_range(0.01, 10.0) = 1.0;
// --- 4. IL FIX DEL CENTRO (Morbidezza) ---
// 0.0 = Sfumatura totale dal centro esatto fino al bordo.
// 0.5 = Metà pallino è solido, l'altra metà sfuma.
// 0.9 = Pallino dai bordi durissimi.
uniform float solid_core : hint_range(0.0, 0.99) = 0.1;
vec3 hash33(vec3 p3) {
p3 = fract(p3 * vec3(0.1031, 0.1030, 0.0973));
p3 += dot(p3, p3.yzx + 33.33);
return fract((p3.xxy + p3.yzz) * p3.zyx);
}
void fragment() {
vec4 scene_color = texture(screen_texture, SCREEN_UV);
float base_time = TIME * dust_speed;
// Vento con oscillazione naturale
vec2 osc = vec2(sin(TIME * 0.5), cos(TIME * 0.3)) * wind_oscillation;
vec2 final_wind = (wind_velocity + osc) * dust_speed;
float final_particle_alpha = 0.0;
// Configurazione dei 3 strati (Vicino, Medio, Lontano)
vec3 layer_scales = vec3(20.0, 50.0, 100.0) / dust_density;
vec3 layer_thresholds = vec3(0.96, 0.98, 0.99);
vec3 layer_speeds = vec3(1.0, 0.6, 0.3);
for (int i = 0; i < 3; i++) {
float scale = layer_scales[i];
float threshold = layer_thresholds[i];
float speed_mult = layer_speeds[i];
// Spostiamo la griglia con il vento
vec2 st = (SCREEN_UV * scale) - (final_wind * speed_mult * base_time * 50.0);
vec2 ipos = floor(st);
vec2 fpos = fract(st);
vec3 rand = hash33(vec3(ipos, float(i)));
if (rand.z > threshold) {
// Effetto brillio
float blink = sin(TIME * (2.0 + rand.x)) * 0.5 + 0.5;
float d = length(fpos - vec2(0.5));
float size = size_min + (size_max - size_min) * rand.x;
float scaled_size = size * (0.5 + 0.5 * blink);
// --- LA SOLUZIONE "ANTI-CIAMBELLA" ---
// Calcoliamo la grandezza del "nucleo solido" in proporzione alla grandezza totale.
float core = scaled_size * solid_core;
// Se la distanza (d) è minore del 'core', l'opacità è 1.0.
// Se va dal 'core' fino al bordo (scaled_size), sfuma dolcemente verso lo 0.0.
float particle_softness = 1.0 - smoothstep(core, scaled_size, d);
// Uniamo tutto: morbidezza, brillio, e una correzione per l'intensità in base allo strato
float intensity = (rand.z - threshold) / (1.0 - threshold);
final_particle_alpha += particle_softness * blink * intensity;
}
}
final_particle_alpha = clamp(final_particle_alpha, 0.0, 1.0);
vec4 dust_colored_particle = dust_color * final_particle_alpha;
COLOR = scene_color + dust_colored_particle;
}

View File

@@ -1 +0,0 @@
uid://svdmjppqell5

26
Scenes/Wind.gdshader Normal file
View File

@@ -0,0 +1,26 @@
shader_type spatial;
render_mode unshaded;
// --- PARAMETRI ---
uniform float time_scale = 3.0;
uniform float wave_amplitude = 0.5; // Quanto curva a destra/sinistra
uniform float wave_frequency = 1.0; // Ogni quanto fa la curva
void vertex() {
// Creiamo un offset unico per ogni particella in modo che non si muovano tutte uguali
float random_seed_offset = INSTANCE_CUSTOM.x * 100.0;
float scaled_time = (TIME + random_seed_offset) * time_scale;
// Applichiamo SOLO la curva morbida all'asse X (o Z, a seconda di come orienti la scena)
// Usiamo VERTEX.y per far sì che la curva si propaghi lungo tutta la lunghezza della scia
VERTEX.x += sin(VERTEX.y * wave_frequency + scaled_time) * wave_amplitude;
// Niente più "VERTEX.y += t;", quindi niente più teletrasporti!
}
void fragment() {
// Il colore e l'alpha (per lo spawn dolce e la morte lenta)
// vengono comandati dalla Color Ramp del GPUParticles3D!
ALBEDO = COLOR.rgb;
ALPHA = COLOR.a;
}

1
Scenes/Wind.gdshader.uid Normal file
View File

@@ -0,0 +1 @@
uid://ch7g8q4utqci8

26
Scenes/Wind.tscn Normal file
View File

@@ -0,0 +1,26 @@
[gd_scene format=3 uid="uid://btljgq47ug1g5"]
[ext_resource type="Shader" uid="uid://ch7g8q4utqci8" path="res://Scenes/Wind.gdshader" id="1_ceua7"]
[sub_resource type="TubeTrailMesh" id="TubeTrailMesh_d85b2"]
custom_aabb = AABB(20, 20, 20, 0, 0, 0)
radius = 0.04
section_length = 0.5
[sub_resource type="ShaderMaterial" id="ShaderMaterial_uwdnm"]
render_priority = 0
shader = ExtResource("1_ceua7")
shader_parameter/color = Color(1, 1, 1, 0.40392157)
shader_parameter/fade_time = 5.0
shader_parameter/time_scale = 3.0
shader_parameter/wave_amplitude = 0.1
shader_parameter/wave_frequency = 1.0
shader_parameter/wave_length = 2.0
shader_parameter/wave_count = 3.0
shader_parameter/loop_radius = 0.0
shader_parameter/loop_count = 0.0
[node name="MeshInstance3D" type="MeshInstance3D" unique_id=202410879]
transform = Transform3D(1, 0, 0, 0, -4.3711385e-08, -0.9999999, 0, 0.9999999, -4.3711385e-08, 0, 0, 0)
mesh = SubResource("TubeTrailMesh_d85b2")
surface_material_override/0 = SubResource("ShaderMaterial_uwdnm")

View File

@@ -1,17 +0,0 @@
[gd_scene format=3 uid="uid://bdhphg2oi4n1v"]
[ext_resource type="PackedScene" uid="uid://bbdaxcrf48xsr" path="res://Assets/Meshes/House/Test_NoRoof.fbx" id="1_k6nmq"]
[ext_resource type="Material" uid="uid://biaudrjlfoflm" path="res://Materials/House.tres" id="2_si57c"]
[node name="Test_NoRoof" unique_id=1047340045 instance=ExtResource("1_k6nmq")]
[node name="Cube_005" parent="." index="0" unique_id=1082356799]
surface_material_override/0 = ExtResource("2_si57c")
surface_material_override/1 = ExtResource("2_si57c")
surface_material_override/2 = ExtResource("2_si57c")
surface_material_override/3 = ExtResource("2_si57c")
surface_material_override/4 = ExtResource("2_si57c")
surface_material_override/5 = ExtResource("2_si57c")
surface_material_override/6 = ExtResource("2_si57c")
surface_material_override/7 = ExtResource("2_si57c")
surface_material_override/8 = ExtResource("2_si57c")