add fog and effects

This commit is contained in:
2026-03-24 20:23:47 +01:00
parent 36d6f29fd3
commit 5af1ba0ba8
6 changed files with 64 additions and 67 deletions

View File

@@ -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.02.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