add rain sound
This commit is contained in:
@@ -216,8 +216,8 @@ point_count = 6
|
||||
[sub_resource type="Resource" id="Resource_dfjcy"]
|
||||
script = ExtResource("8_cnx2n")
|
||||
cloud_density = 0.1
|
||||
cloud_opacity = 0.6
|
||||
cloud_coverage = 0.2
|
||||
cloud_opacity = 0.1
|
||||
cloud_coverage = 0.1
|
||||
wind_speed = 0.5
|
||||
|
||||
[sub_resource type="Resource" id="Resource_sjmt0"]
|
||||
@@ -254,6 +254,7 @@ ambient_intensity_multiplier = 0.6
|
||||
fog_density_multiplier = 2.0
|
||||
rain_intensity = 0.7
|
||||
lightning_enabled = true
|
||||
lightning_frequency = 0.002
|
||||
default_transition_duration = 8.0
|
||||
|
||||
[sub_resource type="Resource" id="Resource_mr14h"]
|
||||
@@ -345,7 +346,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.7679742411724282
|
||||
time_of_day = 0.9185125217273991
|
||||
current_day = 4
|
||||
sun_color_curve = SubResource("Gradient_sxvon")
|
||||
sun_intensity_curve = SubResource("Curve_fm80q")
|
||||
@@ -368,12 +369,12 @@ transition_curve = SubResource("Curve_uhdsh")
|
||||
[node name="CloudSystem" type="Node3D" parent="." unique_id=680200253]
|
||||
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_coverage = 0.1
|
||||
global_wind_speed = 0.5
|
||||
sun_direction = Vector3(-0.99265814, -0.112351425, -0.04480003)
|
||||
sun_direction = Vector3(-0.46286085, -0.82338524, -0.32832408)
|
||||
sun_color = Color(1, 0.95, 0.85, 1)
|
||||
sun_intensity = 1.2
|
||||
moon_direction = Vector3(-0.9932351, 0.11241673, 0.029095592)
|
||||
moon_direction = Vector3(-0.4780105, 0.85033494, 0.22008288)
|
||||
moon_color = Color(0.8, 0.85, 1, 1)
|
||||
moon_intensity = 0.0
|
||||
|
||||
@@ -385,18 +386,18 @@ 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.6533633, 0.5148431, 0.4713005, 1)
|
||||
fog_density = 0.015073524
|
||||
fog_color = Color(0.26191625, 0.21975225, 0.23041001, 1)
|
||||
fog_density = 0.018752154
|
||||
sun_glow_intensity = 0.3
|
||||
sun_glow_color = Color(1, 0.95, 0.85, 1)
|
||||
sun_direction = Vector3(-0.99265814, -0.112351425, -0.04480003)
|
||||
sun_direction = Vector3(-0.46286085, -0.82338524, -0.32832408)
|
||||
|
||||
[node name="VFXController" type="Node3D" parent="." unique_id=207251300]
|
||||
script = ExtResource("7_vfx")
|
||||
|
||||
[node name="ShadowProxySystem" type="Node3D" parent="." unique_id=1982828842]
|
||||
script = ExtResource("8_shadows")
|
||||
shadow_opacity = 0.1
|
||||
shadow_opacity = 0.05
|
||||
flow_speed = 2.5
|
||||
|
||||
[node name="WorldEnvironment" type="WorldEnvironment" parent="." unique_id=700760798]
|
||||
@@ -404,14 +405,14 @@ environment = ExtResource("13_2w5ig")
|
||||
compositor = SubResource("Compositor_ssi15")
|
||||
|
||||
[node name="SunLight" type="DirectionalLight3D" parent="." unique_id=1278065589]
|
||||
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
|
||||
transform = Transform3D(-0.5785618, 0.8155839, -0.009411784, 0, 0.011539156, 0.99993366, 0.8156382, 0.5785233, -0.00667612, 0, 50, 0)
|
||||
visible = false
|
||||
light_color = Color(1, 0.9021925, 0.804385, 1)
|
||||
light_energy = 0.0
|
||||
shadow_enabled = true
|
||||
|
||||
[node name="MoonLight" type="DirectionalLight3D" parent="." unique_id=52072807]
|
||||
transform = Transform3D(0.029281195, 0.99937487, -0.01981562, 0, 0.019824117, 0.9998037, 0.999571, -0.02927545, 0.00058047404, 0, 50, 0)
|
||||
visible = false
|
||||
transform = Transform3D(0.41821608, 0.90829885, -0.009398041, 0, 0.010346303, 0.9999467, 0.90834737, -0.41819376, 0.004326992, 0, 50, 0)
|
||||
light_color = Color(0.7, 0.8, 1, 1)
|
||||
light_energy = 0.0
|
||||
light_energy = 0.29958928
|
||||
light_indirect_energy = 1.979
|
||||
|
||||
@@ -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.99265814, -0.112351425, -0.04480003)
|
||||
shader_parameter/sun_direction = Vector3(-0.46286085, -0.82338524, -0.32832408)
|
||||
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.5162781, 0.4713005, 0.523453, 1)
|
||||
ambient_light_energy = 0.32816777
|
||||
ambient_light_color = Color(0.23323175, 0.23041001, 0.30062926, 1)
|
||||
ambient_light_energy = 0.078244984
|
||||
fog_enabled = true
|
||||
fog_light_color = Color(0.6533633, 0.5148431, 0.4713005, 1)
|
||||
fog_density = 0.015073524
|
||||
fog_light_color = Color(0.26191625, 0.21975225, 0.23041001, 1)
|
||||
fog_density = 0.018752154
|
||||
fog_height_density = 0.1
|
||||
|
||||
@@ -94,7 +94,7 @@ static func create_rain() -> WeatherProfile:
|
||||
profile.fog_density_multiplier = 2.0
|
||||
profile.rain_intensity = 0.7
|
||||
profile.lightning_enabled = true
|
||||
profile.lightning_frequency = 0.04
|
||||
profile.lightning_frequency = 0.008
|
||||
profile.default_transition_duration = 8.0
|
||||
return profile
|
||||
|
||||
|
||||
@@ -53,7 +53,6 @@ extends Node
|
||||
@export var effects_enabled: bool = true
|
||||
|
||||
var _sky_material: ShaderMaterial
|
||||
var _post_process_quad: MeshInstance3D
|
||||
var _moon_direction: Vector3 = Vector3(0.0, -1.0, 0.0)
|
||||
var _moon_color: Color = Color(0.9, 0.92, 1.0)
|
||||
var _moon_intensity: float = 0.0
|
||||
|
||||
@@ -41,11 +41,9 @@ signal meteor_shower_ended()
|
||||
|
||||
var _spawn_timer: float = 0.0
|
||||
var _next_spawn_time: float = 0.0
|
||||
var _meteor_timer: float = 0.0
|
||||
var _meteor_spawn_accumulator: float = 0.0
|
||||
var _meteor_shower_elapsed: float = 0.0
|
||||
var _active_stars: Array[Dictionary] = []
|
||||
var _star_mesh: MeshInstance3D
|
||||
var _star_material: ShaderMaterial
|
||||
var _is_night: bool = false
|
||||
|
||||
@@ -185,10 +183,10 @@ func _get_random_fall_direction() -> Vector3:
|
||||
var base_dir := Vector3(-0.5, -0.8, -0.3).normalized()
|
||||
|
||||
var variance := deg_to_rad(spawn_direction_variance)
|
||||
var rotation := Basis(Vector3.UP, randf() * TAU)
|
||||
rotation = rotation.rotated(Vector3.RIGHT, randf_range(-variance, variance))
|
||||
var curr_rotation := Basis(Vector3.UP, randf() * TAU)
|
||||
curr_rotation = curr_rotation.rotated(Vector3.RIGHT, randf_range(-variance, variance))
|
||||
|
||||
return (rotation * base_dir).normalized()
|
||||
return (curr_rotation * base_dir).normalized()
|
||||
|
||||
|
||||
func _create_star_trail(position: Vector3, direction: Vector3, is_meteor: bool = false) -> MeshInstance3D:
|
||||
|
||||
@@ -19,6 +19,11 @@ extends Node3D
|
||||
@export var lightning_color: Color = Color(0.9, 0.9, 1.0)
|
||||
@export var lightning_flash_duration: float = 0.15
|
||||
|
||||
@export_group("Rain Audio")
|
||||
@export var rain_audio_enabled: bool = true
|
||||
@export var rain_volume_db_max: float = 0.0
|
||||
@export var rain_crossfade_threshold: float = 0.5
|
||||
|
||||
@export_group("Thunder")
|
||||
@export var thunder_enabled: bool = true
|
||||
@export var thunder_min_delay: float = 1.0
|
||||
@@ -42,6 +47,8 @@ var _lightning_light: DirectionalLight3D
|
||||
var _thunder_player: AudioStreamPlayer
|
||||
var _thunder_pending: bool = false
|
||||
var _thunder_delay_timer: float = 0.0
|
||||
var _rain_light_player: AudioStreamPlayer
|
||||
var _rain_hard_player: AudioStreamPlayer
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
@@ -49,6 +56,7 @@ func _ready() -> void:
|
||||
_create_snow_system()
|
||||
_create_lightning_light()
|
||||
_create_thunder_player()
|
||||
_create_rain_audio_players()
|
||||
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
@@ -67,6 +75,7 @@ func _process(delta: float) -> void:
|
||||
|
||||
_process_lightning(delta)
|
||||
_process_thunder(delta)
|
||||
_process_rain_audio()
|
||||
_follow_camera()
|
||||
|
||||
|
||||
@@ -130,6 +139,66 @@ func _create_thunder_player() -> void:
|
||||
add_child(_thunder_player)
|
||||
|
||||
|
||||
func _create_rain_audio_players() -> void:
|
||||
_rain_light_player = AudioStreamPlayer.new()
|
||||
_rain_light_player.name = "RainLightPlayer"
|
||||
_rain_light_player.volume_db = -80.0
|
||||
_rain_light_player.bus = "Master"
|
||||
_rain_light_player.stream = load("res://resources/rain_light.mp3")
|
||||
add_child(_rain_light_player)
|
||||
|
||||
_rain_hard_player = AudioStreamPlayer.new()
|
||||
_rain_hard_player.name = "RainHardPlayer"
|
||||
_rain_hard_player.volume_db = -80.0
|
||||
_rain_hard_player.bus = "Master"
|
||||
_rain_hard_player.stream = load("res://resources/rain_gentle.mp3")
|
||||
add_child(_rain_hard_player)
|
||||
|
||||
|
||||
func _process_rain_audio() -> void:
|
||||
if not rain_audio_enabled:
|
||||
if _rain_light_player.playing:
|
||||
_rain_light_player.stop()
|
||||
if _rain_hard_player.playing:
|
||||
_rain_hard_player.stop()
|
||||
return
|
||||
|
||||
if _current_rain < 0.01:
|
||||
if _rain_light_player.playing:
|
||||
_rain_light_player.stop()
|
||||
if _rain_hard_player.playing:
|
||||
_rain_hard_player.stop()
|
||||
return
|
||||
|
||||
# Below threshold: only light rain plays, volume scales linearly 0 → max
|
||||
# Above threshold: light rain fades out, hard rain fades in
|
||||
if _current_rain <= rain_crossfade_threshold:
|
||||
# Light rain: volume from 0 to max based on percentage within the range
|
||||
var light_vol := _current_rain / rain_crossfade_threshold
|
||||
_set_rain_player(_rain_light_player, light_vol)
|
||||
_stop_rain_player(_rain_hard_player)
|
||||
else:
|
||||
# Crossfade zone: light fades out, hard fades in
|
||||
var t := (_current_rain - rain_crossfade_threshold) / (1.0 - rain_crossfade_threshold)
|
||||
_set_rain_player(_rain_light_player, 1.0 - t)
|
||||
_set_rain_player(_rain_hard_player, t)
|
||||
|
||||
|
||||
func _set_rain_player(player: AudioStreamPlayer, weight: float) -> void:
|
||||
if weight < 0.001:
|
||||
_stop_rain_player(player)
|
||||
return
|
||||
if not player.playing:
|
||||
player.volume_db = -80.0
|
||||
player.play()
|
||||
player.volume_db = lerpf(-80.0, rain_volume_db_max, weight)
|
||||
|
||||
|
||||
func _stop_rain_player(player: AudioStreamPlayer) -> void:
|
||||
if player.playing:
|
||||
player.stop()
|
||||
|
||||
|
||||
func _create_lightning_light() -> void:
|
||||
_lightning_light = DirectionalLight3D.new()
|
||||
_lightning_light.name = "LightningFlash"
|
||||
|
||||
BIN
resources/rain_gentle.mp3
Normal file
BIN
resources/rain_gentle.mp3
Normal file
Binary file not shown.
BIN
resources/rain_light.mp3
Normal file
BIN
resources/rain_light.mp3
Normal file
Binary file not shown.
Reference in New Issue
Block a user