Compare commits
2 Commits
biome_gen_
...
zoo_countr
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
53646e36f0 | ||
|
|
88dd7c3ad8 |
@@ -1,9 +1,5 @@
|
||||
extends Node3D
|
||||
|
||||
const CHUNK_GENERATION_STEPS_PER_FRAME: int = 2
|
||||
const CHUNK_CLEANUP_STEPS_PER_FRAME: int = 4
|
||||
const LAMPPOST_WIRE_STEPS_PER_FRAME: int = 1
|
||||
|
||||
@export_group("Rails")
|
||||
@export var rail_path: Path3D
|
||||
|
||||
@@ -24,12 +20,6 @@ var last_pos_train: Vector2i = Vector2i(999999, 999999)
|
||||
var noise_generator: FastNoiseLite
|
||||
var altitude_generator: FastNoiseLite
|
||||
var wire_connections: Dictionary = {}
|
||||
var chunk_candidate_cache: Dictionary = {}
|
||||
var pending_generation_cells: Array[Vector2i] = []
|
||||
var pending_cleanup_cells: Array[Vector2i] = []
|
||||
var pending_wire_cells: Array[Vector2i] = []
|
||||
var pending_wire_lookup: Dictionary = {}
|
||||
var pending_radar_update: bool = false
|
||||
|
||||
var manual_biome: Biome = null
|
||||
|
||||
@@ -46,7 +36,6 @@ func _ready() -> void:
|
||||
altitude_generator.seed = randi()
|
||||
altitude_generator.frequency = district_scale * 0.5
|
||||
|
||||
_warm_chunk_candidate_cache()
|
||||
_update_set_pieces()
|
||||
|
||||
func _update_set_pieces() -> void:
|
||||
@@ -58,7 +47,7 @@ func _update_set_pieces() -> void:
|
||||
if not "exclusive_biome" in sp or sp.exclusive_biome == "":
|
||||
print("⚠️ Set Piece '", sp.name, "' not have exclusive biome -> always visible.")
|
||||
continue
|
||||
|
||||
|
||||
var local_biome = ""
|
||||
if manual_biome != null:
|
||||
local_biome = manual_biome.nome
|
||||
@@ -66,7 +55,7 @@ func _update_set_pieces() -> void:
|
||||
var grid_x = roundi(sp.global_position.x / chunk_size)
|
||||
var grid_z = roundi(sp.global_position.z / chunk_size)
|
||||
local_biome = _get_procedural_biome_name(noise_generator.get_noise_2d(grid_x, grid_z))
|
||||
|
||||
|
||||
print("Analyze: '", sp.name, "' | Need: [", sp.exclusive_biome, "] | Current biome is: [", local_biome, "]")
|
||||
if local_biome == sp.exclusive_biome:
|
||||
sp.show()
|
||||
@@ -78,18 +67,15 @@ func _update_set_pieces() -> void:
|
||||
print(" ❌ Temple is an invisible ghost.")
|
||||
|
||||
func _destroy_and_regenrate_world() -> void:
|
||||
_warm_chunk_candidate_cache()
|
||||
_clear_pending_world_work()
|
||||
|
||||
#Turn off old temples
|
||||
_update_set_pieces()
|
||||
|
||||
#Destroy all models
|
||||
for pos in board.keys():
|
||||
var cella = board[pos]
|
||||
if cella["type"] != "obstacle":
|
||||
if cella.has("node") and is_instance_valid(cella["node"]):
|
||||
cella["node"].queue_free()
|
||||
if cella["tipo"] == "bioma":
|
||||
if cella.has("nodo") and is_instance_valid(cella["nodo"]):
|
||||
cella["nodo"].queue_free()
|
||||
|
||||
#Clean board and wire connections
|
||||
board.clear()
|
||||
@@ -97,20 +83,9 @@ func _destroy_and_regenrate_world() -> void:
|
||||
|
||||
#Create train
|
||||
last_pos_train = Vector2i(999999, 999999)
|
||||
if rail_path != null and rail_path.train_instance != null:
|
||||
var train_pos = rail_path.train_instance.global_position
|
||||
var current_pos = Vector2i(roundi(train_pos.x / chunk_size), roundi(train_pos.z / chunk_size))
|
||||
_refresh_world_work(current_pos)
|
||||
pending_radar_update = true
|
||||
|
||||
func _process(_delta: float) -> void:
|
||||
_drain_cleanup_queue()
|
||||
_drain_generation_queue()
|
||||
_drain_wire_queue()
|
||||
|
||||
if pending_radar_update:
|
||||
pending_radar_update = false
|
||||
_train_radar()
|
||||
_train_radar()
|
||||
last_pos_train = Vector2i(999999, 999999)
|
||||
_train_radar()
|
||||
|
||||
func _physics_process(_delta: float) -> void:
|
||||
if rail_path == null or rail_path.train_instance == null: return
|
||||
@@ -122,8 +97,9 @@ func _physics_process(_delta: float) -> void:
|
||||
|
||||
if current_pos != last_pos_train:
|
||||
last_pos_train = current_pos
|
||||
_refresh_world_work(current_pos)
|
||||
pending_radar_update = true
|
||||
_generate_pieces_around_train(current_pos)
|
||||
_clean_far_chunks(current_pos)
|
||||
_train_radar()
|
||||
|
||||
func collect_all_chunkinfo(root: Node, list: Array[Node]) -> void:
|
||||
if root == null: return
|
||||
@@ -134,173 +110,11 @@ func collect_all_chunkinfo(root: Node, list: Array[Node]) -> void:
|
||||
for child in root.get_children():
|
||||
collect_all_chunkinfo(child, list)
|
||||
|
||||
func _warm_chunk_candidate_cache() -> void:
|
||||
var unique_scenes: Dictionary = {}
|
||||
|
||||
for biome in biome_list:
|
||||
if biome == null:
|
||||
continue
|
||||
for scene in biome.available_chunks:
|
||||
if scene == null:
|
||||
continue
|
||||
unique_scenes[_get_chunk_scene_cache_key(scene)] = scene
|
||||
|
||||
if manual_biome != null:
|
||||
for scene in manual_biome.available_chunks:
|
||||
if scene == null:
|
||||
continue
|
||||
unique_scenes[_get_chunk_scene_cache_key(scene)] = scene
|
||||
|
||||
for scene in unique_scenes.values():
|
||||
_get_chunk_scene_metadata(scene)
|
||||
|
||||
func _get_chunk_scene_cache_key(scene: PackedScene) -> String:
|
||||
if scene == null:
|
||||
return ""
|
||||
if scene.resource_path != "":
|
||||
return scene.resource_path
|
||||
return "scene_%s" % scene.get_instance_id()
|
||||
|
||||
func _get_chunk_scene_metadata(scene: PackedScene) -> Dictionary:
|
||||
if scene == null:
|
||||
return {}
|
||||
|
||||
var key = _get_chunk_scene_cache_key(scene)
|
||||
if chunk_candidate_cache.has(key):
|
||||
return chunk_candidate_cache[key]
|
||||
|
||||
var preview_chunk = scene.instantiate()
|
||||
var info_list: Array[Node] = []
|
||||
collect_all_chunkinfo(preview_chunk, info_list)
|
||||
var info_node = info_list[0] if info_list.size() > 0 else null
|
||||
|
||||
if info_node == null or not info_node.has_method("get_rotated_data"):
|
||||
preview_chunk.queue_free()
|
||||
chunk_candidate_cache[key] = {}
|
||||
return {}
|
||||
|
||||
var info_path: NodePath = NodePath(".")
|
||||
if info_node != preview_chunk:
|
||||
info_path = preview_chunk.get_path_to(info_node)
|
||||
|
||||
var rotations = []
|
||||
for rot in range(4):
|
||||
rotations.append({
|
||||
"rotation": rot,
|
||||
"data": info_node.get_rotated_data(rot)
|
||||
})
|
||||
|
||||
var metadata = {
|
||||
"info_path": info_path,
|
||||
"rotations": rotations,
|
||||
"has_lamppost": "have_lamppost" in info_node and info_node.have_lamppost,
|
||||
}
|
||||
preview_chunk.queue_free()
|
||||
chunk_candidate_cache[key] = metadata
|
||||
return metadata
|
||||
|
||||
func _get_cached_chunk_info(instance: Node, scene: PackedScene) -> Node:
|
||||
var metadata = _get_chunk_scene_metadata(scene)
|
||||
if metadata.is_empty():
|
||||
return null
|
||||
|
||||
var info_path: NodePath = metadata["info_path"]
|
||||
if String(info_path) == ".":
|
||||
return instance
|
||||
return instance.get_node_or_null(info_path)
|
||||
|
||||
func _clear_pending_world_work() -> void:
|
||||
pending_generation_cells.clear()
|
||||
pending_cleanup_cells.clear()
|
||||
pending_wire_cells.clear()
|
||||
pending_wire_lookup.clear()
|
||||
pending_radar_update = false
|
||||
|
||||
func _refresh_world_work(center: Vector2i) -> void:
|
||||
_rebuild_generation_queue(center)
|
||||
_rebuild_cleanup_queue(center)
|
||||
|
||||
func _rebuild_generation_queue(center: Vector2i) -> void:
|
||||
pending_generation_cells.clear()
|
||||
|
||||
for radius in range(eye_line + 1):
|
||||
for x in range(-radius, radius + 1):
|
||||
for z in range(-radius, radius + 1):
|
||||
if maxi(abs(x), abs(z)) != radius:
|
||||
continue
|
||||
|
||||
var grid_pos = center + Vector2i(x, z)
|
||||
if board.has(grid_pos):
|
||||
continue
|
||||
pending_generation_cells.append(grid_pos)
|
||||
|
||||
func _rebuild_cleanup_queue(center: Vector2i) -> void:
|
||||
pending_cleanup_cells.clear()
|
||||
var safe_margin = 2
|
||||
|
||||
for grid_pos in board.keys():
|
||||
var cell = board[grid_pos]
|
||||
if cell["type"] == "obstacle":
|
||||
continue
|
||||
|
||||
var dist_x = abs(grid_pos.x - center.x)
|
||||
var dist_z = abs(grid_pos.y - center.y)
|
||||
if dist_x > eye_line + safe_margin or dist_z > eye_line + safe_margin:
|
||||
pending_cleanup_cells.append(grid_pos)
|
||||
|
||||
func _drain_generation_queue() -> void:
|
||||
var processed = 0
|
||||
while processed < CHUNK_GENERATION_STEPS_PER_FRAME and not pending_generation_cells.is_empty():
|
||||
var grid_pos = pending_generation_cells.pop_front()
|
||||
if board.has(grid_pos):
|
||||
continue
|
||||
|
||||
var is_obstacle = _register_cell_with_ray(grid_pos)
|
||||
if not is_obstacle:
|
||||
_add_compatible_biome(grid_pos)
|
||||
processed += 1
|
||||
|
||||
func _drain_cleanup_queue() -> void:
|
||||
var processed = 0
|
||||
while processed < CHUNK_CLEANUP_STEPS_PER_FRAME and not pending_cleanup_cells.is_empty():
|
||||
var grid_pos = pending_cleanup_cells.pop_front()
|
||||
if not board.has(grid_pos):
|
||||
continue
|
||||
|
||||
var cell = board[grid_pos]
|
||||
if cell["type"] == "obstacle":
|
||||
continue
|
||||
|
||||
if cell.has("node") and is_instance_valid(cell["node"]):
|
||||
cell["node"].queue_free()
|
||||
board.erase(grid_pos)
|
||||
processed += 1
|
||||
|
||||
func _queue_lamppost_wire_connection(grid_pos: Vector2i) -> void:
|
||||
if pending_wire_lookup.has(grid_pos):
|
||||
return
|
||||
pending_wire_lookup[grid_pos] = true
|
||||
pending_wire_cells.append(grid_pos)
|
||||
|
||||
func _drain_wire_queue() -> void:
|
||||
var processed = 0
|
||||
while processed < LAMPPOST_WIRE_STEPS_PER_FRAME and not pending_wire_cells.is_empty():
|
||||
var grid_pos = pending_wire_cells.pop_front()
|
||||
pending_wire_lookup.erase(grid_pos)
|
||||
|
||||
if not board.has(grid_pos):
|
||||
continue
|
||||
if not board[grid_pos].get("have_lamppost", false):
|
||||
continue
|
||||
|
||||
_connect_lamppost_wires(grid_pos)
|
||||
processed += 1
|
||||
|
||||
func _generate_pieces_around_train(center: Vector2i) -> void:
|
||||
for x in range(-eye_line, eye_line + 1):
|
||||
for z in range(-eye_line, eye_line + 1):
|
||||
var grid_pos = center + Vector2i(x, z)
|
||||
|
||||
|
||||
if not board.has(grid_pos):
|
||||
var ce_obstacle = _register_cell_with_ray(grid_pos)
|
||||
if not ce_obstacle:
|
||||
@@ -352,7 +166,7 @@ func _register_cell_with_ray(grid_pos: Vector2i) -> bool:
|
||||
if info_list.size() > 0:
|
||||
var min_distance = 999999.0
|
||||
var center_cell_pos = Vector3(world_pos.x, 0, world_pos.z)
|
||||
|
||||
|
||||
for info in info_list:
|
||||
if info is Node3D:
|
||||
var pos_info = Vector3(info.global_position.x, 0, info.global_position.z)
|
||||
@@ -377,7 +191,7 @@ func _register_cell_with_ray(grid_pos: Vector2i) -> bool:
|
||||
var data = right_info_node.get_rotated_data(rotation_steps)
|
||||
exit_found = data["connections"]
|
||||
height_found = data["heights"]
|
||||
|
||||
|
||||
if "have_lamppost" in right_info_node:
|
||||
have_lamppost = right_info_node.have_lamppost
|
||||
|
||||
@@ -392,7 +206,7 @@ func _register_cell_with_ray(grid_pos: Vector2i) -> bool:
|
||||
}
|
||||
|
||||
if have_lamppost:
|
||||
_queue_lamppost_wire_connection(grid_pos)
|
||||
_connect_lamppost_wires(grid_pos)
|
||||
|
||||
return true
|
||||
return false
|
||||
@@ -415,40 +229,43 @@ func _add_compatible_biome(grid_pos: Vector2i) -> void:
|
||||
var valid_candidates = []
|
||||
|
||||
for scene in zone_catalogue:
|
||||
var metadata = _get_chunk_scene_metadata(scene)
|
||||
if metadata.is_empty():
|
||||
continue
|
||||
var test_chunk = scene.instantiate()
|
||||
var test_list: Array[Node] = []
|
||||
collect_all_chunkinfo(test_chunk, test_list)
|
||||
var info_test = test_list[0] if test_list.size() > 0 else null
|
||||
|
||||
for candidate in metadata["rotations"]:
|
||||
var rot = candidate["rotation"]
|
||||
var data = candidate["data"]
|
||||
var u_conn = data["connections"]
|
||||
var u_height = data["heights"]
|
||||
|
||||
var match_conn_n = (req_conn_north == -1) or ((req_conn_north == 1) == u_conn["north"])
|
||||
var match_conn_e = (req_conn_est == -1) or ((req_conn_est == 1) == u_conn["est"])
|
||||
var match_conn_s = (req_conn_south == -1) or ((req_conn_south == 1) == u_conn["south"])
|
||||
var match_conn_o = (req_conn_west == -1) or ((req_conn_west == 1) == u_conn["west"])
|
||||
|
||||
var match_alt_n = (req_height_north == -1) or (req_height_north == u_height["north"])
|
||||
var match_alt_e = (req_height_est == -1) or (req_height_est == u_height["est"])
|
||||
var match_alt_s = (req_height_south == -1) or (req_height_south == u_height["south"])
|
||||
var match_alt_o = (req_height_west == -1) or (req_height_west == u_height["west"])
|
||||
|
||||
var diff_n = abs(u_height["north"] - height_target) if req_height_north == -1 else 0
|
||||
var diff_e = abs(u_height["est"] - height_target) if req_height_est == -1 else 0
|
||||
var diff_s = abs(u_height["south"] - height_target) if req_height_south == -1 else 0
|
||||
var diff_o = abs(u_height["west"] - height_target) if req_height_west == -1 else 0
|
||||
var excessive_jumps = diff_n > 1 or diff_e > 1 or diff_s > 1 or diff_o > 1
|
||||
|
||||
if match_conn_n and match_conn_e and match_conn_s and match_conn_o and match_alt_n and match_alt_e and match_alt_s and match_alt_o and not excessive_jumps:
|
||||
var score = 0
|
||||
if req_height_north == -1 and u_height["north"] == height_target: score += 1
|
||||
if req_height_est == -1 and u_height["est"] == height_target: score += 1
|
||||
if req_height_south == -1 and u_height["south"] == height_target: score += 1
|
||||
if req_height_west == -1 and u_height["west"] == height_target: score += 1
|
||||
if info_test != null and info_test.has_method("get_rotated_data"):
|
||||
for rot in range(4):
|
||||
var data = test_chunk.get_rotated_data(rot)
|
||||
var u_conn = data["connections"]
|
||||
var u_height = data["heights"]
|
||||
|
||||
valid_candidates.append({"scene": scene, "rotation": rot, "data": data, "score": score})
|
||||
var match_conn_n = (req_conn_north == -1) or ((req_conn_north == 1) == u_conn["north"])
|
||||
var match_conn_e = (req_conn_est == -1) or ((req_conn_est == 1) == u_conn["est"])
|
||||
var match_conn_s = (req_conn_south == -1) or ((req_conn_south == 1) == u_conn["south"])
|
||||
var match_conn_o = (req_conn_west == -1) or ((req_conn_west == 1) == u_conn["west"])
|
||||
|
||||
var match_alt_n = (req_height_north == -1) or (req_height_north == u_height["north"])
|
||||
var match_alt_e = (req_height_est == -1) or (req_height_est == u_height["est"])
|
||||
var match_alt_s = (req_height_south == -1) or (req_height_south == u_height["south"])
|
||||
var match_alt_o = (req_height_west == -1) or (req_height_west == u_height["west"])
|
||||
|
||||
var diff_n = abs(u_height["north"] - height_target) if req_height_north == -1 else 0
|
||||
var diff_e = abs(u_height["est"] - height_target) if req_height_est == -1 else 0
|
||||
var diff_s = abs(u_height["south"] - height_target) if req_height_south == -1 else 0
|
||||
var diff_o = abs(u_height["west"] - height_target) if req_height_west == -1 else 0
|
||||
var excessive_jumps = diff_n > 1 or diff_e > 1 or diff_s > 1 or diff_o > 1
|
||||
|
||||
if match_conn_n and match_conn_e and match_conn_s and match_conn_o and match_alt_n and match_alt_e and match_alt_s and match_alt_o and not excessive_jumps:
|
||||
var score = 0
|
||||
if req_height_north == -1 and u_height["north"] == height_target: score += 1
|
||||
if req_height_est == -1 and u_height["est"] == height_target: score += 1
|
||||
if req_height_south == -1 and u_height["south"] == height_target: score += 1
|
||||
if req_height_west == -1 and u_height["west"] == height_target: score += 1
|
||||
|
||||
valid_candidates.append({"scene": scene, "rotation": rot, "data": data, "score": score})
|
||||
|
||||
test_chunk.queue_free()
|
||||
|
||||
if valid_candidates.size() > 0:
|
||||
var max_score = -1
|
||||
@@ -461,14 +278,16 @@ func _add_compatible_biome(grid_pos: Vector2i) -> void:
|
||||
|
||||
var choise = best_candidate.pick_random()
|
||||
var new_chunk = choise.scene.instantiate()
|
||||
add_child(new_chunk)
|
||||
new_chunk.position = Vector3(grid_pos.x * chunk_size, 0, grid_pos.y * chunk_size)
|
||||
new_chunk.rotation.y = choise.rotation * (-PI / 2.0)
|
||||
add_child(new_chunk)
|
||||
|
||||
var info_new = _get_cached_chunk_info(new_chunk, choise.scene)
|
||||
var new_list: Array[Node] = []
|
||||
collect_all_chunkinfo(new_chunk, new_list)
|
||||
var info_new = new_list[0] if new_list.size() > 0 else null
|
||||
|
||||
var have_lamppost = false
|
||||
if info_new != null and "have_lamppost" in info_new:
|
||||
if info_new != null and "have_lamppost" in new_chunk:
|
||||
have_lamppost = info_new.have_lamppost
|
||||
|
||||
board[grid_pos] = {
|
||||
@@ -481,14 +300,16 @@ func _add_compatible_biome(grid_pos: Vector2i) -> void:
|
||||
}
|
||||
|
||||
if have_lamppost:
|
||||
_queue_lamppost_wire_connection(grid_pos)
|
||||
_connect_lamppost_wires(grid_pos)
|
||||
|
||||
else:
|
||||
var backup = zone_catalogue[0].instantiate()
|
||||
backup.position = Vector3(grid_pos.x * chunk_size, 0, grid_pos.y * chunk_size)
|
||||
add_child(backup)
|
||||
backup.position = Vector3(grid_pos.x * chunk_size, 0, grid_pos.y * chunk_size)
|
||||
|
||||
var info_backup = _get_cached_chunk_info(backup, zone_catalogue[0])
|
||||
var backup_list: Array[Node] = []
|
||||
collect_all_chunkinfo(backup, backup_list)
|
||||
var info_backup = backup_list[0] if backup_list.size() > 0 else null
|
||||
|
||||
var safe_heights = {
|
||||
"north": req_height_north if req_height_north != -1 else height_target,
|
||||
@@ -530,6 +351,8 @@ func _train_radar() -> void:
|
||||
|
||||
var current_progress = rail_path.train_progress
|
||||
var total_length = rail_path.curve.get_baked_length()
|
||||
#var exchange_distance = 0.0
|
||||
#var next_biome = ""
|
||||
|
||||
for step in range(1, 31):
|
||||
var next_progress = wrapf(current_progress + (step * chunk_size), 0.0, total_length)
|
||||
@@ -541,18 +364,44 @@ func _train_radar() -> void:
|
||||
var future_biome = _get_procedural_biome_name(noise_generator.get_noise_2d(f_x, f_z))
|
||||
|
||||
if future_biome != current_biome:
|
||||
#exchange_distance = step * chunk_size
|
||||
#next_biome = future_biome
|
||||
break
|
||||
|
||||
func _clean_far_chunks(centro_attuale: Vector2i) -> void:
|
||||
var cells_to_remove = []
|
||||
var safe_margin = 2
|
||||
|
||||
for grid_pos in board.keys():
|
||||
var cell = board[grid_pos]
|
||||
if cell["type"] == "obstacle": continue
|
||||
|
||||
var dist_x = abs(grid_pos.x - centro_attuale.x)
|
||||
var dist_z = abs(grid_pos.y - centro_attuale.y)
|
||||
|
||||
if dist_x > eye_line + safe_margin or dist_z > eye_line + safe_margin:
|
||||
if cell.has("node") and is_instance_valid(cell["node"]):
|
||||
cell["node"].queue_free()
|
||||
cells_to_remove.append(grid_pos)
|
||||
|
||||
for pos in cells_to_remove:
|
||||
board.erase(pos)
|
||||
|
||||
|
||||
func _get_lampposts(info_node: Node, side: String) -> Array[Node3D]:
|
||||
var lampposts: Array[Node3D] = []
|
||||
if side == "sx":
|
||||
if "connection_left" in info_node and info_node.connection_left != null:
|
||||
for p in info_node.connection_left:
|
||||
if is_instance_valid(p): lampposts.append(p)
|
||||
#if lampposts.is_empty() and "nodo_attacco_sx" in nodo_info and is_instance_valid(nodo_info.get("nodo_attacco_sx")):
|
||||
# lampposts.append(nodo_info.get("nodo_attacco_sx"))
|
||||
else:
|
||||
if "connection_right" in info_node and info_node.connection_right != null:
|
||||
for p in info_node.connection_right:
|
||||
if is_instance_valid(p): lampposts.append(p)
|
||||
#if lampposts.is_empty() and "nodo_attacco_dx" in nodo_info and is_instance_valid(nodo_info.get("nodo_attacco_dx")):
|
||||
# lampposts.append(nodo_info.get("nodo_attacco_dx"))
|
||||
return lampposts
|
||||
|
||||
func _connect_lamppost_wires(new_board_pos: Vector2i) -> void:
|
||||
@@ -622,7 +471,7 @@ func _connect_lamppost_wires(new_board_pos: Vector2i) -> void:
|
||||
if board.has(closest_pos) and board[closest_pos].get("have_lamppost", false):
|
||||
var closest_root = board[closest_pos]["node"]
|
||||
var closest_info = board[closest_pos]["info"]
|
||||
|
||||
|
||||
if not is_instance_valid(closest_root) or closest_root == new_root or closest_info == null: continue
|
||||
|
||||
if closest_info is Node3D: closest_info.force_update_transform()
|
||||
|
||||
@@ -47,112 +47,15 @@ var next_stop_index: int = 0
|
||||
var stop_multiply: float = 1.0
|
||||
var is_restarting: bool = false
|
||||
var tween_restart: Tween
|
||||
var environment_config: EnvironmentConfig
|
||||
|
||||
func _ready() -> void:
|
||||
_cache_environment_config()
|
||||
if curve != null and curve.get_baked_length() > 0:
|
||||
build_rails()
|
||||
build_train()
|
||||
_plan_stops()
|
||||
_apply_initial_train_start()
|
||||
else:
|
||||
print("WARNING: Draw Path3D for rails!")
|
||||
|
||||
func _cache_environment_config() -> void:
|
||||
var parent_node: Node = get_parent()
|
||||
if parent_node != null:
|
||||
var day_night_node := parent_node.get_node_or_null("DayNight") as EnvironmentManagerRoot
|
||||
if day_night_node != null:
|
||||
environment_config = day_night_node.environment_config
|
||||
return
|
||||
|
||||
var current_scene: Node = get_tree().current_scene
|
||||
if current_scene == null:
|
||||
return
|
||||
|
||||
for child in current_scene.get_children():
|
||||
var environment_manager := child as EnvironmentManagerRoot
|
||||
if environment_manager != null:
|
||||
environment_config = environment_manager.environment_config
|
||||
return
|
||||
|
||||
func _apply_initial_train_start() -> void:
|
||||
if train_instance == null or curve == null:
|
||||
return
|
||||
|
||||
var total_length: float = curve.get_baked_length()
|
||||
if total_length <= 0.0:
|
||||
return
|
||||
|
||||
#start from a random position
|
||||
if environment_config != null and environment_config.train_start_from_random_position:
|
||||
train_progress = randf() * total_length
|
||||
_update_next_stop_index_from_progress()
|
||||
elif environment_config != null and not stop_offset.is_empty():
|
||||
#start from a specific stop
|
||||
var stop_index: int = clampi(environment_config.train_start_stop_index, 0, stop_offset.size() - 1)
|
||||
train_progress = stop_offset[stop_index]
|
||||
_set_next_stop_index_from_current(stop_index)
|
||||
else:
|
||||
train_progress = wrapf(train_progress, 0.0, total_length)
|
||||
_update_next_stop_index_from_progress()
|
||||
|
||||
_snap_train_to_progress()
|
||||
|
||||
func _set_next_stop_index_from_current(current_stop_index: int) -> void:
|
||||
if stop_offset.is_empty():
|
||||
next_stop_index = 0
|
||||
return
|
||||
|
||||
if train_speed >= 0.0:
|
||||
next_stop_index = (current_stop_index + 1) % stop_offset.size()
|
||||
else:
|
||||
next_stop_index = current_stop_index - 1
|
||||
if next_stop_index < 0:
|
||||
next_stop_index = stop_offset.size() - 1
|
||||
|
||||
func _update_next_stop_index_from_progress() -> void:
|
||||
if stop_offset.is_empty():
|
||||
next_stop_index = 0
|
||||
return
|
||||
|
||||
if train_speed >= 0.0:
|
||||
next_stop_index = 0
|
||||
for i in range(stop_offset.size()):
|
||||
if stop_offset[i] > train_progress + 0.001:
|
||||
next_stop_index = i
|
||||
return
|
||||
return
|
||||
|
||||
next_stop_index = stop_offset.size() - 1
|
||||
for i in range(stop_offset.size() - 1, -1, -1):
|
||||
if stop_offset[i] < train_progress - 0.001:
|
||||
next_stop_index = i
|
||||
return
|
||||
|
||||
func _snap_train_to_progress() -> void:
|
||||
if train_instance == null or curve == null:
|
||||
return
|
||||
|
||||
var total_length: float = curve.get_baked_length()
|
||||
if total_length <= 0.0:
|
||||
return
|
||||
|
||||
train_progress = wrapf(train_progress, 0.0, total_length)
|
||||
var center_position: Vector3 = to_global(curve.sample_baked(train_progress, true))
|
||||
var prog_forward: float = wrapf(train_progress + 2.0, 0.0, total_length)
|
||||
var forward_position: Vector3 = to_global(curve.sample_baked(prog_forward, true))
|
||||
|
||||
train_instance.global_position = center_position
|
||||
if center_position.distance_to(forward_position) > 0.01:
|
||||
train_instance.look_at(forward_position, Vector3.UP)
|
||||
train_instance.rotate_y(PI)
|
||||
|
||||
if cameras:
|
||||
cameras.global_position = center_position
|
||||
cameras.global_basis = train_instance.global_basis
|
||||
|
||||
func build_rails() -> void:
|
||||
var mat_wood = StandardMaterial3D.new()
|
||||
mat_wood.albedo_color = Color(0.35, 0.2, 0.1)
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
[gd_resource type="NoiseTexture2D" format=3 uid="uid://b2xcpt2y8v32x"]
|
||||
|
||||
[sub_resource type="FastNoiseLite" id="FastNoiseLite_oqwsk"]
|
||||
|
||||
[resource]
|
||||
noise = SubResource("FastNoiseLite_oqwsk")
|
||||
seamless = true
|
||||
@@ -1,17 +1,9 @@
|
||||
shader_type canvas_item;
|
||||
|
||||
// Cattura tutto quello che c'è sotto questo nodo
|
||||
uniform sampler2D screen_texture : hint_screen_texture, filter_linear_mipmap;
|
||||
|
||||
uniform float blur_amount : hint_range(0.0, 5.0) = 2.5;
|
||||
uniform float focus_size : hint_range(0.0, 1.0) = 0.4;
|
||||
uniform float transition_softness : hint_range(0.01, 1.0) = 0.3;
|
||||
|
||||
void fragment() {
|
||||
float dist_from_center = abs(SCREEN_UV.y - 0.5);
|
||||
float mask = smoothstep(focus_size / 2.0, (focus_size / 2.0) + transition_softness, dist_from_center);
|
||||
|
||||
// Applica il blur
|
||||
vec4 blurred_screen = textureLod(screen_texture, SCREEN_UV, blur_amount * mask);
|
||||
COLOR = blurred_screen;
|
||||
}
|
||||
COLOR = textureLod(screen_texture, SCREEN_UV, blur_amount);
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
[ext_resource type="Material" uid="uid://codq5gx71rj4o" path="res://core/daynight/environment_dust_material.tres" id="8_amaf0"]
|
||||
[ext_resource type="Shader" uid="uid://bkn6eqgbn37jx" path="res://core/daynight/blur.gdshader" id="9_amaf0"]
|
||||
[ext_resource type="Shader" uid="uid://b5wa82soyhsqm" path="res://core/daynight/environment_shadows.gdshader" id="10_tuauy"]
|
||||
[ext_resource type="Texture2D" uid="uid://b2xcpt2y8v32x" path="res://core/daynight/FogNoise.tres" id="11_tuauy"]
|
||||
[ext_resource type="FastNoiseLite" uid="uid://c0mtwrkptjcuw" path="res://core/daynight/environment_shadows_noise_clouds.tres" id="11_yn8v8"]
|
||||
|
||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_ruhh7"]
|
||||
@@ -41,55 +40,9 @@ shader_parameter/sun_color = Color(0.2841828, 0.2023238, 0.27953526, 1)
|
||||
|
||||
[sub_resource type="Resource" id="Resource_r4tfj"]
|
||||
script = ExtResource("2_h6hjk")
|
||||
morning_color = Color(0.93333334, 0.78039217, 0.6039216, 1)
|
||||
afternoon_color = Color(0.9490196, 0.62352943, 0.38039216, 1)
|
||||
night_color = Color(0.18431373, 0.18431373, 0.4862745, 1)
|
||||
sun_rotation_morning = Vector3(-50, -90, 0)
|
||||
sun_rotation_afternoon = Vector3(-120, -90, 0)
|
||||
sun_rotation_night = Vector3(-130, -90, 0)
|
||||
night_light_energy = 1.0
|
||||
exposure_morning = 0.8
|
||||
exposure_afternoon = 0.7
|
||||
exposure_night = 0.7
|
||||
sky_top_morning = Color(0.11764706, 0.35686275, 0.5411765, 1)
|
||||
sky_top_afternoon = Color(0.7019608, 0.4509804, 0.2, 1)
|
||||
sky_top_night = Color(0.050980393, 0.050980393, 0.14901961, 1)
|
||||
sky_horizon_morning = Color(0.4627451, 0.6745098, 0.8627451, 1)
|
||||
sky_horizon_afternoon = Color(0.93333334, 0.6, 0.8039216, 1)
|
||||
sky_horizon_night = Color(0.14901961, 0.101960786, 0.2509804, 1)
|
||||
grad_top_morning = Color(0.7921569, 0.8784314, 0.95686275, 1)
|
||||
grad_top_afternoon = Color(0.8627451, 0.24313726, 0.5411765, 1)
|
||||
grad_top_night = Color(0.16470589, 0.16470589, 0.26666668, 1)
|
||||
grad_bot_morning = Color(0.05882353, 0.078431375, 0.21568628, 1)
|
||||
grad_bot_afternoon = Color(0.2509804, 0.019607844, 0.043137256, 1)
|
||||
grad_intensity_morning = 0.05
|
||||
grad_intensity_afternoon = 0.1
|
||||
grad_intensity_night = 0.5
|
||||
fog_color_morning = Color(0.7490196, 0.8509804, 0.9490196, 1)
|
||||
fog_color_afternoon = Color(0.9647059, 0.5882353, 0.7607843, 1)
|
||||
fog_color_night = Color(0.14901961, 0.101960786, 0.2509804, 1)
|
||||
fog_density_morning = 0.01
|
||||
fog_density_afternoon = 0.02
|
||||
glow_morning = 0.4
|
||||
glow_night = 0.6
|
||||
material_fog = SubResource("ShaderMaterial_b5atu")
|
||||
material_drops = SubResource("StandardMaterial3D_r4tfj")
|
||||
material_clouds = SubResource("ShaderMaterial_ruhh7")
|
||||
lightning_color = Color(1, 0.9843137, 0.4627451, 1)
|
||||
lightning_min = 2
|
||||
lightning_max = 4
|
||||
lightning_scale_min = 2.0
|
||||
lightning_scale_max = 5.0
|
||||
godray_max_rain = 60
|
||||
godray_spawn_radius = 100.0
|
||||
godray_spawn_offset = Vector3(20, 80, 20)
|
||||
godray_rotation_degrees = Vector3(50, 30, 0)
|
||||
godray_scale = Vector3(2, 25, 50)
|
||||
snow_amount = 2000.0
|
||||
wind_amount = 50
|
||||
cloud_speed = 0.01
|
||||
fireflies_amount = 550
|
||||
fireflies_spawn_ray = 60.0
|
||||
metadata/_custom_type_script = "uid://butda6k2tli3o"
|
||||
|
||||
[sub_resource type="Gradient" id="Gradient_i3hjl"]
|
||||
@@ -132,7 +85,7 @@ gradient = SubResource("Gradient_djqkg")
|
||||
lifetime_randomness = 0.5
|
||||
emission_shape_scale = Vector3(5, 5, 5)
|
||||
emission_shape = 3
|
||||
emission_box_extents = Vector3(1, 1, 1)
|
||||
emission_box_extents = Vector3(25, 5, 25)
|
||||
direction = Vector3(0, 1, 0)
|
||||
initial_velocity_min = 6.0
|
||||
initial_velocity_max = 6.0
|
||||
@@ -146,9 +99,10 @@ point_count = 3
|
||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_cer0u"]
|
||||
render_priority = 0
|
||||
shader = ExtResource("5_djqkg")
|
||||
shader_parameter/time_scale = 3.065
|
||||
shader_parameter/wave_amplitude = 0.3
|
||||
shader_parameter/wave_frequency = 0.25
|
||||
shader_parameter/wave_frequency = 1.0
|
||||
shader_parameter/base_amplitude = 0.5
|
||||
shader_parameter/secondary_ratio = 0.6
|
||||
shader_parameter/time_scale_base = 3.0
|
||||
|
||||
[sub_resource type="TubeTrailMesh" id="TubeTrailMesh_vo82p"]
|
||||
material = SubResource("ShaderMaterial_cer0u")
|
||||
@@ -220,9 +174,7 @@ size = Vector2(0.05, 0.8)
|
||||
|
||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_kavln"]
|
||||
shader = ExtResource("9_amaf0")
|
||||
shader_parameter/blur_amount = 0.50000002375
|
||||
shader_parameter/focus_size = 0.54400002584
|
||||
shader_parameter/transition_softness = 0.00999999977648
|
||||
shader_parameter/blur_amount = 0.6000000285
|
||||
|
||||
[sub_resource type="QuadMesh" id="QuadMesh_sxgg7"]
|
||||
size = Vector2(2, 2)
|
||||
@@ -232,12 +184,12 @@ noise = ExtResource("11_yn8v8")
|
||||
seamless = true
|
||||
|
||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_oqt1s"]
|
||||
render_priority = -1
|
||||
render_priority = 0
|
||||
shader = ExtResource("10_tuauy")
|
||||
shader_parameter/noise_texture = SubResource("NoiseTexture2D_0fcg4")
|
||||
shader_parameter/cloud_scale = 0.0070000003325
|
||||
shader_parameter/cloud_speed = 0.0030000001425
|
||||
shader_parameter/direction = Vector2(0.1, 0.025)
|
||||
shader_parameter/direction = Vector2(0.5, 0.2)
|
||||
shader_parameter/sun_angle = Vector2(0.5, 0.5)
|
||||
shader_parameter/cloud_density = 0.400000019
|
||||
shader_parameter/center_sharpness = 0.138000006555
|
||||
@@ -249,23 +201,7 @@ shader_parameter/fade_end = 800.000035625
|
||||
shader_parameter/height_fade_start = 10.0
|
||||
shader_parameter/height_fade_end = 50.0
|
||||
|
||||
[sub_resource type="QuadMesh" id="QuadMesh_yn8v8"]
|
||||
size = Vector2(2, 2)
|
||||
|
||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_sxgg7"]
|
||||
render_priority = 2
|
||||
shader = ExtResource("2_r4tfj")
|
||||
shader_parameter/fog_noise = ExtResource("11_tuauy")
|
||||
shader_parameter/use_red_as_alpha = true
|
||||
shader_parameter/fog_color = Color(0.8, 0.8509804, 0.9019608, 0.2509804)
|
||||
shader_parameter/scroll_speed = Vector2(0, 0.01)
|
||||
shader_parameter/texture_scale = Vector2(1, 1)
|
||||
shader_parameter/edge_softness_y = 0.16400000779
|
||||
shader_parameter/edge_softness_x = 0.5
|
||||
shader_parameter/night_intensity = 0.0
|
||||
shader_parameter/sun_color = Color(1, 1, 1, 1)
|
||||
|
||||
[node name="EnvironmentManager" type="Node3D" unique_id=1611939731 node_paths=PackedStringArray("particles_wind", "particles_snow", "particles_fireflies", "particles_rain", "environment_dust", "blur", "environment_shadows", "fog")]
|
||||
[node name="EnvironmentManager" type="Node3D" unique_id=1611939731 node_paths=PackedStringArray("particles_wind", "particles_snow", "particles_fireflies", "particles_rain", "environment_dust", "blur", "environment_shadows")]
|
||||
script = ExtResource("1_wecen")
|
||||
environment_config = SubResource("Resource_r4tfj")
|
||||
particles_wind = NodePath("Particles_Wind")
|
||||
@@ -276,7 +212,6 @@ godray = ExtResource("5_411rw")
|
||||
environment_dust = NodePath("EnvironmentDust")
|
||||
blur = NodePath("Blur")
|
||||
environment_shadows = NodePath("EnvironmentCloudsShadows")
|
||||
fog = NodePath("Fog")
|
||||
|
||||
[node name="Particles_Fireflies" type="GPUParticles3D" parent="." unique_id=947538133]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2, 0)
|
||||
@@ -287,10 +222,9 @@ process_material = SubResource("ParticleProcessMaterial_i3hjl")
|
||||
draw_pass_1 = SubResource("QuadMesh_b5atu")
|
||||
|
||||
[node name="Particles_Wind" type="GPUParticles3D" parent="." unique_id=1238214694]
|
||||
transform = Transform3D(1, 0, 0, 0, -4.371139e-08, -1, 0, 1, -4.371139e-08, 0, 50, 0)
|
||||
cast_shadow = 0
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 50, 0)
|
||||
emitting = false
|
||||
amount = 25
|
||||
amount = 100
|
||||
lifetime = 3.0
|
||||
fixed_fps = 60
|
||||
process_material = SubResource("ParticleProcessMaterial_ruhh7")
|
||||
@@ -337,15 +271,3 @@ mouse_filter = 2
|
||||
extra_cull_margin = 16384.0
|
||||
mesh = SubResource("QuadMesh_sxgg7")
|
||||
surface_material_override/0 = SubResource("ShaderMaterial_oqt1s")
|
||||
|
||||
[node name="Fog" type="Node3D" parent="." unique_id=1626352238]
|
||||
|
||||
[node name="MeshInstance3D" type="MeshInstance3D" parent="Fog" unique_id=96635311]
|
||||
transform = Transform3D(-42.075005, 7.553328e-06, 1.7196172e-13, 0, -3.7766642e-06, 45, 3.6783138e-06, 86.4, 1.9670128e-06, -41.926987, 14, 0)
|
||||
mesh = SubResource("QuadMesh_yn8v8")
|
||||
surface_material_override/0 = SubResource("ShaderMaterial_sxgg7")
|
||||
|
||||
[node name="MeshInstance3D2" type="MeshInstance3D" parent="Fog" unique_id=10121049]
|
||||
transform = Transform3D(-42.075005, 7.553328e-06, 1.7196172e-13, 0, -3.7766642e-06, 45, 3.6783138e-06, 86.4, 1.9670128e-06, 59.320038, 14, 0)
|
||||
mesh = SubResource("QuadMesh_yn8v8")
|
||||
surface_material_override/0 = SubResource("ShaderMaterial_sxgg7")
|
||||
|
||||
@@ -1,11 +1,6 @@
|
||||
class_name EnvironmentManagerRoot
|
||||
extends Node3D
|
||||
|
||||
const NOISE_TEXTURE: Texture2D = preload("res://core/daynight/noise.tres")
|
||||
const WEATHER_SHADER: Material = preload("res://core/daynight/weather_overlay.tres")
|
||||
const WEATHER_PLAIN_SHADER: Material = preload("res://core/daynight/weather_plain_shader.tres")
|
||||
const DYNAMIC_ENVIRONMENT_UPDATES_PER_FRAME: int = 2 #how many update of the environment (apply materials) will be done per frame
|
||||
|
||||
@export var environment_config: EnvironmentConfig
|
||||
|
||||
@export_group("Camera")
|
||||
@@ -21,7 +16,6 @@ const DYNAMIC_ENVIRONMENT_UPDATES_PER_FRAME: int = 2 #how many update of the env
|
||||
@export var environment_dust: ColorRect
|
||||
@export var blur: ColorRect
|
||||
@export var environment_shadows: MeshInstance3D
|
||||
@export var fog: Node3D
|
||||
|
||||
@export_group("Sound")
|
||||
@export var thunder_sounds: Array[AudioStream]
|
||||
@@ -36,13 +30,9 @@ var weather_controller: WeatherController
|
||||
|
||||
var day_tween: Tween
|
||||
var day_time: float = 0.0
|
||||
var pending_environment_nodes: Dictionary = {}
|
||||
|
||||
func _ready() -> void:
|
||||
|
||||
#connect shader when new node is added
|
||||
get_tree().node_added.connect(_on_tree_node_added)
|
||||
|
||||
#set noise texture 2d to materials in special group
|
||||
ApplyWindNoiseToMaterials()
|
||||
#set weather overlay (snow + rain) to materials in special group
|
||||
@@ -65,7 +55,6 @@ func _ready() -> void:
|
||||
godray,
|
||||
environment_dust,
|
||||
blur,
|
||||
fog,
|
||||
environment_shadows,
|
||||
sun,
|
||||
environment,
|
||||
@@ -78,67 +67,10 @@ func _ready() -> void:
|
||||
weather_controller.name = "WeatherController"
|
||||
add_child(weather_controller)
|
||||
|
||||
func _process(_delta: float) -> void:
|
||||
_process_pending_environment_nodes()
|
||||
|
||||
func _on_tree_node_added(node: Node) -> void:
|
||||
if node.is_in_group("wind_node") or node.is_in_group("weather_node") or node.is_in_group("weather_vegetables_node"):
|
||||
_queue_dynamic_environment_node(node)
|
||||
|
||||
func _queue_dynamic_environment_node(node: Node) -> void:
|
||||
if not is_instance_valid(node):
|
||||
return
|
||||
|
||||
var ancestor = node.get_parent()
|
||||
while ancestor != null:
|
||||
if pending_environment_nodes.has(ancestor.get_instance_id()):
|
||||
return
|
||||
ancestor = ancestor.get_parent()
|
||||
|
||||
var stale_ids: Array[int] = []
|
||||
for node_id in pending_environment_nodes.keys():
|
||||
var pending_node = pending_environment_nodes[node_id]
|
||||
if not is_instance_valid(pending_node):
|
||||
stale_ids.append(node_id)
|
||||
continue
|
||||
if node.is_ancestor_of(pending_node):
|
||||
stale_ids.append(node_id)
|
||||
|
||||
for node_id in stale_ids:
|
||||
pending_environment_nodes.erase(node_id)
|
||||
|
||||
pending_environment_nodes[node.get_instance_id()] = node
|
||||
|
||||
func _process_pending_environment_nodes() -> void:
|
||||
var processed = 0
|
||||
for node_id in pending_environment_nodes.keys():
|
||||
if processed >= DYNAMIC_ENVIRONMENT_UPDATES_PER_FRAME:
|
||||
break
|
||||
|
||||
var node = pending_environment_nodes[node_id]
|
||||
pending_environment_nodes.erase(node_id)
|
||||
if not is_instance_valid(node):
|
||||
continue
|
||||
|
||||
_apply_dynamic_environment_materials(node)
|
||||
processed += 1
|
||||
|
||||
func _apply_dynamic_environment_materials(node: Node) -> void:
|
||||
if not is_instance_valid(node):
|
||||
return
|
||||
|
||||
if node.is_in_group("wind_node"):
|
||||
_apply_wind_noise_to_node(node, NOISE_TEXTURE)
|
||||
|
||||
if node.is_in_group("weather_node"):
|
||||
_apply_weather_overlay_to_node(node, WEATHER_SHADER)
|
||||
|
||||
if node.is_in_group("weather_vegetables_node"):
|
||||
_apply_weather_overlay_to_node(node, WEATHER_PLAIN_SHADER)
|
||||
|
||||
func ApplyWindNoiseToMaterials():
|
||||
var noise_tex = preload("res://core/daynight/noise.tres")
|
||||
for node in get_tree().get_nodes_in_group("wind_node"):
|
||||
_apply_wind_noise_to_node(node, NOISE_TEXTURE)
|
||||
_apply_wind_noise_to_node(node, noise_tex)
|
||||
|
||||
func _apply_wind_noise_to_node(node: Node, noise_tex: Texture2D) -> void:
|
||||
if node is GeometryInstance3D:
|
||||
@@ -156,18 +88,25 @@ func _apply_wind_noise_to_node(node: Node, noise_tex: Texture2D) -> void:
|
||||
_apply_wind_noise_to_node(child, noise_tex)
|
||||
|
||||
func ApplyWeatherShaderToMaterials():
|
||||
var weather_shader = preload("res://core/daynight/weather_overlay.tres")
|
||||
for node in get_tree().get_nodes_in_group("weather_node"):
|
||||
_apply_weather_overlay_to_node(node, WEATHER_SHADER)
|
||||
if node is GeometryInstance3D:
|
||||
node.material_overlay = weather_shader
|
||||
else:
|
||||
for child in node.get_children():
|
||||
if child is GeometryInstance3D:
|
||||
child.material_overlay = weather_shader
|
||||
break
|
||||
|
||||
var weather_plain_shader = preload("res://core/daynight/weather_plain_shader.tres")
|
||||
for node in get_tree().get_nodes_in_group("weather_vegetables_node"):
|
||||
_apply_weather_overlay_to_node(node, WEATHER_PLAIN_SHADER)
|
||||
|
||||
func _apply_weather_overlay_to_node(node: Node, material: Material) -> void:
|
||||
if node is GeometryInstance3D:
|
||||
node.material_overlay = material
|
||||
|
||||
for child in node.get_children():
|
||||
_apply_weather_overlay_to_node(child, material)
|
||||
if node is GeometryInstance3D:
|
||||
node.material_overlay = weather_plain_shader
|
||||
else:
|
||||
for child in node.get_children():
|
||||
if child is GeometryInstance3D:
|
||||
child.material_overlay = weather_plain_shader
|
||||
break
|
||||
|
||||
func select_day_time(normalized_time: float) -> void:
|
||||
#set show_day_time_debug = true to show debug on screen
|
||||
|
||||
@@ -1,114 +0,0 @@
|
||||
## Procedural snow cap geometry for flat roofs and vehicles.
|
||||
extends Node3D
|
||||
|
||||
enum PlacementMode {
|
||||
AUTO_TARGET_AABB,
|
||||
MANUAL_SURFACE,
|
||||
}
|
||||
|
||||
const SNOW_CAP_SHADER: Shader = preload("res://core/daynight/snow_cap.gdshader")
|
||||
|
||||
@export var placement_mode: PlacementMode = PlacementMode.AUTO_TARGET_AABB
|
||||
@export var target_path: NodePath
|
||||
@export var size_inset: Vector2 = Vector2(0.25, 1.0)
|
||||
@export var position_offset: Vector3 = Vector3(0.0, -0.08, 0.0)
|
||||
@export var max_snow_height: float = 0.2
|
||||
@export_range(1, 24) var subdivide_width: int = 6
|
||||
@export_range(1, 24) var subdivide_depth: int = 18
|
||||
@export var manual_surface_center: Vector3 = Vector3.ZERO
|
||||
@export var manual_surface_size: Vector2 = Vector2(2.0, 6.0)
|
||||
|
||||
var _mesh_instance: MeshInstance3D
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
add_to_group("weather_overlay_ignore")
|
||||
_ensure_mesh_instance()
|
||||
_rebuild()
|
||||
|
||||
|
||||
func rebuild() -> void:
|
||||
_rebuild()
|
||||
|
||||
|
||||
func _ensure_mesh_instance() -> void:
|
||||
_mesh_instance = get_node_or_null("SnowCapMesh") as MeshInstance3D
|
||||
if _mesh_instance != null:
|
||||
return
|
||||
|
||||
_mesh_instance = MeshInstance3D.new()
|
||||
_mesh_instance.name = "SnowCapMesh"
|
||||
_mesh_instance.add_to_group("weather_overlay_ignore")
|
||||
add_child(_mesh_instance)
|
||||
|
||||
|
||||
func _rebuild() -> void:
|
||||
var cap_width: float = 0.0
|
||||
var cap_depth: float = 0.0
|
||||
var cap_surface_center := Vector3.ZERO
|
||||
|
||||
if placement_mode == PlacementMode.MANUAL_SURFACE:
|
||||
cap_width = manual_surface_size.x
|
||||
cap_depth = manual_surface_size.y
|
||||
cap_surface_center = manual_surface_center
|
||||
else:
|
||||
var target_mesh: MeshInstance3D = get_node_or_null(target_path) as MeshInstance3D
|
||||
if target_mesh == null:
|
||||
if _mesh_instance:
|
||||
_mesh_instance.visible = false
|
||||
return
|
||||
|
||||
var target_aabb: AABB = _get_target_aabb(target_mesh)
|
||||
cap_width = max(target_aabb.size.x - size_inset.x, 0.1)
|
||||
cap_depth = max(target_aabb.size.z - size_inset.y, 0.1)
|
||||
cap_surface_center = Vector3(
|
||||
target_aabb.position.x + target_aabb.size.x * 0.5,
|
||||
target_aabb.position.y + target_aabb.size.y,
|
||||
target_aabb.position.z + target_aabb.size.z * 0.5
|
||||
)
|
||||
|
||||
var cap_center := cap_surface_center + Vector3(0.0, max_snow_height * 0.5, 0.0)
|
||||
|
||||
var box_mesh := BoxMesh.new()
|
||||
box_mesh.size = Vector3(cap_width, max_snow_height, cap_depth)
|
||||
box_mesh.subdivide_width = subdivide_width
|
||||
box_mesh.subdivide_depth = subdivide_depth
|
||||
_mesh_instance.mesh = box_mesh
|
||||
_mesh_instance.position = cap_center + position_offset
|
||||
_mesh_instance.material_override = _build_material(cap_width, cap_depth)
|
||||
_mesh_instance.visible = true
|
||||
|
||||
|
||||
func _build_material(cap_width: float, cap_depth: float) -> ShaderMaterial:
|
||||
var material := ShaderMaterial.new()
|
||||
material.shader = SNOW_CAP_SHADER
|
||||
material.set_shader_parameter("max_height", max_snow_height)
|
||||
material.set_shader_parameter("half_width", cap_width * 0.5)
|
||||
material.set_shader_parameter("half_depth", cap_depth * 0.5)
|
||||
return material
|
||||
|
||||
|
||||
func _get_target_aabb(target_mesh: MeshInstance3D) -> AABB:
|
||||
var points: Array[Vector3] = []
|
||||
for point in _get_aabb_points(target_mesh.get_aabb()):
|
||||
points.append(target_mesh.transform * point)
|
||||
|
||||
var merged := AABB(points[0], Vector3.ZERO)
|
||||
for point in points:
|
||||
merged = merged.expand(point)
|
||||
return merged
|
||||
|
||||
|
||||
func _get_aabb_points(aabb: AABB) -> Array[Vector3]:
|
||||
var p: Vector3 = aabb.position
|
||||
var s: Vector3 = aabb.size
|
||||
return [
|
||||
p,
|
||||
p + Vector3(s.x, 0.0, 0.0),
|
||||
p + Vector3(0.0, s.y, 0.0),
|
||||
p + Vector3(0.0, 0.0, s.z),
|
||||
p + Vector3(s.x, s.y, 0.0),
|
||||
p + Vector3(s.x, 0.0, s.z),
|
||||
p + Vector3(0.0, s.y, s.z),
|
||||
p + s,
|
||||
]
|
||||
@@ -1 +0,0 @@
|
||||
uid://bxc6ketfgedxw
|
||||
@@ -1,114 +0,0 @@
|
||||
shader_type spatial;
|
||||
render_mode blend_mix, cull_back, depth_draw_opaque;
|
||||
|
||||
global uniform float global_snow_start_time = -1.0;
|
||||
global uniform float global_snow_accumulation_speed = 0.1;
|
||||
global uniform float global_snow_melt_time = -1.0;
|
||||
global uniform float global_snow_melt_speed = 0.1;
|
||||
global uniform vec4 global_snow_color = vec4(0.92, 0.96, 1.0, 1.0);
|
||||
|
||||
uniform float max_height : hint_range(0.02, 1.0) = 0.2;
|
||||
uniform float half_width : hint_range(0.01, 20.0) = 1.0;
|
||||
uniform float half_depth : hint_range(0.01, 20.0) = 1.0;
|
||||
uniform float noise_scale : hint_range(0.05, 2.0) = 0.35;
|
||||
uniform float noise_strength : hint_range(0.0, 0.4) = 0.18;
|
||||
uniform float edge_rounding : hint_range(0.0, 0.3) = 0.12;
|
||||
uniform float side_shade : hint_range(0.2, 1.0) = 0.82;
|
||||
uniform float sparkle_strength : hint_range(0.0, 0.1) = 0.03;
|
||||
|
||||
varying float v_snow_amount;
|
||||
varying float v_noise;
|
||||
|
||||
float hash(vec2 p) {
|
||||
return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453123);
|
||||
}
|
||||
|
||||
float value_noise(vec2 p) {
|
||||
vec2 i = floor(p);
|
||||
vec2 f = fract(p);
|
||||
vec2 u = f * f * (3.0 - 2.0 * f);
|
||||
|
||||
float a = hash(i);
|
||||
float b = hash(i + vec2(1.0, 0.0));
|
||||
float c = hash(i + vec2(0.0, 1.0));
|
||||
float d = hash(i + vec2(1.0, 1.0));
|
||||
|
||||
return mix(mix(a, b, u.x), mix(c, d, u.x), u.y);
|
||||
}
|
||||
|
||||
float fbm(vec2 p) {
|
||||
float value = 0.0;
|
||||
float amplitude = 0.5;
|
||||
float frequency = 1.0;
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
value += value_noise(p * frequency) * amplitude;
|
||||
frequency *= 2.0;
|
||||
amplitude *= 0.5;
|
||||
}
|
||||
|
||||
return clamp(value, 0.0, 1.0);
|
||||
}
|
||||
|
||||
float get_snow_amount() {
|
||||
float snow_amount = 0.0;
|
||||
if (global_snow_start_time >= 0.0) {
|
||||
snow_amount = clamp(
|
||||
(TIME - global_snow_start_time) * global_snow_accumulation_speed,
|
||||
0.0,
|
||||
1.0
|
||||
);
|
||||
}
|
||||
if (global_snow_melt_time >= 0.0) {
|
||||
float melt = clamp((TIME - global_snow_melt_time) * global_snow_melt_speed, 0.0, 1.0);
|
||||
snow_amount *= (1.0 - melt);
|
||||
}
|
||||
return snow_amount;
|
||||
}
|
||||
|
||||
void vertex() {
|
||||
vec3 base_vertex = VERTEX;
|
||||
vec3 world_pos = (MODEL_MATRIX * vec4(base_vertex, 1.0)).xyz;
|
||||
float snow_amount = get_snow_amount();
|
||||
float noise_val = fbm(world_pos.xz * noise_scale);
|
||||
float thickness = max_height * snow_amount * mix(
|
||||
1.0 - noise_strength,
|
||||
1.0 + noise_strength,
|
||||
noise_val
|
||||
);
|
||||
float footprint_growth = smoothstep(0.0, 0.35, snow_amount);
|
||||
|
||||
float from_bottom = clamp((base_vertex.y + max_height * 0.5) / max_height, 0.0, 1.0);
|
||||
VERTEX.y = -max_height * 0.5 + thickness * from_bottom;
|
||||
VERTEX.x *= mix(0.92, 1.0, footprint_growth);
|
||||
VERTEX.z *= mix(0.94, 1.0, footprint_growth);
|
||||
|
||||
float edge_x = abs(base_vertex.x) / max(half_width, 0.001);
|
||||
float edge_z = abs(base_vertex.z) / max(half_depth, 0.001);
|
||||
float edge_mask = smoothstep(0.55, 1.0, max(edge_x, edge_z));
|
||||
float top_mask = smoothstep(0.6, 1.0, from_bottom) * snow_amount;
|
||||
float round_factor = edge_rounding * edge_mask * top_mask;
|
||||
VERTEX.x *= 1.0 - round_factor;
|
||||
VERTEX.z *= 1.0 - round_factor;
|
||||
|
||||
v_snow_amount = snow_amount;
|
||||
v_noise = noise_val;
|
||||
}
|
||||
|
||||
void fragment() {
|
||||
if (v_snow_amount <= 0.001) {
|
||||
ALPHA = 0.0;
|
||||
ALBEDO = global_snow_color.rgb;
|
||||
ROUGHNESS = 1.0;
|
||||
SPECULAR = 0.0;
|
||||
} else {
|
||||
float facing_up = clamp(NORMAL.y, 0.0, 1.0);
|
||||
float shade = mix(-sparkle_strength, sparkle_strength, v_noise);
|
||||
vec3 snow_albedo = clamp(global_snow_color.rgb + vec3(shade), 0.0, 1.0);
|
||||
|
||||
ALBEDO = mix(snow_albedo * side_shade, snow_albedo, facing_up);
|
||||
ROUGHNESS = mix(0.95, 0.72, facing_up);
|
||||
SPECULAR = 0.18;
|
||||
ALPHA = smoothstep(0.0, 0.28, v_snow_amount);
|
||||
}
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
uid://c7js7ytvewmab
|
||||
@@ -2,7 +2,6 @@ shader_type spatial;
|
||||
render_mode blend_mix, depth_draw_always;
|
||||
|
||||
global uniform float global_rain_intensity;
|
||||
global uniform vec4 global_water_color = vec4(0.285, 0.534, 0.487, 1.0);
|
||||
|
||||
//Water color
|
||||
uniform vec4 deep_water_color : source_color = vec4(0.0, 0.1, 0.2, 1.0);
|
||||
@@ -45,14 +44,12 @@ void fragment() {
|
||||
float water_depth_gradient = exp(-depth_difference * beer_law_factor);
|
||||
vec4 base_water = mix(deep_water_color, shallow_water_color, water_depth_gradient);
|
||||
float rain_intensity = clamp(global_rain_intensity, 0.0, 1.0);
|
||||
base_water.rgb = mix(base_water.rgb, global_water_color.rgb, 0.7);
|
||||
|
||||
vec2 pos = world_pos_xz * ripple_scale;
|
||||
vec2 cell = floor(pos);
|
||||
vec2 local_pos = fract(pos) - 0.5;
|
||||
float random_val = fract(sin(dot(cell, vec2(12.9898, 78.233))) * 43758.5453);
|
||||
float active_ripple_density = ripple_density * rain_intensity;
|
||||
float is_active_cell = step(1.0 - active_ripple_density, random_val);
|
||||
float is_active_cell = step(1.0 - ripple_density, random_val);
|
||||
|
||||
float ring = 0.0;
|
||||
if (is_active_cell > 0.0) {
|
||||
|
||||
@@ -14,7 +14,6 @@ var godray: PackedScene
|
||||
var environment_dust: ColorRect
|
||||
var blur: ColorRect
|
||||
var environment_shadows: MeshInstance3D
|
||||
var fog: Node3D
|
||||
|
||||
var sun: DirectionalLight3D
|
||||
var environment: WorldEnvironment
|
||||
@@ -50,11 +49,10 @@ var current_wind_speed: float = 0.0
|
||||
var current_wind_strength: float = 0.0
|
||||
var current_wind_fade: float = 0.0
|
||||
var max_wind_amount: int = 0
|
||||
var random_weather_restore_tween: Tween
|
||||
|
||||
func _init(wind: GPUParticles3D, snow: GPUParticles3D,
|
||||
fireflies: GPUParticles3D, rain: GPUParticles3D, ray: PackedScene,
|
||||
dust: ColorRect, blurr: ColorRect, thefog: Node3D, envshadows: MeshInstance3D,
|
||||
dust: ColorRect, blurr: ColorRect, envshadows: MeshInstance3D,
|
||||
thesun: DirectionalLight3D, theenvironment: WorldEnvironment, environmentconfig: EnvironmentConfig,
|
||||
thecamera: Camera3D, thecamerapivot: Node3D, thundersounds: Array[AudioStream], rainsounds: Array[AudioStream]) -> void:
|
||||
particles_wind = wind
|
||||
@@ -65,7 +63,6 @@ func _init(wind: GPUParticles3D, snow: GPUParticles3D,
|
||||
sun = thesun
|
||||
environment_dust = dust
|
||||
blur = blurr
|
||||
fog = thefog
|
||||
environment_shadows = envshadows
|
||||
environment = theenvironment
|
||||
environment_config = environmentconfig
|
||||
@@ -89,7 +86,6 @@ func _init(wind: GPUParticles3D, snow: GPUParticles3D,
|
||||
|
||||
toggle_dust(environment_config.enable_dust)
|
||||
toggle_blur(environment_config.enable_blur)
|
||||
toggle_fog(environment_config.enable_fog)
|
||||
|
||||
#set camera pivot if available
|
||||
if camera_pivot:
|
||||
@@ -102,14 +98,11 @@ func _ready() -> void:
|
||||
UIEvents.toggle_snow.connect(toggle_snow)
|
||||
UIEvents.toggle_wind.connect(toggle_wind)
|
||||
UIEvents.wind_change.connect(change_wind_strength)
|
||||
UIEvents.trigger_random_weather.connect(trigger_random_weather_event)
|
||||
UIEvents.toggle_fireflies.connect(toggle_fireflies)
|
||||
UIEvents.toggle_storm.connect(toggle_storm)
|
||||
UIEvents.toggle_dust.connect(toggle_dust)
|
||||
UIEvents.toggle_blur.connect(toggle_blur)
|
||||
UIEvents.toggle_fog.connect(toggle_fog)
|
||||
UIEvents.toggle_shadows.connect(toggle_shadows)
|
||||
_emit_weather_event_label()
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
|
||||
@@ -129,7 +122,6 @@ func _process(delta: float) -> void:
|
||||
var base_grad_top: Color
|
||||
var base_grad_bot: Color
|
||||
var base_grad_intensity: float
|
||||
var base_water_color: Color
|
||||
var base_rotation_sun: Vector3
|
||||
|
||||
if is_raining:
|
||||
@@ -157,7 +149,6 @@ func _process(delta: float) -> void:
|
||||
base_grad_top = environment_config.grad_top_morning.lerp(environment_config.grad_top_afternoon, t)
|
||||
base_grad_bot = environment_config.grad_top_morning.lerp(environment_config.grad_bot_afternoon, t)
|
||||
base_grad_intensity = lerp(environment_config.grad_intensity_morning, environment_config.grad_intensity_afternoon, t)
|
||||
base_water_color = environment_config.water_color_morning.lerp(environment_config.water_color_afternoon, t)
|
||||
base_rotation_sun = environment_config.sun_rotation_morning.lerp(environment_config.sun_rotation_afternoon, t)
|
||||
else:
|
||||
var t = day_time - 2.0
|
||||
@@ -171,7 +162,6 @@ func _process(delta: float) -> void:
|
||||
base_grad_top = environment_config.grad_top_afternoon.lerp(environment_config.grad_top_night, t)
|
||||
base_grad_bot = environment_config.grad_bot_afternoon.lerp(environment_config.grad_bot_night, t)
|
||||
base_grad_intensity = lerp(environment_config.grad_intensity_afternoon, environment_config.grad_intensity_night, t)
|
||||
base_water_color = environment_config.water_color_afternoon.lerp(environment_config.water_color_night, t)
|
||||
base_rotation_sun = environment_config.sun_rotation_afternoon.lerp(environment_config.sun_rotation_night, t)
|
||||
|
||||
var weather_color = environment_config.rain_mode_color
|
||||
@@ -183,7 +173,6 @@ func _process(delta: float) -> void:
|
||||
var final_sky_horizon = base_sky_horizon.lerp(base_sky_horizon * weather_color, clamp(rain_intensity, 0.0, 1.0))
|
||||
var final_fog_color = base_fog_color.lerp(base_fog_color * weather_color, clamp(rain_intensity, 0.0, 1.0))
|
||||
var final_fog_density = lerp(base_fog_density, base_fog_density * 4.0, clamp(rain_intensity, 0.0, 1.0))
|
||||
var final_water_color = base_water_color.darkened(clamp(environment_config.water_darkening_rain, 0.0, 1.0) * clamp(rain_intensity, 0.0, 1.0))
|
||||
|
||||
final_tint = final_tint.lerp(final_tint * environment_config.snow_mode_color, actual_snow_amount)
|
||||
final_sky_top = final_sky_top.lerp(final_sky_top * environment_config.snow_mode_color, actual_snow_amount)
|
||||
@@ -197,7 +186,6 @@ func _process(delta: float) -> void:
|
||||
RenderingServer.global_shader_parameter_set("global_gradient_color_top", final_grad_top)
|
||||
RenderingServer.global_shader_parameter_set("global_gradient_color_bot", final_grad_bot)
|
||||
RenderingServer.global_shader_parameter_set("global_gradient_intensity", base_grad_intensity)
|
||||
RenderingServer.global_shader_parameter_set("global_water_color", final_water_color)
|
||||
|
||||
var night_val = clamp(day_time - 2.0, 0.0, 1.0)
|
||||
|
||||
@@ -277,23 +265,6 @@ func _get_weather_anchor_position() -> Variant:
|
||||
return camera.global_position
|
||||
return null
|
||||
|
||||
func _get_weather_anchor_basis() -> Variant:
|
||||
var source_basis: Basis
|
||||
if camera_pivot and is_instance_valid(camera_pivot):
|
||||
source_basis = camera_pivot.global_basis
|
||||
elif camera and is_instance_valid(camera):
|
||||
source_basis = camera.global_basis
|
||||
else:
|
||||
return null
|
||||
|
||||
var forward := -source_basis.z
|
||||
forward.y = 0.0
|
||||
if forward.length_squared() <= 0.0001:
|
||||
return Basis.IDENTITY
|
||||
forward = forward.normalized()
|
||||
var right := forward.cross(Vector3.UP).normalized()
|
||||
return Basis(right, Vector3.UP, -forward)
|
||||
|
||||
func _follow_camera() -> void:
|
||||
var cam_pos = _get_weather_anchor_position()
|
||||
if cam_pos == null:
|
||||
@@ -306,12 +277,6 @@ func _follow_camera() -> void:
|
||||
particles_wind.global_position = Vector3(cam_pos.x, cam_pos.y, cam_pos.z)
|
||||
if particles_fireflies:
|
||||
particles_fireflies.global_position = Vector3(cam_pos.x, particles_fireflies.position.y, cam_pos.z)
|
||||
if fog:
|
||||
fog.global_position = Vector3(cam_pos.x, fog.global_position.y, cam_pos.z)
|
||||
#used to follow camera pivot or camera
|
||||
var anchor_basis = _get_weather_anchor_basis()
|
||||
if anchor_basis != null:
|
||||
fog.global_basis = anchor_basis
|
||||
#endregion
|
||||
|
||||
#region Fireflies
|
||||
@@ -342,7 +307,6 @@ func toggle_wind(value: bool):
|
||||
particles_wind.emitting = is_windy
|
||||
|
||||
_apply_wind_state()
|
||||
_emit_weather_event_label()
|
||||
|
||||
#disable wind and set default values and materials
|
||||
func init_wind():
|
||||
@@ -446,51 +410,6 @@ func _update_wind_amount_from_strength(value: float) -> void:
|
||||
|
||||
environment_config.wind_amount = roundi(max_wind_amount * amount_ratio)
|
||||
|
||||
func trigger_random_weather_event(duration: float = 0.0) -> void:
|
||||
if random_weather_restore_tween and random_weather_restore_tween.is_valid():
|
||||
random_weather_restore_tween.kill()
|
||||
|
||||
var previous_rain: bool = is_raining
|
||||
var previous_snow: bool = is_snowing
|
||||
var previous_wind: bool = is_windy
|
||||
var previous_storm: bool = is_storm
|
||||
var random_event_index: int = randi_range(0, 3)
|
||||
match random_event_index:
|
||||
0:
|
||||
_apply_weather_event_state(false, true, false, false)
|
||||
1:
|
||||
_apply_weather_event_state(true, false, false, false)
|
||||
2:
|
||||
_apply_weather_event_state(false, false, true, false)
|
||||
_:
|
||||
_apply_weather_event_state(true, false, false, true)
|
||||
|
||||
if duration > 0.0:
|
||||
random_weather_restore_tween = create_tween()
|
||||
random_weather_restore_tween.tween_interval(duration)
|
||||
random_weather_restore_tween.tween_callback(func():
|
||||
_apply_weather_event_state(previous_rain, previous_snow, previous_wind, previous_storm)
|
||||
)
|
||||
|
||||
func _apply_weather_event_state(rain_enabled: bool, snow_enabled: bool, wind_enabled: bool, storm_enabled: bool = false) -> void:
|
||||
if is_storm and not storm_enabled:
|
||||
toggle_storm(false)
|
||||
if is_raining and not rain_enabled:
|
||||
toggle_rain(false)
|
||||
if is_snowing and not snow_enabled:
|
||||
toggle_snow(false)
|
||||
if is_windy and not wind_enabled:
|
||||
toggle_wind(false)
|
||||
|
||||
if not is_raining and rain_enabled:
|
||||
toggle_rain(true)
|
||||
if not is_snowing and snow_enabled:
|
||||
toggle_snow(true)
|
||||
if not is_windy and wind_enabled:
|
||||
toggle_wind(true)
|
||||
if not is_storm and storm_enabled:
|
||||
toggle_storm(true)
|
||||
|
||||
func _apply_cloud_config() -> void:
|
||||
var dir = environment_config.wind_direction
|
||||
var cloud_scale = environment_config.cloud_scale
|
||||
@@ -522,7 +441,6 @@ func _apply_cloud_config() -> void:
|
||||
|
||||
func toggle_storm(value: bool):
|
||||
is_storm = value
|
||||
_emit_weather_event_label()
|
||||
|
||||
#set lightning
|
||||
func init_lightning():
|
||||
@@ -636,7 +554,6 @@ func toggle_rain(value: bool):
|
||||
is_raining = value
|
||||
|
||||
if not particles_rain:
|
||||
_emit_weather_event_label()
|
||||
return
|
||||
|
||||
if is_raining and is_snowing:
|
||||
@@ -670,7 +587,6 @@ func toggle_rain(value: bool):
|
||||
trigger_after_rain())
|
||||
puddle_tween = create_tween()
|
||||
puddle_tween.tween_method(set_puddle_amount, puddle_amount, 0.0, environment_config.puddle_dry_time)
|
||||
_emit_weather_event_label()
|
||||
|
||||
func trigger_morning() -> void:
|
||||
spawn_single_godray()
|
||||
@@ -769,23 +685,6 @@ func toggle_snow(value: bool):
|
||||
snow_tween.kill()
|
||||
snow_tween = create_tween()
|
||||
snow_tween.tween_method(init_snow_amount, actual_snow_amount, target_snow_amount, environment_config.snow_transaction_time)
|
||||
_emit_weather_event_label()
|
||||
|
||||
func _emit_weather_event_label() -> void:
|
||||
var weather_label := "Weather: Clear"
|
||||
if is_storm:
|
||||
weather_label = "Weather: Storm"
|
||||
else:
|
||||
var active_events: Array[String] = []
|
||||
if is_snowing:
|
||||
active_events.append("Snow")
|
||||
if is_raining:
|
||||
active_events.append("Rain")
|
||||
if is_windy:
|
||||
active_events.append("Wind")
|
||||
if not active_events.is_empty():
|
||||
weather_label = "Weather: %s" % " + ".join(active_events)
|
||||
UIEvents.weather_event_changed.emit(weather_label)
|
||||
|
||||
#disable snow and set default values and shader
|
||||
func init_snow(value: float = 0.0):
|
||||
@@ -800,13 +699,6 @@ func init_snow(value: float = 0.0):
|
||||
RenderingServer.global_shader_parameter_set("global_snow_color", environment_config.snow_color)
|
||||
RenderingServer.global_shader_parameter_set("global_snow_accumulation_speed", environment_config.snow_accumulation_speed)
|
||||
RenderingServer.global_shader_parameter_set("global_snow_melt_speed", environment_config.snow_melt_speed)
|
||||
RenderingServer.global_shader_parameter_set("global_snow_max_accumulation", environment_config.snow_max_accumulation)
|
||||
RenderingServer.global_shader_parameter_set("global_snow_cap_enabled", environment_config.show_snow_accumulation_volume)
|
||||
RenderingServer.global_shader_parameter_set("global_snow_cap_height", environment_config.snow_cap_height)
|
||||
RenderingServer.global_shader_parameter_set("global_snow_cap_flatness_start", environment_config.snow_cap_flatness_start)
|
||||
RenderingServer.global_shader_parameter_set("global_snow_cap_flatness_end", environment_config.snow_cap_flatness_end)
|
||||
RenderingServer.global_shader_parameter_set("global_snow_cap_noise_scale", environment_config.snow_cap_noise_scale)
|
||||
RenderingServer.global_shader_parameter_set("global_snow_cap_noise_strength", environment_config.snow_cap_noise_strength)
|
||||
RenderingServer.global_shader_parameter_set("global_snow_start_time", -1.0)
|
||||
RenderingServer.global_shader_parameter_set("global_snow_melt_time", -1.0)
|
||||
|
||||
@@ -836,10 +728,6 @@ func toggle_blur(value: bool) -> void:
|
||||
|
||||
ApplyPostProcessBlurConfig()
|
||||
|
||||
func toggle_fog(value: bool) -> void:
|
||||
if fog:
|
||||
fog.visible = value
|
||||
|
||||
func toggle_shadows(value: bool) -> void:
|
||||
if environment_shadows:
|
||||
environment_shadows.visible = value
|
||||
|
||||
@@ -6,16 +6,8 @@ global uniform float global_snow_start_time = -1.0;
|
||||
global uniform float global_snow_accumulation_speed = 0.1;
|
||||
global uniform float global_snow_melt_time = -1.0;
|
||||
global uniform float global_snow_melt_speed = 0.1;
|
||||
global uniform float global_snow_amount = 0.0;
|
||||
global uniform float global_snow_threshold = 0.5;
|
||||
global uniform vec4 global_snow_color = vec4(0.92, 0.96, 1.0, 1.0);
|
||||
global uniform float global_snow_max_accumulation = 0.72;
|
||||
global uniform bool global_snow_cap_enabled = true;
|
||||
global uniform float global_snow_cap_height = 0.06;
|
||||
global uniform float global_snow_cap_flatness_start = 0.72;
|
||||
global uniform float global_snow_cap_flatness_end = 0.96;
|
||||
global uniform float global_snow_cap_noise_scale = 0.22;
|
||||
global uniform float global_snow_cap_noise_strength = 0.18;
|
||||
uniform float snow_noise_scale : hint_range(0.01, 1.0) = 0.15;
|
||||
uniform float snow_edge_softness : hint_range(0.01, 0.5) = 0.2;
|
||||
uniform float snow_roughness_variation : hint_range(0.0, 0.3) = 0.15;
|
||||
@@ -37,58 +29,6 @@ uniform float puddle_threshold : hint_range(0.0, 0.8) = 0.45;
|
||||
|
||||
uniform sampler2D noise_texture : filter_linear_mipmap, repeat_enable;
|
||||
|
||||
varying float v_snow_amount;
|
||||
varying float v_snow_cap_mask;
|
||||
|
||||
float hash(vec2 p) {
|
||||
return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453123);
|
||||
}
|
||||
|
||||
float value_noise(vec2 p) {
|
||||
vec2 i = floor(p);
|
||||
vec2 f = fract(p);
|
||||
vec2 u = f * f * (3.0 - 2.0 * f);
|
||||
|
||||
float a = hash(i);
|
||||
float b = hash(i + vec2(1.0, 0.0));
|
||||
float c = hash(i + vec2(0.0, 1.0));
|
||||
float d = hash(i + vec2(1.0, 1.0));
|
||||
|
||||
return mix(mix(a, b, u.x), mix(c, d, u.x), u.y);
|
||||
}
|
||||
|
||||
float fbm(vec2 p) {
|
||||
float value = 0.0;
|
||||
float amplitude = 0.5;
|
||||
float frequency = 1.0;
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
value += value_noise(p * frequency) * amplitude;
|
||||
frequency *= 2.0;
|
||||
amplitude *= 0.5;
|
||||
}
|
||||
|
||||
return clamp(value, 0.0, 1.0);
|
||||
}
|
||||
|
||||
float get_snow_progress() {
|
||||
bool has_snow_timeline = global_snow_start_time >= 0.0 || global_snow_melt_time >= 0.0;
|
||||
float snow_progress = clamp(global_snow_amount, 0.0, 1.0);
|
||||
|
||||
if (has_snow_timeline) {
|
||||
snow_progress = 0.0;
|
||||
if (global_snow_start_time >= 0.0) {
|
||||
snow_progress = clamp((TIME - global_snow_start_time) * global_snow_accumulation_speed, 0.0, 1.0);
|
||||
}
|
||||
if (global_snow_melt_time >= 0.0) {
|
||||
float melt = clamp((TIME - global_snow_melt_time) * global_snow_melt_speed, 0.0, 1.0);
|
||||
snow_progress *= (1.0 - melt);
|
||||
}
|
||||
}
|
||||
|
||||
return snow_progress;
|
||||
}
|
||||
|
||||
float ripple_ring(vec2 uv, float time_offset) {
|
||||
float d = length(uv);
|
||||
float ring = sin(d * 30.0 - TIME * ripple_speed + time_offset) * 0.5 + 0.5;
|
||||
@@ -96,27 +36,6 @@ float ripple_ring(vec2 uv, float time_offset) {
|
||||
return ring * fade;
|
||||
}
|
||||
|
||||
void vertex() {
|
||||
float snow_progress = get_snow_progress();
|
||||
float snow_accumulation = snow_progress * global_snow_max_accumulation;
|
||||
vec3 world_pos = (MODEL_MATRIX * vec4(VERTEX, 1.0)).xyz;
|
||||
vec3 world_normal = normalize((MODEL_MATRIX * vec4(NORMAL, 0.0)).xyz);
|
||||
|
||||
float flat_surface = smoothstep(
|
||||
max(global_snow_threshold, global_snow_cap_flatness_start),
|
||||
global_snow_cap_flatness_end,
|
||||
world_normal.y
|
||||
);
|
||||
float accumulation_growth = smoothstep(0.08, 0.65, snow_progress);
|
||||
float cap_noise = fbm(world_pos.xz * global_snow_cap_noise_scale + vec2(11.3, 4.7));
|
||||
float cap_variation = mix(1.0 - global_snow_cap_noise_strength, 1.0 + global_snow_cap_noise_strength, cap_noise);
|
||||
|
||||
v_snow_amount = snow_progress;
|
||||
v_snow_cap_mask = flat_surface * accumulation_growth * cap_variation * (global_snow_cap_enabled ? 1.0 : 0.0);
|
||||
|
||||
VERTEX += NORMAL * (global_snow_cap_height * snow_accumulation * v_snow_cap_mask);
|
||||
}
|
||||
|
||||
void fragment() {
|
||||
vec3 world_pos = (INV_VIEW_MATRIX * vec4(VERTEX, 1.0)).xyz;
|
||||
vec3 world_normal = normalize((INV_VIEW_MATRIX * vec4(NORMAL, 0.0)).xyz);
|
||||
@@ -124,23 +43,25 @@ void fragment() {
|
||||
float noise_val = texture(noise_texture, world_pos.xz * snow_noise_scale).r;
|
||||
|
||||
//Snow
|
||||
float snow_progress = v_snow_amount;
|
||||
float snow_accumulation = snow_progress * global_snow_max_accumulation;
|
||||
float snow_amount = 0.0;
|
||||
if (global_snow_start_time >= 0.0) {
|
||||
snow_amount = clamp((TIME - global_snow_start_time) * global_snow_accumulation_speed, 0.0, 1.0);
|
||||
}
|
||||
if (global_snow_melt_time >= 0.0) {
|
||||
float melt = clamp((TIME - global_snow_melt_time) * global_snow_melt_speed, 0.0, 1.0);
|
||||
snow_amount *= (1.0 - melt);
|
||||
}
|
||||
|
||||
float snow_edge = smoothstep(
|
||||
global_snow_threshold - snow_edge_softness,
|
||||
global_snow_threshold + snow_edge_softness,
|
||||
facing_up + (noise_val - 0.5) * 0.4
|
||||
);
|
||||
float flat_accumulation = smoothstep(0.0, 0.35, v_snow_cap_mask) * snow_accumulation;
|
||||
float snow_coverage = smoothstep(0.0, 0.6, noise_val + snow_progress - 0.4 + flat_accumulation * 0.25);
|
||||
float snow_factor = max(snow_edge * snow_coverage * snow_progress, flat_accumulation);
|
||||
float snow_opacity = smoothstep(0.04, 0.28, snow_factor);
|
||||
snow_opacity = max(snow_opacity, flat_accumulation * 0.9);
|
||||
float snow_coverage = smoothstep(0.0, 0.6, noise_val + snow_amount - 0.4);
|
||||
float snow_factor = snow_edge * snow_coverage * snow_amount;
|
||||
|
||||
float shade = mix(-snow_color_variation, snow_color_variation, noise_val);
|
||||
vec3 snow_albedo = clamp(global_snow_color.rgb + vec3(shade), 0.0, 1.0);
|
||||
snow_albedo = mix(snow_albedo, vec3(1.0), 0.18 + snow_opacity * 0.12);
|
||||
float snow_rough = mix(0.15 - snow_roughness_variation, 0.15 + snow_roughness_variation, noise_val);
|
||||
|
||||
//Rain
|
||||
@@ -252,7 +173,7 @@ void fragment() {
|
||||
ALBEDO = snow_albedo;
|
||||
ROUGHNESS = snow_rough;
|
||||
METALLIC = 0.0;
|
||||
ALPHA = snow_opacity;
|
||||
ALPHA = snow_factor;
|
||||
} else {
|
||||
ALBEDO = rain_albedo;
|
||||
ROUGHNESS = rain_rough;
|
||||
|
||||
@@ -7,13 +7,16 @@ global uniform float global_snow_accumulation_speed;
|
||||
global uniform float global_snow_melt_time;
|
||||
global uniform float global_snow_melt_speed;
|
||||
global uniform vec4 global_snow_color;
|
||||
|
||||
// Rain globals
|
||||
global uniform float global_rain_intensity;
|
||||
global uniform float global_rain_puddle_amount;
|
||||
|
||||
// Snow parameters
|
||||
uniform float snow_edge_softness : hint_range(0.01, 0.5) = 0.15;
|
||||
uniform float snow_color_variation : hint_range(0.0, 0.15) = 0.05;
|
||||
|
||||
|
||||
// Rain wetness parameters
|
||||
global uniform float global_rain_intensity;
|
||||
global uniform float global_rain_puddle_amount;
|
||||
uniform float ripple_scale : hint_range(0.1, 5.0) = 1.5;
|
||||
uniform float ripple_speed : hint_range(0.5, 5.0) = 2.0;
|
||||
uniform float ripple_layers : hint_range(1.0, 4.0) = 3.0;
|
||||
|
||||
@@ -1,21 +1,7 @@
|
||||
[gd_resource type="ShaderMaterial" format=3 uid="uid://b34bnqbrtxktw"]
|
||||
[gd_resource type="ShaderMaterial" format=3]
|
||||
|
||||
[ext_resource type="Shader" uid="uid://do8puw7u8dvry" path="res://core/daynight/weather_plain_shader.gdshader" id="1_weather_plain"]
|
||||
[ext_resource type="Texture2D" uid="uid://bpswbjh4jj1ou" path="res://core/daynight/noise.tres" id="2_noise"]
|
||||
[ext_resource type="Shader" path="res://core/daynight/weather_plain_shader.gdshader" id="1_weather_plain"]
|
||||
|
||||
[resource]
|
||||
render_priority = 0
|
||||
shader = ExtResource("1_weather_plain")
|
||||
shader_parameter/snow_edge_softness = 0.15
|
||||
shader_parameter/snow_color_variation = 0.05
|
||||
shader_parameter/ripple_scale = 1.5
|
||||
shader_parameter/ripple_speed = 2.0
|
||||
shader_parameter/ripple_layers = 3.0
|
||||
shader_parameter/streak_scale = 2.0
|
||||
shader_parameter/streak_speed = 0.8
|
||||
shader_parameter/wetness_darkening = 0.25
|
||||
shader_parameter/wet_roughness = 0.05
|
||||
shader_parameter/rain_normal_strength = 0.4
|
||||
shader_parameter/puddle_noise_scale = 0.08
|
||||
shader_parameter/puddle_threshold = 0.45
|
||||
shader_parameter/noise_texture = ExtResource("2_noise")
|
||||
|
||||
@@ -1,26 +1,31 @@
|
||||
shader_type spatial;
|
||||
render_mode unshaded;
|
||||
|
||||
// --- PARAMETRI ---
|
||||
uniform float time_scale = 3.0;
|
||||
uniform float wave_amplitude = 0.5; // Quanto curva a destra/sinistra
|
||||
uniform float wave_frequency = 1.0; // Ogni quanto fa la curva
|
||||
global uniform float global_wind_speed = 1.0; //0.0 = calm, 1.0 = normal, 2.0+ = strong
|
||||
global uniform vec2 global_wind_direction = vec2(1.0, 0.0);
|
||||
|
||||
uniform float wave_frequency = 1.0;
|
||||
uniform float base_amplitude = 0.5;
|
||||
uniform float secondary_ratio = 0.6;
|
||||
uniform float time_scale_base = 3.0;
|
||||
|
||||
void vertex() {
|
||||
// Creiamo un offset unico per ogni particella in modo che non si muovano tutte uguali
|
||||
float random_seed_offset = INSTANCE_CUSTOM.x * 100.0;
|
||||
float scaled_time = (TIME + random_seed_offset) * time_scale;
|
||||
|
||||
// Applichiamo SOLO la curva morbida all'asse X (o Z, a seconda di come orienti la scena)
|
||||
// Usiamo VERTEX.y per far sì che la curva si propaghi lungo tutta la lunghezza della scia
|
||||
VERTEX.x += sin(VERTEX.y * wave_frequency + scaled_time) * wave_amplitude;
|
||||
|
||||
// Niente più "VERTEX.y += t;", quindi niente più teletrasporti!
|
||||
float random_seed_offset = INSTANCE_CUSTOM.x * 100.0;
|
||||
float scaled_time = (TIME + random_seed_offset) * (time_scale_base * global_wind_speed);
|
||||
float amplitude = base_amplitude * global_wind_speed;
|
||||
|
||||
vec2 wind_dir = normalize(global_wind_direction);
|
||||
vec2 wind_perp = vec2(-wind_dir.y, wind_dir.x); //90° perpendicular
|
||||
|
||||
float primary_sway = sin(VERTEX.y * wave_frequency + scaled_time) * amplitude;
|
||||
float secondary_sway = sin(VERTEX.y * wave_frequency * 1.3 + scaled_time * 0.7 + 1.57)
|
||||
* (amplitude * secondary_ratio);
|
||||
|
||||
VERTEX.x += primary_sway * wind_dir.x + secondary_sway * wind_perp.x;
|
||||
VERTEX.z += primary_sway * wind_dir.y + secondary_sway * wind_perp.y;
|
||||
}
|
||||
|
||||
void fragment() {
|
||||
// Il colore e l'alpha (per lo spawn dolce e la morte lenta)
|
||||
// vengono comandati dalla Color Ramp del GPUParticles3D!
|
||||
ALBEDO = COLOR.rgb;
|
||||
ALPHA = COLOR.a;
|
||||
}
|
||||
@@ -81,9 +81,8 @@ extends Resource
|
||||
#Post-process effect toggles (initial values)
|
||||
@export_group("Post Process")
|
||||
@export var enable_dust: bool = false #Floating dust particles overlay
|
||||
@export var enable_blur: bool = true #Screen blur effect
|
||||
@export var enable_blur: bool = false #Screen blur effect
|
||||
@export var enable_environment_shadows: bool = true #Cloud shadow projection on terrain
|
||||
@export var enable_fog: bool = false #Enable fog around the train
|
||||
@export var blur_amount: float = 0.6
|
||||
|
||||
@export_group("Dust")
|
||||
@@ -134,27 +133,15 @@ extends Resource
|
||||
@export var godray_spawn_height: float = 5.0 #Y world position where god rays spawn
|
||||
@export var godray_scale: Vector3 = Vector3(2.0, 6.0, 2.0) #Scale of the god ray mesh
|
||||
|
||||
#Train start settings
|
||||
@export_group("Train Start")
|
||||
@export var train_start_from_random_position: bool = false #When enabled the train starts from a random offset on the rail curve instead of a stop
|
||||
@export_range(0, 64, 1, "or_greater") var train_start_stop_index: int = 1 #Stop index used for the train start when random start is disabled
|
||||
|
||||
#Snow settings
|
||||
@export_group("Snow")
|
||||
@export var snow_amount: float = 0.0 #Initial snow coverage amount (0.0 = none, 1.0 = full)
|
||||
@export var snow_transaction_time: float = 10.0 #Seconds for snow shader to fully transition in/out
|
||||
@export var snow_fade_time: float = 5.0 #Seconds for snow particles to fade in/out
|
||||
@export var snow_threshold: float = 0.4 #Normal Y threshold for snow accumulation on surfaces
|
||||
@export var snow_accumulation_speed: float = 0.014 #Accumulation speed: 0.1 -> 10s, 0.05 -> 20s, 0.02 -> 50s, 0.012 -> ~83s
|
||||
@export var snow_accumulation_speed: float = 0.02 #Accumulation speed: 0.1 -> 10s, 0.05 -> 20s, 0.02 -> 50s, 0.2 -> 5s
|
||||
@export var snow_melt_speed: float = 0.05 #Speed at which accumulated snow melts away
|
||||
@export var show_snow_accumulation_volume: bool = true #Enables vertex snow buildup; when false snow only changes surface color
|
||||
@export var snow_max_accumulation: float = 0.25 #Maximum accumulated snow factor applied to coverage and thickness
|
||||
@export var snow_color: Color = Color(0.9, 0.95, 1.0) #Albedo color of snow on surfaces
|
||||
@export var snow_cap_height: float = 0.03 #Maximum snow thickness extruded on flat surfaces
|
||||
@export var snow_cap_flatness_start: float = 0.85 #Surface normal Y where cap buildup starts
|
||||
@export var snow_cap_flatness_end: float = 0.96 #Surface normal Y where cap buildup reaches full effect
|
||||
@export var snow_cap_noise_scale: float = 0.22 #Noise scale used to vary the snow cap silhouette
|
||||
@export var snow_cap_noise_strength: float = 0.12 #How much the cap noise changes the accumulated thickness
|
||||
@export var snow_mode_color: Color = Color(0.556, 0.62, 0.683, 1.0) #Sky/light darkening color during snow
|
||||
|
||||
#Wind settings
|
||||
@@ -165,7 +152,7 @@ extends Resource
|
||||
@export var wind_direction: Vector2 = Vector2(0.5, 0.4) #Global wind direction (XZ)
|
||||
@export var wind_speed: float = 0.2 #Global wind animation speed
|
||||
@export var wind_scale: float = 0.025 #Global wind noise scale
|
||||
@export var wind_strength: float = 0.3 #Global wind displacement strength
|
||||
@export var wind_strength: float = 0.6 #Global wind displacement strength
|
||||
@export var cloud_scale: float = 0.5 #Cloud noise scale in sky shader
|
||||
@export var cloud_speed: float = 0.05 #Cloud movement speed in sky shader
|
||||
@export_range(0.01, 1.0) var cloud_scale_envshadows_rate: float = 0.01 #Cloud scale multiplier for environment shadows
|
||||
@@ -177,10 +164,3 @@ extends Resource
|
||||
@export var fireflies_amount: int = 60 #Number of firefly particles
|
||||
@export var fireflies_spawn_ray: float = 20.0 #Horizontal spawn radius
|
||||
@export var fireflies_spawn_height: float = 3.0 #Vertical spawn range
|
||||
|
||||
#Water settings
|
||||
@export_group("Water")
|
||||
@export var water_color_morning: Color = Color(0.285, 0.534, 0.487, 1.0) #Tint for morning
|
||||
@export var water_color_afternoon: Color = Color(0.889, 0.733, 0.205, 1.0) #Tint for afternoon (sunset)
|
||||
@export var water_color_night: Color = Color(0.728, 0.54, 0.986, 1.0); #Tint for night
|
||||
@export var water_darkening_rain: float = 0.7 #Percentage of darkening when is rainy
|
||||
|
||||
@@ -10,10 +10,6 @@ signal toggle_wind(value: bool)
|
||||
@warning_ignore("unused_signal")
|
||||
signal wind_change(value: float)
|
||||
@warning_ignore("unused_signal")
|
||||
signal trigger_random_weather(duration: float)
|
||||
@warning_ignore("unused_signal")
|
||||
signal weather_event_changed(description: String)
|
||||
@warning_ignore("unused_signal")
|
||||
signal toggle_fireflies(value: bool)
|
||||
@warning_ignore("unused_signal")
|
||||
signal toggle_storm(value: bool)
|
||||
@@ -27,8 +23,6 @@ signal toggle_dust(value: bool)
|
||||
signal toggle_blur(value: bool)
|
||||
@warning_ignore("unused_signal")
|
||||
signal toggle_shadows(value: bool)
|
||||
@warning_ignore("unused_signal")
|
||||
signal toggle_fog(value: bool)
|
||||
|
||||
#day cycle signals
|
||||
@warning_ignore("unused_signal")
|
||||
|
||||
@@ -349,30 +349,6 @@ theme_override_colors/font_outline_color = Color(1, 1, 1, 1)
|
||||
button_pressed = true
|
||||
text = "Shadows"
|
||||
|
||||
[node name="RandomWeather" type="Button" parent="Control" unique_id=1047710802]
|
||||
layout_mode = 0
|
||||
offset_left = 12.0
|
||||
offset_top = 289.0
|
||||
offset_right = 157.0
|
||||
offset_bottom = 320.0
|
||||
theme_override_colors/font_color = Color(1, 1, 1, 1)
|
||||
theme_override_colors/font_focus_color = Color(1, 1, 1, 1)
|
||||
theme_override_colors/font_pressed_color = Color(1, 1, 1, 1)
|
||||
theme_override_colors/font_hover_color = Color(1, 1, 1, 1)
|
||||
theme_override_colors/font_hover_pressed_color = Color(1, 1, 1, 1)
|
||||
theme_override_colors/font_outline_color = Color(1, 1, 1, 1)
|
||||
text = "Random Weather (10\")"
|
||||
|
||||
[node name="WeatherEventLabel" type="Label" parent="Control" unique_id=641424797]
|
||||
layout_mode = 0
|
||||
offset_left = 1656.0
|
||||
offset_top = 11.0
|
||||
offset_right = 1908.0
|
||||
offset_bottom = 34.0
|
||||
theme_override_colors/font_color = Color(1, 1, 1, 1)
|
||||
theme_override_colors/font_outline_color = Color(1, 1, 1, 1)
|
||||
text = "Weather: Clear"
|
||||
|
||||
[connection signal="toggled" from="Control/Snow" to="Control" method="_on_snow_toggled"]
|
||||
[connection signal="toggled" from="Control/Rain" to="Control" method="_on_rain_toggled"]
|
||||
[connection signal="toggled" from="Control/Wind" to="Control" method="_on_wind_toggled"]
|
||||
@@ -385,4 +361,3 @@ text = "Weather: Clear"
|
||||
[connection signal="toggled" from="Control/Blur" to="Control" method="_on_blur_toggled"]
|
||||
[connection signal="toggled" from="Control/Pause" to="Control" method="_on_pause_toggled"]
|
||||
[connection signal="toggled" from="Control/Shadows" to="Control" method="_on_shadows_toggled"]
|
||||
[connection signal="pressed" from="Control/RandomWeather" to="Control" method="_on_random_weather_pressed"]
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -1,7 +1,6 @@
|
||||
extends Control
|
||||
|
||||
@onready var day_night: EnvironmentManagerRoot = $"../DayNight"
|
||||
@onready var weather_event_label: Label = $WeatherEventLabel
|
||||
@onready var day_time_label: Label = $DayTimeLabel
|
||||
@onready var day_time_slider: HSlider = $DayTimeSlider
|
||||
@onready var wind_slider: HSlider = $WindSlider
|
||||
@@ -10,11 +9,9 @@ extends Control
|
||||
func _ready() -> void:
|
||||
UIEvents.day_time_changed.connect(_on_day_time_changed)
|
||||
UIEvents.day_time_option_changed.connect(_on_day_time_option_changed)
|
||||
UIEvents.weather_event_changed.connect(_on_weather_event_changed)
|
||||
if day_night != null and day_night.environment_config != null and wind_slider != null:
|
||||
wind_slider.set_value_no_signal(day_night.environment_config.wind_strength)
|
||||
_sync_day_time_ui()
|
||||
_on_weather_event_changed("Weather: Clear")
|
||||
|
||||
func _on_rain_toggled(toggled_on: bool) -> void:
|
||||
UIEvents.toggle_rain.emit(toggled_on)
|
||||
@@ -28,13 +25,10 @@ func _on_wind_toggled(toggled_on: bool) -> void:
|
||||
func _on_wind_slider_value_changed(value: float) -> void:
|
||||
UIEvents.wind_change.emit(value)
|
||||
|
||||
func _on_random_weather_pressed() -> void:
|
||||
UIEvents.trigger_random_weather.emit(10.0)
|
||||
|
||||
func _on_fireflies_toggled(toggled_on: bool) -> void:
|
||||
UIEvents.toggle_fireflies.emit(toggled_on)
|
||||
|
||||
func _on_storm_toggled(toggled_on: bool) -> void:
|
||||
func _on_storm_toggled(toggled_on: bool) -> void:
|
||||
UIEvents.toggle_storm.emit(toggled_on)
|
||||
|
||||
func _on_day_time_slider_value_changed(value: float) -> void:
|
||||
@@ -51,10 +45,6 @@ func _on_day_time_changed(value: float, time_string: String) -> void:
|
||||
label_text = "Time %s | nt %.3f | dt %.3f" % [time_string, value, day_night.day_time]
|
||||
day_time_label.text = label_text
|
||||
|
||||
func _on_weather_event_changed(description: String) -> void:
|
||||
if weather_event_label:
|
||||
weather_event_label.text = description
|
||||
|
||||
func _on_fog_overlay_toggled(toggled_on: bool) -> void:
|
||||
UIEvents.toggle_fog_overlay.emit(toggled_on)
|
||||
|
||||
@@ -96,6 +86,3 @@ func _on_day_time_option_changed(index: int) -> void:
|
||||
|
||||
func _on_option_button_item_selected(index: int) -> void:
|
||||
UIEvents.time_option_item_changed.emit(index)
|
||||
|
||||
func _on_fog_toggled(toggled_on: bool) -> void:
|
||||
UIEvents.toggle_fog.emit(toggled_on)
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -11,9 +11,8 @@ config_version=5
|
||||
[application]
|
||||
|
||||
config/name="tgcc"
|
||||
run/main_scene="uid://38qpxwbpvd28"
|
||||
run/main_scene="uid://cae0mnf353dy3"
|
||||
config/features=PackedStringArray("4.6", "Forward Plus")
|
||||
run/max_fps=60
|
||||
config/icon="uid://bfar1kk3pgq8f"
|
||||
|
||||
[autoload]
|
||||
@@ -24,7 +23,6 @@ UIEvents="*uid://dehu28iq27mbn"
|
||||
|
||||
window/size/viewport_width=1920
|
||||
window/size/viewport_height=1080
|
||||
window/size/mode=3
|
||||
window/stretch/mode="canvas_items"
|
||||
window/stretch/aspect="expand"
|
||||
|
||||
@@ -114,35 +112,3 @@ global_wind_fade={
|
||||
"type": "float",
|
||||
"value": 1.2
|
||||
}
|
||||
global_snow_cap_height={
|
||||
"type": "float",
|
||||
"value": 0.0
|
||||
}
|
||||
global_snow_cap_flatness_start={
|
||||
"type": "float",
|
||||
"value": 0.0
|
||||
}
|
||||
global_snow_cap_flatness_end={
|
||||
"type": "float",
|
||||
"value": 0.0
|
||||
}
|
||||
global_snow_cap_noise_scale={
|
||||
"type": "float",
|
||||
"value": 0.0
|
||||
}
|
||||
global_snow_cap_noise_strength={
|
||||
"type": "float",
|
||||
"value": 0.0
|
||||
}
|
||||
global_snow_max_accumulation={
|
||||
"type": "float",
|
||||
"value": 0.0
|
||||
}
|
||||
global_snow_cap_enabled={
|
||||
"type": "bool",
|
||||
"value": false
|
||||
}
|
||||
global_water_color={
|
||||
"type": "color",
|
||||
"value": Color(0, 0, 0, 1)
|
||||
}
|
||||
|
||||
@@ -110,7 +110,7 @@ surface_material_override/1 = ExtResource("4_w66q1")
|
||||
surface_material_override/0 = ExtResource("4_w66q1")
|
||||
surface_material_override/1 = ExtResource("6_333a0")
|
||||
|
||||
[node name="MSH_Staccioanta_1_001" parent="." index="8" unique_id=2137478487 groups=["weather_node"]]
|
||||
[node name="MSH_Staccioanta_1_001" parent="." index="8" unique_id=2137478487]
|
||||
surface_material_override/0 = ExtResource("7_333a0")
|
||||
|
||||
[node name="Palo_001" parent="." index="9" unique_id=1395117968]
|
||||
|
||||
@@ -60,7 +60,7 @@ surface_material_override/1 = ExtResource("2_6ig2p")
|
||||
[node name="Grass_009" parent="." index="1" unique_id=629886419]
|
||||
surface_material_override/0 = ExtResource("2_6ig2p")
|
||||
|
||||
[node name="MSH_Staccioanta_1_009" parent="." index="2" unique_id=802806256 groups=["weather_node"]]
|
||||
[node name="MSH_Staccioanta_1_009" parent="." index="2" unique_id=802806256]
|
||||
surface_material_override/0 = ExtResource("3_wjrum")
|
||||
|
||||
[node name="Strada_007" parent="." index="3" unique_id=1200357449 groups=["weather_node"]]
|
||||
|
||||
@@ -103,7 +103,7 @@ surface_material_override/1 = ExtResource("4_yg4ko")
|
||||
[node name="MSH_Staccioanta_1_007" parent="." index="8" unique_id=166305032]
|
||||
surface_material_override/0 = ExtResource("6_k52wx")
|
||||
|
||||
[node name="PaliLuci_003" parent="." index="9" unique_id=718749193 groups=["weather_node"]]
|
||||
[node name="PaliLuci_003" parent="." index="9" unique_id=718749193]
|
||||
surface_material_override/0 = ExtResource("7_yg4ko")
|
||||
surface_material_override/1 = ExtResource("7_yg4ko")
|
||||
|
||||
|
||||
@@ -91,7 +91,7 @@ visible = false
|
||||
[node name="FlowerG_003" parent="." index="5" unique_id=65871813 groups=["weather_node", "wind_node"]]
|
||||
visible = false
|
||||
|
||||
[node name="Grass_008" parent="." index="6" unique_id=1853173495]
|
||||
[node name="Grass_008" parent="." index="6" unique_id=1853173495 groups=["weather_vegetables_node", "wind_node"]]
|
||||
surface_material_override/0 = ExtResource("2_cltnj")
|
||||
|
||||
[node name="House_M_3" parent="." index="7" unique_id=155596536 groups=["weather_node"]]
|
||||
@@ -104,14 +104,14 @@ surface_material_override/1 = ExtResource("7_0r8cm")
|
||||
surface_material_override/0 = ExtResource("7_0r8cm")
|
||||
surface_material_override/1 = ExtResource("6_pjysl")
|
||||
|
||||
[node name="MSH_Staccioanta_1_005" parent="." index="9" unique_id=1042751383 groups=["weather_node"]]
|
||||
[node name="MSH_Staccioanta_1_005" parent="." index="9" unique_id=1042751383]
|
||||
surface_material_override/0 = ExtResource("8_hmdr4")
|
||||
|
||||
[node name="PaliLuci_002" parent="." index="10" unique_id=1504995410]
|
||||
surface_material_override/0 = ExtResource("3_aj7xj")
|
||||
surface_material_override/1 = ExtResource("3_aj7xj")
|
||||
|
||||
[node name="Panchina_002" parent="." index="11" unique_id=876085859 groups=["weather_node"]]
|
||||
[node name="Panchina_002" parent="." index="11" unique_id=876085859]
|
||||
surface_material_override/0 = ExtResource("8_hmdr4")
|
||||
|
||||
[node name="Strada_006" parent="." index="12" unique_id=76888486 groups=["weather_node"]]
|
||||
|
||||
@@ -154,7 +154,7 @@ south = true
|
||||
[node name="Argini_005" parent="." index="0" unique_id=255857931]
|
||||
surface_material_override/0 = ExtResource("2_t65ww")
|
||||
|
||||
[node name="Bags" parent="." index="1" unique_id=2117673123]
|
||||
[node name="Bags" parent="." index="1" unique_id=2117673123 groups=["weather_node"]]
|
||||
surface_material_override/0 = SubResource("ShaderMaterial_q2s76")
|
||||
|
||||
[node name="Cart" parent="." index="2" unique_id=884973125]
|
||||
@@ -191,14 +191,14 @@ surface_material_override/0 = ExtResource("5_sy58u")
|
||||
surface_material_override/1 = ExtResource("5_sy58u")
|
||||
surface_material_override/2 = ExtResource("6_eev23")
|
||||
|
||||
[node name="Statue" parent="." index="11" unique_id=1814801509]
|
||||
[node name="Statue" parent="." index="11" unique_id=1814801509 groups=["weather_node"]]
|
||||
surface_material_override/0 = ExtResource("5_sy58u")
|
||||
surface_material_override/1 = ExtResource("7_q2s76")
|
||||
|
||||
[node name="Water_006" parent="." index="12" unique_id=1352334701]
|
||||
surface_material_override/0 = ExtResource("10_r4bww")
|
||||
|
||||
[node name="WoodPile" parent="." index="13" unique_id=1088104699]
|
||||
[node name="WoodPile" parent="." index="13" unique_id=1088104699 groups=["weather_node"]]
|
||||
surface_material_override/0 = ExtResource("11_iulsg")
|
||||
surface_material_override/1 = ExtResource("12_ytk0o")
|
||||
surface_material_override/2 = SubResource("ShaderMaterial_ytk0o")
|
||||
|
||||
@@ -2,13 +2,13 @@
|
||||
|
||||
[ext_resource type="Shader" uid="uid://8l8glwvvs7fb" path="res://core/daynight/grass_leaves.gdshader" id="1_yw70r"]
|
||||
[ext_resource type="Texture2D" uid="uid://bm0roy74xo3ce" path="res://tgcc/chunk/prop/flower/bush_alpha.png" id="2_rv6bf"]
|
||||
[ext_resource type="Texture2D" uid="uid://bkuv31yvqmqr2" path="res://tgcc/chunk/prop/flower/bush_colornoise.tres" id="3_t3pfi"]
|
||||
[ext_resource type="Texture2D" path="res://tgcc/chunk/prop/flower/bush_colornoise.tres" id="3_t3pfi"]
|
||||
|
||||
[resource]
|
||||
render_priority = 0
|
||||
shader = ExtResource("1_yw70r")
|
||||
shader_parameter/billboard_enabled = true
|
||||
shader_parameter/wind_enabled = true
|
||||
shader_parameter/wind_enabled = false
|
||||
shader_parameter/base_color = Color(0.2509804, 0.44705883, 0.20392157, 1)
|
||||
shader_parameter/alpha_texture = ExtResource("2_rv6bf")
|
||||
shader_parameter/leaves_scale = 0.65
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
render_priority = 0
|
||||
shader = ExtResource("1_28e45")
|
||||
shader_parameter/billboard_enabled = true
|
||||
shader_parameter/wind_enabled = true
|
||||
shader_parameter/wind_enabled = false
|
||||
shader_parameter/base_color = Color(0, 0.42745098, 0.9843137, 1)
|
||||
shader_parameter/alpha_texture = ExtResource("2_4kf4f")
|
||||
shader_parameter/leaves_scale = 0.365
|
||||
|
||||
@@ -16,7 +16,7 @@ seamless = true
|
||||
render_priority = 0
|
||||
shader = ExtResource("1_a5yde")
|
||||
shader_parameter/billboard_enabled = true
|
||||
shader_parameter/wind_enabled = true
|
||||
shader_parameter/wind_enabled = false
|
||||
shader_parameter/base_color = Color(0.3882353, 0.52156866, 0.20784314, 1)
|
||||
shader_parameter/alpha_texture = ExtResource("2_4hc02")
|
||||
shader_parameter/leaves_scale = 0.65
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
render_priority = 0
|
||||
shader = ExtResource("1_0cuwq")
|
||||
shader_parameter/billboard_enabled = true
|
||||
shader_parameter/wind_enabled = true
|
||||
shader_parameter/wind_enabled = false
|
||||
shader_parameter/base_color = Color(0.103467666, 0.34917185, 0.14285779, 1)
|
||||
shader_parameter/alpha_texture = ExtResource("2_ldsj3")
|
||||
shader_parameter/leaves_scale = 0.92
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
render_priority = 0
|
||||
shader = ExtResource("1_vpd27")
|
||||
shader_parameter/billboard_enabled = true
|
||||
shader_parameter/wind_enabled = true
|
||||
shader_parameter/wind_enabled = false
|
||||
shader_parameter/base_color = Color(0.14700681, 0.45590013, 0.22758594, 1)
|
||||
shader_parameter/alpha_texture = ExtResource("2_wl0p2")
|
||||
shader_parameter/leaves_scale = 0.46
|
||||
@@ -21,4 +21,3 @@ shader_parameter/highlight_intensity = 0.0
|
||||
shader_parameter/light_steps = 10.0
|
||||
shader_parameter/random_mix = 0.010000000475
|
||||
shader_parameter/cast_shadow_strength = 0.6
|
||||
shader_parameter/wetness_darkening = 0.25
|
||||
|
||||
@@ -35,13 +35,13 @@ size = Vector3(20, 10, 20)
|
||||
|
||||
[node name="chunk_railway_straight" unique_id=1509029322 instance=ExtResource("1_koika")]
|
||||
|
||||
[node name="Chunk_001" parent="." index="0" unique_id=1290410887 groups=["weather_node", "wind_node"]]
|
||||
[node name="Chunk_001" parent="." index="0" unique_id=1122765659]
|
||||
surface_material_override/0 = ExtResource("1_bdsfm")
|
||||
|
||||
[node name="Chunk_020" parent="." index="1" unique_id=107670766]
|
||||
[node name="Chunk_020" parent="." index="1" unique_id=467050080]
|
||||
surface_material_override/0 = ExtResource("2_1yd65")
|
||||
|
||||
[node name="Cube_159" parent="." index="2" unique_id=334311805 groups=["weather_node"]]
|
||||
[node name="Cube_159" parent="." index="2" unique_id=1552861257]
|
||||
surface_material_override/0 = ExtResource("3_dldiy")
|
||||
surface_material_override/1 = ExtResource("4_5cqaj")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user