diff --git a/dynamic-sky/dynamic_sky.tscn b/dynamic-sky/dynamic_sky.tscn index 633e81f..3fff07b 100644 --- a/dynamic-sky/dynamic_sky.tscn +++ b/dynamic-sky/dynamic_sky.tscn @@ -253,6 +253,7 @@ wind_speed = 2.0 ambient_intensity_multiplier = 0.6 fog_density_multiplier = 2.0 rain_intensity = 0.7 +lightning_enabled = true default_transition_duration = 8.0 [sub_resource type="Resource" id="Resource_mr14h"] @@ -344,7 +345,7 @@ presets = Array[ExtResource("3_c6jpa")]([SubResource("Resource_ajt3x"), SubResou [node name="DayNightController" type="Node" parent="." unique_id=1083149574] script = ExtResource("3_day_night") -time_of_day = 0.6330777230246745 +time_of_day = 0.7679742411724282 current_day = 4 sun_color_curve = SubResource("Gradient_sxvon") sun_intensity_curve = SubResource("Curve_fm80q") @@ -369,10 +370,10 @@ script = ExtResource("5_clouds") layer_configs = Array[ExtResource("4_ssi15")]([SubResource("Resource_xh4oc"), SubResource("Resource_ahi10"), SubResource("Resource_a5xai"), SubResource("Resource_uxs4q")]) global_coverage = 0.2 global_wind_speed = 0.5 -sun_direction = Vector3(-0.71683276, 0.6476549, 0.25825176) +sun_direction = Vector3(-0.99265814, -0.112351425, -0.04480003) sun_color = Color(1, 0.95, 0.85, 1) sun_intensity = 1.2 -moon_direction = Vector3(-0.7310799, -0.6605271, -0.17095698) +moon_direction = Vector3(-0.9932351, 0.11241673, 0.029095592) moon_color = Color(0.8, 0.85, 1, 1) moon_intensity = 0.0 @@ -384,11 +385,11 @@ sky_top_color = Color(0.2, 0.4, 0.85, 1) sky_horizon_color = Color(0.6, 0.75, 0.95, 1) sky_bottom_color = Color(0.5, 0.6, 0.7, 1) skybox_texture = ExtResource("6_ssi15") -fog_color = Color(0.7, 0.64355034, 0.6637131, 1) -fog_density = 0.012741526 +fog_color = Color(0.6533633, 0.5148431, 0.4713005, 1) +fog_density = 0.015073524 sun_glow_intensity = 0.3 sun_glow_color = Color(1, 0.95, 0.85, 1) -sun_direction = Vector3(-0.71683276, 0.6476549, 0.25825176) +sun_direction = Vector3(-0.99265814, -0.112351425, -0.04480003) [node name="VFXController" type="Node3D" parent="." unique_id=207251300] script = ExtResource("7_vfx") @@ -403,13 +404,13 @@ environment = ExtResource("13_2w5ig") compositor = SubResource("Compositor_ssi15") [node name="SunLight" type="DirectionalLight3D" parent="." unique_id=1278065589] -transform = Transform3D(0.33894238, 0.9407005, -0.014151112, 0, 0.015041453, 0.9998871, 0.9408068, -0.33890405, 0.0050981897, 0, 50, 0) -light_color = Color(1, 0.84032553, 0.65726346, 1) -light_energy = 0.58916044 +transform = Transform3D(-0.04508543, 0.9987848, -0.019893857, 0, 0.019914096, 0.99980193, 0.99898285, 0.045076493, -0.00089783635, 0, 50, 0) +light_color = Color(1, 0.7215246, 0.44304925, 1) +light_energy = 0.31373072 shadow_enabled = true [node name="MoonLight" type="DirectionalLight3D" parent="." unique_id=52072807] -transform = Transform3D(-0.22769909, 0.9736189, -0.014815218, 0, 0.015214887, 0.9998845, 0.9737314, 0.22767279, -0.0034644168, 0, 50, 0) +transform = Transform3D(0.029281195, 0.99937487, -0.01981562, 0, 0.019824117, 0.9998037, 0.999571, -0.02927545, 0.00058047404, 0, 50, 0) visible = false light_color = Color(0.7, 0.8, 1, 1) light_energy = 0.0 diff --git a/dynamic-sky/environment.tres b/dynamic-sky/environment.tres index 7c69b29..335260d 100644 --- a/dynamic-sky/environment.tres +++ b/dynamic-sky/environment.tres @@ -110,7 +110,7 @@ shader_parameter/sky_bottom_color = Color(0.5, 0.6, 0.7, 1) shader_parameter/gradient_intensity = 1.0 shader_parameter/horizon_blend = 0.5 shader_parameter/sun_glow_enabled = true -shader_parameter/sun_direction = Vector3(-0.71683276, 0.6476549, 0.25825176) +shader_parameter/sun_direction = Vector3(-0.99265814, -0.112351425, -0.04480003) shader_parameter/sun_glow_color = Color(1, 0.95, 0.85, 1) shader_parameter/sun_glow_intensity = 0.3 shader_parameter/sun_glow_size = 0.2 @@ -128,9 +128,9 @@ sky_material = SubResource("ShaderMaterial_jmmec") [resource] background_mode = 2 sky = SubResource("Sky_ssi15") -ambient_light_color = Color(0.5733876, 0.5701628, 0.64355034, 1) -ambient_light_energy = 0.52610695 +ambient_light_color = Color(0.5162781, 0.4713005, 0.523453, 1) +ambient_light_energy = 0.32816777 fog_enabled = true -fog_light_color = Color(0.7, 0.64355034, 0.6637131, 1) -fog_density = 0.012741526 +fog_light_color = Color(0.6533633, 0.5148431, 0.4713005, 1) +fog_density = 0.015073524 fog_height_density = 0.1 diff --git a/dynamic-sky/resources/weather_profile.gd b/dynamic-sky/resources/weather_profile.gd index 1dbac94..b01b265 100644 --- a/dynamic-sky/resources/weather_profile.gd +++ b/dynamic-sky/resources/weather_profile.gd @@ -93,6 +93,8 @@ static func create_rain() -> WeatherProfile: profile.ambient_intensity_multiplier = 0.6 profile.fog_density_multiplier = 2.0 profile.rain_intensity = 0.7 + profile.lightning_enabled = true + profile.lightning_frequency = 0.04 profile.default_transition_duration = 8.0 return profile diff --git a/dynamic-sky/scripts/dynamic_sky_root.gd b/dynamic-sky/scripts/dynamic_sky_root.gd index 57d1155..112bbe0 100644 --- a/dynamic-sky/scripts/dynamic_sky_root.gd +++ b/dynamic-sky/scripts/dynamic_sky_root.gd @@ -465,6 +465,10 @@ func _sync_weather_vfx() -> void: return weather_vfx.set_rain_intensity(weather_controller.get_rain_intensity()) weather_vfx.set_snow_intensity(weather_controller.get_snow_intensity()) + weather_vfx.set_lightning( + weather_controller.is_lightning_active(), + weather_controller.get_lightning_frequency() + ) func _update_debug_info() -> void: diff --git a/dynamic-sky/scripts/weather_vfx.gd b/dynamic-sky/scripts/weather_vfx.gd index d651ac7..f68c7bc 100644 --- a/dynamic-sky/scripts/weather_vfx.gd +++ b/dynamic-sky/scripts/weather_vfx.gd @@ -19,6 +19,12 @@ extends Node3D @export var lightning_color: Color = Color(0.9, 0.9, 1.0) @export var lightning_flash_duration: float = 0.15 +@export_group("Thunder") +@export var thunder_enabled: bool = true +@export var thunder_min_delay: float = 1.0 +@export var thunder_max_delay: float = 5.0 +@export var thunder_volume_db: float = -2.0 + var _rain_particles: GPUParticles3D var _snow_particles: GPUParticles3D var _rain_material: ShaderMaterial @@ -33,12 +39,16 @@ var _lightning_timer: float = 0.0 var _lightning_next: float = 0.0 var _lightning_flash_timer: float = 0.0 var _lightning_light: DirectionalLight3D +var _thunder_player: AudioStreamPlayer +var _thunder_pending: bool = false +var _thunder_delay_timer: float = 0.0 func _ready() -> void: _create_rain_system() _create_snow_system() _create_lightning_light() + _create_thunder_player() func _process(delta: float) -> void: @@ -56,6 +66,7 @@ func _process(delta: float) -> void: _snow_material.set_shader_parameter("alpha_mult", _current_snow) _process_lightning(delta) + _process_thunder(delta) _follow_camera() @@ -87,6 +98,36 @@ func _trigger_lightning() -> void: _lightning_light.visible = true _lightning_light.rotation_degrees.x = randf_range(-80.0, -50.0) _lightning_light.rotation_degrees.y = randf_range(-180.0, 180.0) + + if thunder_enabled: + _thunder_pending = true + _thunder_delay_timer = randf_range(thunder_min_delay, thunder_max_delay) + + +func _process_thunder(delta: float) -> void: + if not _thunder_pending: + return + + _thunder_delay_timer -= delta + if _thunder_delay_timer <= 0.0: + _thunder_pending = false + _play_thunder() + + +func _play_thunder() -> void: + if _thunder_player == null: + return + + _thunder_player.play() + + +func _create_thunder_player() -> void: + _thunder_player = AudioStreamPlayer.new() + _thunder_player.name = "ThunderPlayer" + _thunder_player.volume_db = thunder_volume_db + _thunder_player.bus = "Master" + _thunder_player.stream = load("res://resources/thunder.mp3") + add_child(_thunder_player) func _create_lightning_light() -> void: diff --git a/resources/thunder.mp3 b/resources/thunder.mp3 new file mode 100644 index 0000000..ef577d6 Binary files /dev/null and b/resources/thunder.mp3 differ