add fog and effects
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
shader_type spatial;
|
||||
render_mode unshaded, depth_test_disabled, cull_disabled;
|
||||
|
||||
/*
|
||||
uniform sampler2D depth_texture : hint_depth_texture, repeat_disable, filter_nearest;
|
||||
uniform sampler2D noise_texture : repeat_enable, filter_linear;
|
||||
|
||||
@@ -72,4 +71,3 @@ void fragment() {
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
@@ -11,13 +11,26 @@
|
||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_ruhh7"]
|
||||
render_priority = 0
|
||||
shader = ExtResource("2_i3hjl")
|
||||
shader_parameter/cloud_scale = 0.05
|
||||
shader_parameter/cloud_speed = 0.05
|
||||
shader_parameter/direction = Vector2(1, 0.2)
|
||||
shader_parameter/sun_angle = Vector2(0.5, 0.5)
|
||||
shader_parameter/cloud_density = 0.4
|
||||
shader_parameter/center_sharpness = 0.14
|
||||
shader_parameter/shadow_color = Color(0, 0, 0, 1)
|
||||
shader_parameter/opacity_center = 0.5
|
||||
shader_parameter/opacity_edge = 0.2
|
||||
shader_parameter/fade_start = 150.0
|
||||
shader_parameter/fade_end = 300.0
|
||||
shader_parameter/height_fade_start = 10.0
|
||||
shader_parameter/height_fade_end = 50.0
|
||||
|
||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_r4tfj"]
|
||||
transparency = 2
|
||||
alpha_scissor_threshold = 0.0
|
||||
alpha_antialiasing_mode = 0
|
||||
disable_ambient_light = true
|
||||
albedo_color = Color(0.8523133, 0.64268667, 0.43305993, 1)
|
||||
albedo_color = Color(0.07500001, 0.06400001, 0.12100001, 0.39999998)
|
||||
billboard_mode = 3
|
||||
particles_anim_h_frames = 1
|
||||
particles_anim_v_frames = 1
|
||||
@@ -26,14 +39,20 @@ particles_anim_loop = false
|
||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_b5atu"]
|
||||
render_priority = 0
|
||||
shader = ExtResource("2_r4tfj")
|
||||
shader_parameter/use_red_as_alpha = true
|
||||
shader_parameter/fog_color = Color(0.8, 0.85, 0.9, 0.5)
|
||||
shader_parameter/scroll_speed = Vector2(0.05, 0.01)
|
||||
shader_parameter/texture_scale = Vector2(1, 1)
|
||||
shader_parameter/edge_softness_y = 0.2
|
||||
shader_parameter/edge_softness_x = 0.1
|
||||
shader_parameter/night_intensity = 0.0
|
||||
shader_parameter/sun_color = Color(1, 1, 1, 1)
|
||||
|
||||
[sub_resource type="Resource" id="Resource_r4tfj"]
|
||||
script = ExtResource("2_h6hjk")
|
||||
material_fog = SubResource("ShaderMaterial_b5atu")
|
||||
material_drops = SubResource("StandardMaterial3D_r4tfj")
|
||||
material_clouds = SubResource("ShaderMaterial_ruhh7")
|
||||
rain_fade_time = null
|
||||
snow_fade_time = null
|
||||
metadata/_custom_type_script = "uid://butda6k2tli3o"
|
||||
|
||||
[sub_resource type="Gradient" id="Gradient_i3hjl"]
|
||||
@@ -176,7 +195,7 @@ particles_rain = NodePath("Particles_Rain")
|
||||
godray = ExtResource("5_411rw")
|
||||
|
||||
[node name="Particles_Fireflies" type="GPUParticles3D" parent="." unique_id=947538133]
|
||||
visible = false
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 10, 0)
|
||||
emitting = false
|
||||
amount = 60
|
||||
lifetime = 4.0
|
||||
@@ -184,8 +203,7 @@ process_material = SubResource("ParticleProcessMaterial_i3hjl")
|
||||
draw_pass_1 = SubResource("QuadMesh_b5atu")
|
||||
|
||||
[node name="Particles_Wind" type="GPUParticles3D" parent="." unique_id=1238214694]
|
||||
transform = Transform3D(-0.9999756, -8.742171e-08, -0.0069812723, -0.0069812723, -3.051611e-10, 0.9999756, -8.742171e-08, 1, -3.051611e-10, 0, 4.573, 21.04)
|
||||
visible = false
|
||||
transform = Transform3D(-0.9999756, -8.742171e-08, -0.0069812723, -0.0069812723, -3.051611e-10, 0.9999756, -8.742171e-08, 1, -3.051611e-10, 0, 50, 0)
|
||||
emitting = false
|
||||
amount = 100
|
||||
lifetime = 3.0
|
||||
@@ -204,7 +222,6 @@ draw_pass_1 = SubResource("QuadMesh_ruhh7")
|
||||
|
||||
[node name="Particles_Rain" type="GPUParticles3D" parent="." unique_id=1543042897]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 30, 0)
|
||||
visible = false
|
||||
cast_shadow = 0
|
||||
extra_cull_margin = 10.0
|
||||
emitting = false
|
||||
|
||||
@@ -45,20 +45,26 @@ func _ready() -> void:
|
||||
add_child(weather_controller)
|
||||
|
||||
func select_day_time(normalized_time: float) -> void:
|
||||
# Convert 0.0-1.0 normalized time to range used by atmosphere lerps
|
||||
# morning (dawn→noon) = 1.0-2.0, afternoon/night (noon→midnight) = 2.0-3.0
|
||||
if normalized_time < 0.5:
|
||||
# 0.0→0.5 maps to 1.0→2.0 (morning to afternoon)
|
||||
day_time = 1.0 + (normalized_time / 0.5)
|
||||
# 0.0→0.25 = alba: day_time 1.0→2.0 (night colors → morning colors)
|
||||
# 0.25→0.5 = giorno: day_time 2.0→2.0 (stays morning/afternoon)
|
||||
# 0.5→0.75 = tramonto: day_time 2.0→3.0 (afternoon colors → night colors)
|
||||
# 0.75→1.0 = notte: day_time 3.0→3.0 (stays night)
|
||||
# At wrap 1.0→0.0: day_time stays 3.0, then fades back via alba
|
||||
|
||||
if normalized_time < 0.25:
|
||||
# Alba: notte → mattina
|
||||
day_time = 3.0 - (normalized_time / 0.25) * 2.0 # 3.0 → 1.0
|
||||
elif normalized_time < 0.5:
|
||||
# Giorno pieno
|
||||
var t: float = (normalized_time - 0.25) / 0.25
|
||||
day_time = 1.0 + t # 1.0 → 2.0
|
||||
elif normalized_time < 0.75:
|
||||
# Tramonto: pomeriggio → notte
|
||||
var t: float = (normalized_time - 0.5) / 0.25
|
||||
day_time = 2.0 + t # 2.0 → 3.0
|
||||
else:
|
||||
# 0.5→1.0 maps to 2.0→3.0 (afternoon to night)
|
||||
day_time = 2.0 + ((normalized_time - 0.5) / 0.5)
|
||||
|
||||
if day_tween and day_tween.is_valid():
|
||||
day_tween.kill()
|
||||
day_tween = create_tween()
|
||||
day_tween.set_trans(Tween.TRANS_SINE).set_ease(Tween.EASE_IN_OUT)
|
||||
day_tween.tween_property(self, "day_time", day_time, 3.0)
|
||||
# Notte piena
|
||||
day_time = 3.0
|
||||
|
||||
if weather_controller:
|
||||
weather_controller.day_time = day_time
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
shader_type spatial;
|
||||
render_mode unshaded, depth_draw_never, cull_disabled, blend_mix;
|
||||
/*
|
||||
|
||||
group_uniforms TextureCheck;
|
||||
uniform sampler2D fog_noise : repeat_enable, filter_linear_mipmap;
|
||||
uniform bool use_red_as_alpha = true;
|
||||
@@ -37,4 +37,4 @@ void fragment() {
|
||||
ALBEDO = mix(tinted_fog, dark_fog, night_intensity);
|
||||
|
||||
ALPHA = fog_color.a * noise_alpha * edge_mask;
|
||||
}*/
|
||||
}
|
||||
@@ -75,9 +75,10 @@ func _process(delta: float) -> void:
|
||||
var base_grad_intensity: float
|
||||
var base_rotation_sun: Vector3
|
||||
|
||||
var storm_is_active = is_raining and is_snowing
|
||||
|
||||
if storm_is_active:
|
||||
var is_storm = is_raining and is_snowing
|
||||
var is_night = day_time >= 2.5
|
||||
|
||||
if is_storm:
|
||||
rain_intensity = move_toward(rain_intensity, 1.0, delta * 0.5)
|
||||
if is_raining:
|
||||
timer_next_lightning -= delta
|
||||
@@ -155,10 +156,10 @@ func _process(delta: float) -> void:
|
||||
if sun:
|
||||
sun.light_color = final_tint
|
||||
sun.rotation_degrees = base_rotation_sun
|
||||
#var target_energy = lerp(1.0, night_light_energy, night_val)
|
||||
var target_energy = lerp(1.0, environment_config.night_light_energy, night_val)
|
||||
|
||||
# Sunlight scales normally based on weather/night (global exposure does the rest of the work)
|
||||
#sun.light_energy = lerp(target_energy, target_energy * 0.4, rain_intensity)
|
||||
# Sunlight scales based on weather/night
|
||||
sun.light_energy = lerp(target_energy, target_energy * 0.4, rain_intensity)
|
||||
|
||||
if environment and environment.environment:
|
||||
environment.environment.ambient_light_color = final_tint
|
||||
@@ -185,21 +186,14 @@ func _process(delta: float) -> void:
|
||||
if environment_config.material_fog:
|
||||
environment_config.material_fog.set_shader_parameter("night_intensity", night_val)
|
||||
environment_config.material_fog.set_shader_parameter("sun_color", final_tint)
|
||||
|
||||
var e_night = day_time >= 2.5
|
||||
|
||||
#if nodo_polvere:
|
||||
#nodo_polvere.visible = (not storm_is_active and not e_night)
|
||||
|
||||
if particles_fireflies:
|
||||
particles_fireflies.emitting = (not storm_is_active and e_night and thereare_fireflies)
|
||||
|
||||
if particles_wind:
|
||||
particles_wind.emitting = (not storm_is_active and not e_night and is_windy)
|
||||
|
||||
#region fireflies
|
||||
|
||||
func toggle_fireflies(value: bool):
|
||||
thereare_fireflies = value
|
||||
if particles_fireflies:
|
||||
particles_fireflies.emitting = thereare_fireflies
|
||||
|
||||
#disable fireflies and set default values and materials
|
||||
func set_fireflies():
|
||||
@@ -210,11 +204,18 @@ func set_fireflies():
|
||||
var proc_mat = particles_fireflies.process_material as ParticleProcessMaterial
|
||||
if proc_mat:
|
||||
proc_mat.emission_box_extents = Vector3(environment_config.fireflies_spawn_ray, environment_config.fireflies_spawn_height, environment_config.fireflies_spawn_ray)
|
||||
|
||||
#endregion
|
||||
|
||||
#region Wind
|
||||
|
||||
func toggle_wind(value: bool):
|
||||
is_windy = value
|
||||
var is_storm = is_raining and is_snowing
|
||||
var is_night = day_time >= 2.5
|
||||
|
||||
if particles_wind:
|
||||
particles_wind.emitting = (not is_storm and not is_night and is_windy)
|
||||
|
||||
#disable wind and set default values and materials
|
||||
func set_wind():
|
||||
@@ -225,6 +226,7 @@ func set_wind():
|
||||
var proc_mat_wind = particles_wind.process_material as ParticleProcessMaterial
|
||||
if proc_mat_wind:
|
||||
proc_mat_wind.emission_box_extents = Vector3(environment_config.wind_spawn_ray, environment_config.wind_spawn_height, environment_config.wind_spawn_ray)
|
||||
|
||||
#endregion
|
||||
|
||||
#region Lightning
|
||||
@@ -423,30 +425,3 @@ func set_snow_amount(value: float):
|
||||
RenderingServer.global_shader_parameter_set("global_snow_amount", value)
|
||||
|
||||
#endregion
|
||||
|
||||
#func _genera_evento_meteo_casuale() -> void:
|
||||
#sto_cambiando_in_cinematic = true
|
||||
#
|
||||
#var scelta = randi() % 3
|
||||
#
|
||||
#if scelta == 0:
|
||||
#var nuovo_orario = randi() % 3
|
||||
#if menu_giornata:
|
||||
#menu_giornata.selected = nuovo_orario
|
||||
#_on_giornata_selezionata(nuovo_orario)
|
||||
#
|
||||
#elif scelta == 1:
|
||||
#if not is_snowing:
|
||||
#var piove = randf() > 0.5
|
||||
#if bottone_pioggia:
|
||||
#bottone_pioggia.set_pressed_no_signal(piove)
|
||||
#_on_pioggia_toggled(piove)
|
||||
#
|
||||
#elif scelta == 2:
|
||||
#if not is_snowing:
|
||||
#if not is_raining:
|
||||
#if bottone_pioggia:
|
||||
#bottone_pioggia.set_pressed_no_signal(true)
|
||||
#_on_pioggia_toggled(true)
|
||||
#_scatena_fulmine()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user