add blur - fog - dust
This commit is contained in:
@@ -24,6 +24,8 @@ extends Node3D
|
||||
@export var materiale_nebbia: ShaderMaterial
|
||||
@export var materiale_pioggia_gocce: StandardMaterial3D
|
||||
@export var materiale_nuvole: ShaderMaterial
|
||||
# --- NUOVO: SLOT NODO POLVERE ---
|
||||
@export var nodo_polvere: ColorRect
|
||||
|
||||
@export_group("Meteo (Pioggia & Fulmini)")
|
||||
@export var colore_mood_pioggia: Color = Color(0.5, 0.6, 0.7, 1.0)
|
||||
@@ -38,23 +40,13 @@ extends Node3D
|
||||
@export_group("Cinematic Mode Ambiente")
|
||||
@export var intervallo_eventi_meteo: float = 8.0
|
||||
|
||||
# --- NUOVO: PARAMETRI GOD RAYS ---
|
||||
@export_group("God Rays")
|
||||
@export var godray_scene: PackedScene
|
||||
@export var max_rain_godrays: int = 8
|
||||
@export var godray_spawn_radius: float = 15.0
|
||||
|
||||
# --- NUOVE VARIABILI PER L'ISOMETRICA ---
|
||||
# Sposta il centro in cui nascono i raggi (es. più a destra e più in alto)
|
||||
@export var godray_spawn_offset: Vector3 = Vector3(15.0, 5.0, -15.0)
|
||||
# Incliniamo i raggi per farli spiovere dall'alto a destra.
|
||||
# (X negativa li inclina in avanti, Z li fa "stendere" diagonalmente sullo schermo)
|
||||
@export var godray_rotation_degrees: Vector3 = Vector3(-45.0, 45.0, -30.0)
|
||||
|
||||
# Quanto in alto rispetto al suolo/treno devono nascere
|
||||
@export var godray_spawn_height: float = 5.0
|
||||
|
||||
# Quanto devono essere lunghi i raggi (scala Y) e larghi (scala X)
|
||||
@export var godray_scale: Vector3 = Vector3(2.0, 6.0, 2.0)
|
||||
|
||||
@onready var sole: DirectionalLight3D = $DirectionalLight3D
|
||||
@@ -62,10 +54,7 @@ extends Node3D
|
||||
@onready var menu_giornata: OptionButton = $CanvasLayer/OptionButton
|
||||
@onready var bottone_pioggia: CheckButton = $CanvasLayer/CheckButtonPioggia
|
||||
@onready var particelle_pioggia: GPUParticles3D = $SubViewportContainer/SubViewport/World/Camere/PioggiaCadente
|
||||
|
||||
# --- NUOVO: RIFERIMENTO AL NODO DELLE CAMERE PER FARLI MUOVERE COL TRENO ---
|
||||
@onready var nodo_camere: Node3D = $SubViewportContainer/SubViewport/World/Camere
|
||||
|
||||
@onready var luce_lampo: DirectionalLight3D = $LuceLampo
|
||||
@onready var sprite_fulmine: Sprite3D = $SubViewportContainer/SubViewport/World/Camere/SpriteFulmine
|
||||
|
||||
@@ -123,7 +112,6 @@ func _on_giornata_selezionata(index: int) -> void:
|
||||
tween_giorno.set_trans(Tween.TRANS_SINE).set_ease(Tween.EASE_IN_OUT)
|
||||
tween_giorno.tween_property(self, "tempo_giorno", target_tempo, durata_transizione)
|
||||
|
||||
# --- NUOVO: SE E' MATTINA (Index 0), SPAWNA IL GODRAY ---
|
||||
if index == 0:
|
||||
trigger_morning()
|
||||
|
||||
@@ -132,14 +120,11 @@ func _on_pioggia_toggled(toggled_on: bool) -> void:
|
||||
is_cinematic_mode = false
|
||||
print("Ambiente Cinematic: DISATTIVATA (Pioggia cambiata manualmente)")
|
||||
|
||||
# --- NUOVO: SALVIAMO LO STATO PRECEDENTE PER CAPIRE SE HA SMESSO ---
|
||||
var stava_piovendo = is_raining
|
||||
|
||||
is_raining = toggled_on
|
||||
if particelle_pioggia:
|
||||
particelle_pioggia.emitting = is_raining
|
||||
|
||||
# --- NUOVO: SE STAVA PIOVENDO E ORA NON PIOVE PIÙ, SPAWNA TANTI GODRAYS ---
|
||||
if stava_piovendo and not is_raining:
|
||||
trigger_after_rain()
|
||||
|
||||
@@ -213,6 +198,18 @@ func _process(delta: float) -> void:
|
||||
materiale_nebbia.set_shader_parameter("night_intensity", night_val)
|
||||
materiale_nebbia.set_shader_parameter("sun_color", final_tint)
|
||||
|
||||
# ==========================================
|
||||
# --- NUOVO: GESTIONE POLVERE INFALLIBILE ---
|
||||
# ==========================================
|
||||
if nodo_polvere:
|
||||
var e_notte = tempo_giorno >= 2.5
|
||||
|
||||
# Accende/Spegne brutalmente il nodo
|
||||
if not is_raining and not e_notte:
|
||||
nodo_polvere.visible = true
|
||||
else:
|
||||
nodo_polvere.visible = false
|
||||
|
||||
func _genera_evento_meteo_casuale() -> void:
|
||||
sto_cambiando_in_cinematic = true
|
||||
|
||||
@@ -275,16 +272,10 @@ func _scatena_fulmine() -> void:
|
||||
if numero_scariche > 1:
|
||||
await get_tree().create_timer(randf_range(0.05, 0.15)).timeout
|
||||
|
||||
# ==========================================
|
||||
# --- FUNZIONI GOD RAYS INTEGRATE ---
|
||||
# ==========================================
|
||||
|
||||
func trigger_morning() -> void:
|
||||
# Quando è mattina spara un solo godray vicino al treno
|
||||
spawn_single_godray()
|
||||
|
||||
func trigger_after_rain() -> void:
|
||||
# Evitiamo di farli spawnare se piove di notte (tempo_giorno >= 2.5)
|
||||
if tempo_giorno < 2.5:
|
||||
for i in range(max_rain_godrays):
|
||||
spawn_single_godray()
|
||||
@@ -299,23 +290,12 @@ func spawn_single_godray() -> void:
|
||||
|
||||
var ray = godray_scene.instantiate()
|
||||
|
||||
# --- LA MAGIA È QUI ---
|
||||
# Invece di aggiungerli a "nodo_camere" (che si muove),
|
||||
# li aggiungiamo al genitore delle camere (il nodo "World"), che è fermo!
|
||||
var nodo_mondo = nodo_camere.get_parent()
|
||||
nodo_mondo.add_child(ray)
|
||||
|
||||
# Calcoliamo una posizione casuale
|
||||
var random_x = randf_range(-godray_spawn_radius, godray_spawn_radius)
|
||||
var random_z = randf_range(-godray_spawn_radius, godray_spawn_radius)
|
||||
|
||||
# Usiamo la GLOBAL_POSITION: Il raggio prende le coordinate globali di dov'è la
|
||||
# telecamera in QUESTO preciso millisecondo, e ci aggiunge il suo offset casuale.
|
||||
# Da questo momento in poi, essendo figlio del Mondo, resterà immobile lì.
|
||||
ray.global_position = nodo_camere.global_position + Vector3(random_x, godray_spawn_height, random_z)
|
||||
|
||||
# Li incliniamo tutti uguali per farli piovere dall'angolo
|
||||
ray.rotation_degrees = godray_rotation_degrees
|
||||
|
||||
# Li allunghiamo per farli sembrare veri fasci di luce
|
||||
ray.scale = godray_scale
|
||||
|
||||
Reference in New Issue
Block a user