Merge branch 'main' into ai_and_photo_mode
This commit is contained in:
5
core/biome_generator/biome.gd
Normal file
5
core/biome_generator/biome.gd
Normal file
@@ -0,0 +1,5 @@
|
||||
extends Resource
|
||||
class_name Biome
|
||||
|
||||
@export var name: String = "New Biome"
|
||||
@export var available_chunks: Array[PackedScene]
|
||||
1
core/biome_generator/biome.gd.uid
Normal file
1
core/biome_generator/biome.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://wv6kcqkibium
|
||||
852
core/biome_generator/biome_generator.gd
Normal file
852
core/biome_generator/biome_generator.gd
Normal file
@@ -0,0 +1,852 @@
|
||||
extends Node3D
|
||||
|
||||
const CHUNK_TYPE_BIOME: int = 0
|
||||
const CHUNK_TYPE_STRAIGHT_TRACK: int = 1
|
||||
const CHUNK_TYPE_CURVED_TRACK: int = 2
|
||||
|
||||
const CHUNK_GENERATION_STEPS_PER_FRAME: int = 2
|
||||
const CHUNK_CLEANUP_STEPS_PER_FRAME: int = 4
|
||||
const LAMPPOST_WIRE_STEPS_PER_FRAME: int = 1
|
||||
const RAILWAY_SCENE_DIRECTORY: String = "res://tgcc/chunk/railway/scene"
|
||||
|
||||
@export_group("Rails")
|
||||
@export var rail_path: Path3D
|
||||
|
||||
@export_group("Biomes")
|
||||
@export var biome_list: Array[Biome]
|
||||
|
||||
@export_group("Grid and Area")
|
||||
@export var chunk_size: float = 20.0
|
||||
@export var eye_line: int = 3
|
||||
@export var district_scale: float = 0.05
|
||||
|
||||
@export_group("Lamppost")
|
||||
@export var lamppost_wire_material: ShaderMaterial
|
||||
@export_range(0.01, 1.0) var wire_thickness: float = 0.05
|
||||
@export var lamppost_dist_factor: int = 10
|
||||
|
||||
var board: Dictionary = {}
|
||||
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 rail_chunk_catalogue: Dictionary = {}
|
||||
|
||||
var manual_biome: Biome = null
|
||||
|
||||
func _ready() -> void:
|
||||
if biome_list.is_empty() or rail_path == null: return
|
||||
|
||||
#connect events
|
||||
UIEvents.update_rail_chunks.connect(_update_rail_chunks)
|
||||
|
||||
noise_generator = FastNoiseLite.new()
|
||||
noise_generator.noise_type = FastNoiseLite.TYPE_PERLIN
|
||||
noise_generator.seed = randi()
|
||||
noise_generator.frequency = district_scale
|
||||
|
||||
altitude_generator = FastNoiseLite.new()
|
||||
altitude_generator.noise_type = FastNoiseLite.TYPE_PERLIN
|
||||
altitude_generator.seed = randi()
|
||||
altitude_generator.frequency = district_scale * 0.5
|
||||
|
||||
_warm_chunk_candidate_cache()
|
||||
_warm_rail_chunk_catalogue()
|
||||
_update_set_pieces()
|
||||
|
||||
func _update_set_pieces() -> void:
|
||||
var set_pieces = get_tree().get_nodes_in_group("set_pieces")
|
||||
|
||||
print("🔍 Found ", set_pieces.size(), " in 'set_pieces' group.")
|
||||
|
||||
for sp in set_pieces:
|
||||
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
|
||||
else:
|
||||
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()
|
||||
sp.process_mode = Node.PROCESS_MODE_INHERIT
|
||||
print(" ✅ Temple is visible.")
|
||||
else:
|
||||
sp.hide()
|
||||
sp.process_mode = Node.PROCESS_MODE_DISABLED
|
||||
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()
|
||||
|
||||
#Clean board and wire connections
|
||||
board.clear()
|
||||
wire_connections.clear()
|
||||
|
||||
#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(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
|
||||
|
||||
func _physics_process(_delta: float) -> void:
|
||||
if rail_path == null or rail_path.train_instance == null: return
|
||||
|
||||
var train_pos = rail_path.train_instance.global_position
|
||||
var grid_x = roundi(train_pos.x / chunk_size)
|
||||
var grid_z = roundi(train_pos.z / chunk_size)
|
||||
var current_pos = Vector2i(grid_x, grid_z)
|
||||
|
||||
if current_pos != last_pos_train:
|
||||
last_pos_train = current_pos
|
||||
_refresh_world(current_pos)
|
||||
pending_radar_update = true
|
||||
|
||||
func collect_all_chunkinfo(root: Node, list: Array[Node]) -> void:
|
||||
if root == null: return
|
||||
|
||||
if root.has_method("get_rotated_data") or "have_lamppost" in root:
|
||||
list.append(root)
|
||||
|
||||
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 _warm_rail_chunk_catalogue() -> void:
|
||||
rail_chunk_catalogue.clear()
|
||||
|
||||
var directory := DirAccess.open(RAILWAY_SCENE_DIRECTORY)
|
||||
if directory == null:
|
||||
return
|
||||
|
||||
directory.list_dir_begin()
|
||||
var file_name := directory.get_next()
|
||||
while file_name != "":
|
||||
if not directory.current_is_dir() and file_name.ends_with(".tscn"):
|
||||
var scene_path := "%s/%s" % [RAILWAY_SCENE_DIRECTORY, file_name]
|
||||
var scene := load(scene_path) as PackedScene
|
||||
if scene != null:
|
||||
var chunk_type = _get_chunk_type_from_scene(scene)
|
||||
if chunk_type == CHUNK_TYPE_STRAIGHT_TRACK or chunk_type == CHUNK_TYPE_CURVED_TRACK:
|
||||
if not rail_chunk_catalogue.has(chunk_type):
|
||||
rail_chunk_catalogue[chunk_type] = []
|
||||
rail_chunk_catalogue[chunk_type].append(scene)
|
||||
file_name = directory.get_next()
|
||||
directory.list_dir_end()
|
||||
|
||||
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 _get_chunk_type_from_scene(scene: PackedScene) -> int:
|
||||
if scene == null:
|
||||
return CHUNK_TYPE_BIOME
|
||||
|
||||
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
|
||||
var chunk_type = CHUNK_TYPE_BIOME
|
||||
if info_node != null and "chunk_type" in info_node:
|
||||
chunk_type = info_node.chunk_type
|
||||
preview_chunk.queue_free()
|
||||
return chunk_type
|
||||
|
||||
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 _collect_replaceable_rail_chunks(root: Node, result: Array[Node3D]) -> void:
|
||||
if root == null:
|
||||
return
|
||||
|
||||
if root is Node3D:
|
||||
var node_3d := root as Node3D
|
||||
if node_3d.scene_file_path.begins_with(RAILWAY_SCENE_DIRECTORY):
|
||||
var info_list: Array[Node] = []
|
||||
collect_all_chunkinfo(node_3d, info_list)
|
||||
var info_node = info_list[0] if info_list.size() > 0 else null
|
||||
if info_node != null and "chunk_type" in info_node:
|
||||
var chunk_type = info_node.chunk_type
|
||||
if chunk_type == CHUNK_TYPE_STRAIGHT_TRACK or chunk_type == CHUNK_TYPE_CURVED_TRACK:
|
||||
result.append(node_3d)
|
||||
return
|
||||
|
||||
for child in root.get_children():
|
||||
_collect_replaceable_rail_chunks(child, result)
|
||||
|
||||
func _pick_replacement_rail_scene(chunk_type: int, current_scene_path: String) -> PackedScene:
|
||||
var candidates: Array = rail_chunk_catalogue.get(chunk_type, [])
|
||||
if candidates.is_empty():
|
||||
return null
|
||||
|
||||
var alternatives: Array[PackedScene] = []
|
||||
for candidate in candidates:
|
||||
var scene := candidate as PackedScene
|
||||
if scene != null and scene.resource_path != current_scene_path:
|
||||
alternatives.append(scene)
|
||||
|
||||
if not alternatives.is_empty():
|
||||
return alternatives.pick_random()
|
||||
return candidates.pick_random() as PackedScene
|
||||
|
||||
func _replace_rail_chunk_instance(chunk_root: Node3D) -> bool:
|
||||
if chunk_root == null or not is_instance_valid(chunk_root):
|
||||
return false
|
||||
|
||||
var info_list: Array[Node] = []
|
||||
collect_all_chunkinfo(chunk_root, info_list)
|
||||
var info_node = info_list[0] if info_list.size() > 0 else null
|
||||
if info_node == null or not "chunk_type" in info_node:
|
||||
return false
|
||||
|
||||
var replacement_scene = _pick_replacement_rail_scene(info_node.chunk_type, chunk_root.scene_file_path)
|
||||
if replacement_scene == null:
|
||||
return false
|
||||
|
||||
var chunk_parent = chunk_root.get_parent()
|
||||
var replacement = replacement_scene.instantiate() as Node3D
|
||||
if chunk_parent == null or replacement == null:
|
||||
return false
|
||||
|
||||
var chunk_index = chunk_root.get_index()
|
||||
var chunk_name = chunk_root.name
|
||||
chunk_root.name = "%s_old" % chunk_name
|
||||
|
||||
replacement.transform = chunk_root.transform
|
||||
chunk_parent.add_child(replacement)
|
||||
chunk_parent.move_child(replacement, chunk_index)
|
||||
replacement.name = chunk_name
|
||||
replacement.owner = chunk_root.owner
|
||||
chunk_root.queue_free()
|
||||
return true
|
||||
|
||||
func _refresh_rail_chunks() -> void:
|
||||
print("update rail chunks")
|
||||
_warm_rail_chunk_catalogue()
|
||||
|
||||
var current_scene: Node = get_tree().current_scene
|
||||
if current_scene == null:
|
||||
return
|
||||
|
||||
var replaceable_chunks: Array[Node3D] = []
|
||||
_collect_replaceable_rail_chunks(current_scene, replaceable_chunks)
|
||||
|
||||
var replaced_count = 0
|
||||
for chunk_root in replaceable_chunks:
|
||||
if _replace_rail_chunk_instance(chunk_root):
|
||||
replaced_count += 1
|
||||
|
||||
if replaced_count > 0:
|
||||
await get_tree().process_frame
|
||||
_destroy_and_regenrate_world()
|
||||
|
||||
func _update_rail_chunks() -> void:
|
||||
call_deferred("_refresh_rail_chunks")
|
||||
|
||||
func _refresh_world(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:
|
||||
_add_compatible_biome(grid_pos)
|
||||
|
||||
func _choose_catalogue_by_cell(grid_pos: Vector2i) -> Array[PackedScene]:
|
||||
if manual_biome != null:
|
||||
return manual_biome.available_chunks
|
||||
|
||||
var value = noise_generator.get_noise_2d(grid_pos.x, grid_pos.y)
|
||||
var normalized_value = (value + 1.0) / 2.0
|
||||
var indice = clamp(int(normalized_value * biome_list.size()), 0, biome_list.size() - 1)
|
||||
return biome_list[indice].available_chunks
|
||||
|
||||
func _get_procedural_biome_name(value: float) -> String:
|
||||
if manual_biome != null:
|
||||
return manual_biome.name
|
||||
|
||||
var normalized_value = (value + 1.0) / 2.0
|
||||
var index = clamp(int(normalized_value * biome_list.size()), 0, biome_list.size() - 1)
|
||||
return biome_list[index].name
|
||||
|
||||
func _register_cell_with_ray(grid_pos: Vector2i) -> bool:
|
||||
if board.has(grid_pos): return true
|
||||
|
||||
var world_pos = Vector3(grid_pos.x * chunk_size, 0, grid_pos.y * chunk_size)
|
||||
var space_state = get_world_3d().direct_space_state
|
||||
var ray_origin = Vector3(world_pos.x, 50.0, world_pos.z)
|
||||
var ray_end = Vector3(world_pos.x, -10.0, world_pos.z)
|
||||
|
||||
var query = PhysicsRayQueryParameters3D.create(ray_origin, ray_end)
|
||||
var result = space_state.intersect_ray(query)
|
||||
|
||||
if result.size() > 0:
|
||||
var collider = result["collider"]
|
||||
var root_chunk = collider
|
||||
var info_list: Array[Node] = []
|
||||
|
||||
#Find parent node
|
||||
while root_chunk != null and root_chunk != get_tree().root:
|
||||
collect_all_chunkinfo(root_chunk, info_list)
|
||||
if info_list.size() > 0:
|
||||
break
|
||||
root_chunk = root_chunk.get_parent()
|
||||
|
||||
var right_info_node = null
|
||||
|
||||
#Find closest chunk to the ray
|
||||
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)
|
||||
var dist = center_cell_pos.distance_to(pos_info)
|
||||
|
||||
if dist < min_distance:
|
||||
min_distance = dist
|
||||
right_info_node = info
|
||||
|
||||
#If no node is found use first element
|
||||
if right_info_node == null and info_list.size() > 0:
|
||||
right_info_node = info_list[0]
|
||||
|
||||
var exit_found = {"north": false, "est": false, "south": false, "west": false}
|
||||
var river_exit_found = {"north": false, "est": false, "south": false, "west": false}
|
||||
var height_found = {"north": 0, "est": 0, "south": 0, "west": 0}
|
||||
var have_lamppost = false
|
||||
|
||||
#Get node info
|
||||
if right_info_node != null:
|
||||
if right_info_node.has_method("get_rotated_data"):
|
||||
var rotation_steps = roundi(rad_to_deg(right_info_node.global_rotation.y) / -90.0)
|
||||
var data = right_info_node.get_rotated_data(rotation_steps)
|
||||
exit_found = data["connections"]
|
||||
river_exit_found = data["river_connections"]
|
||||
height_found = data["heights"]
|
||||
|
||||
if "have_lamppost" in right_info_node:
|
||||
have_lamppost = right_info_node.have_lamppost
|
||||
|
||||
#Add piece to the grid
|
||||
board[grid_pos] = {
|
||||
"type": "obstacle",
|
||||
"exit": exit_found,
|
||||
"river_exit": river_exit_found,
|
||||
"heights": height_found,
|
||||
"node": root_chunk,
|
||||
"info": right_info_node,
|
||||
"have_lamppost": have_lamppost
|
||||
}
|
||||
|
||||
if have_lamppost:
|
||||
_queue_lamppost_wire_connection(grid_pos)
|
||||
|
||||
return true
|
||||
return false
|
||||
|
||||
func _add_compatible_biome(grid_pos: Vector2i) -> void:
|
||||
var req_conn_north = _needed_connection(grid_pos + Vector2i(0, -1), "south")
|
||||
var req_conn_est = _needed_connection(grid_pos + Vector2i(1, 0), "west")
|
||||
var req_conn_south = _needed_connection(grid_pos + Vector2i(0, 1), "north")
|
||||
var req_conn_west = _needed_connection(grid_pos + Vector2i(-1, 0), "est")
|
||||
var req_river_north = _needed_river_connection(grid_pos + Vector2i(0, -1), "south")
|
||||
var req_river_est = _needed_river_connection(grid_pos + Vector2i(1, 0), "west")
|
||||
var req_river_south = _needed_river_connection(grid_pos + Vector2i(0, 1), "north")
|
||||
var req_river_west = _needed_river_connection(grid_pos + Vector2i(-1, 0), "est")
|
||||
|
||||
var req_height_north = _needed_heights(grid_pos + Vector2i(0, -1), "south")
|
||||
var req_height_est = _needed_heights(grid_pos + Vector2i(1, 0), "west")
|
||||
var req_height_south = _needed_heights(grid_pos + Vector2i(0, 1), "north")
|
||||
var req_height_west = _needed_heights(grid_pos + Vector2i(-1, 0), "est")
|
||||
|
||||
var height_noise = altitude_generator.get_noise_2d(grid_pos.x, grid_pos.y)
|
||||
var height_target = clamp(roundi((height_noise + 1.0) / 2.0), 0, 1)
|
||||
|
||||
var zone_catalogue = _choose_catalogue_by_cell(grid_pos)
|
||||
var valid_candidates = []
|
||||
|
||||
for scene in zone_catalogue:
|
||||
var metadata = _get_chunk_scene_metadata(scene)
|
||||
if metadata.is_empty():
|
||||
continue
|
||||
|
||||
for candidate in metadata["rotations"]:
|
||||
var rot = candidate["rotation"]
|
||||
var data = candidate["data"]
|
||||
var u_conn = data["connections"]
|
||||
var u_river_conn = data["river_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_river_n = (req_river_north == -1) or ((req_river_north == 1) == u_river_conn["north"])
|
||||
var match_river_e = (req_river_est == -1) or ((req_river_est == 1) == u_river_conn["est"])
|
||||
var match_river_s = (req_river_south == -1) or ((req_river_south == 1) == u_river_conn["south"])
|
||||
var match_river_o = (req_river_west == -1) or ((req_river_west == 1) == u_river_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_river_n and match_river_e and match_river_s and match_river_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})
|
||||
|
||||
if valid_candidates.size() > 0:
|
||||
var max_score = -1
|
||||
for c in valid_candidates:
|
||||
if c.score > max_score: max_score = c.score
|
||||
|
||||
var best_candidate = []
|
||||
for c in valid_candidates:
|
||||
if c.score == max_score: best_candidate.append(c)
|
||||
|
||||
var choise = best_candidate.pick_random()
|
||||
var new_chunk = choise.scene.instantiate()
|
||||
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 have_lamppost = false
|
||||
if info_new != null and "have_lamppost" in info_new:
|
||||
have_lamppost = info_new.have_lamppost
|
||||
|
||||
board[grid_pos] = {
|
||||
"type": "bioma",
|
||||
"exit": choise.data["connections"],
|
||||
"river_exit": choise.data["river_connections"],
|
||||
"heights": choise.data["heights"],
|
||||
"node": new_chunk,
|
||||
"info": info_new,
|
||||
"have_lamppost": have_lamppost
|
||||
}
|
||||
|
||||
if have_lamppost:
|
||||
_queue_lamppost_wire_connection(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)
|
||||
|
||||
var info_backup = _get_cached_chunk_info(backup, zone_catalogue[0])
|
||||
|
||||
var safe_heights = {
|
||||
"north": req_height_north if req_height_north != -1 else height_target,
|
||||
"est": req_height_est if req_height_est != -1 else height_target,
|
||||
"south": req_height_south if req_height_south != -1 else height_target,
|
||||
"west": req_height_west if req_height_west != -1 else height_target
|
||||
}
|
||||
board[grid_pos] = {
|
||||
"type": "biome",
|
||||
"exit": {"north":false, "est":false, "south":false, "west":false},
|
||||
"river_exit": {"north":false, "est":false, "south":false, "west":false},
|
||||
"heights": safe_heights,
|
||||
"node": backup,
|
||||
"info": info_backup,
|
||||
"have_lamppost": false
|
||||
}
|
||||
|
||||
func _needed_connection(near_pos: Vector2i, side_needed: String) -> int:
|
||||
if not board.has(near_pos):
|
||||
_register_cell_with_ray(near_pos)
|
||||
if board.has(near_pos) and board[near_pos].has("exit"):
|
||||
return 1 if board[near_pos]["exit"][side_needed] else 0
|
||||
return -1
|
||||
|
||||
func _needed_river_connection(near_pos: Vector2i, side_needed: String) -> int:
|
||||
if not board.has(near_pos):
|
||||
_register_cell_with_ray(near_pos)
|
||||
if board.has(near_pos) and board[near_pos].has("river_exit"):
|
||||
return 1 if board[near_pos]["river_exit"][side_needed] else 0
|
||||
return -1
|
||||
|
||||
func _needed_heights(near_pos: Vector2i, side_needed: String) -> int:
|
||||
if board.has(near_pos) and board[near_pos].has("heights"):
|
||||
return board[near_pos]["heights"][side_needed]
|
||||
return -1
|
||||
|
||||
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)
|
||||
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)
|
||||
return lampposts
|
||||
|
||||
func _connect_lamppost_wires(new_board_pos: Vector2i) -> void:
|
||||
var new_cell = board[new_board_pos]
|
||||
var new_root = new_cell["node"]
|
||||
var new_info = new_cell["info"]
|
||||
|
||||
if new_info == null: return
|
||||
if new_info is Node3D: new_info.force_update_transform()
|
||||
|
||||
var new_sx = _get_lampposts(new_info, "sx")
|
||||
var new_dx = _get_lampposts(new_info, "dx")
|
||||
if new_sx.is_empty() or new_dx.is_empty(): return
|
||||
|
||||
var new_id = new_root.get_instance_id()
|
||||
if not wire_connections.has(new_id): wire_connections[new_id] = 0
|
||||
|
||||
if wire_connections[new_id] >= 2: return
|
||||
|
||||
var p_sx_my_best = null; var p_dx_my_best = null
|
||||
var p_sx_your_best = null; var p_dx_your_best = null
|
||||
var best_closest_to_root = null
|
||||
var best_distance = 999999.0
|
||||
var ray_research = 6
|
||||
|
||||
for x in range(-ray_research, ray_research + 1):
|
||||
for z in range(-ray_research, ray_research + 1):
|
||||
if x == 0 and z == 0: continue
|
||||
|
||||
var closest_post = new_board_pos + Vector2i(x, z)
|
||||
if board.has(closest_post) and board[closest_post].get("have_lamppost", false):
|
||||
var closest_root = board[closest_post]["node"]
|
||||
var closest_info = board[closest_post]["info"]
|
||||
|
||||
if not is_instance_valid(closest_root) or closest_root == new_root or closest_info == null: continue
|
||||
|
||||
var closest_id = closest_root.get_instance_id()
|
||||
var closest_connections = wire_connections.get(closest_id, 0)
|
||||
|
||||
if closest_connections >= 2: continue
|
||||
|
||||
if closest_info is Node3D: closest_info.force_update_transform()
|
||||
var closest_sx = _get_lampposts(closest_info, "sx")
|
||||
var closest_dx = _get_lampposts(closest_info, "dx")
|
||||
if closest_sx.is_empty() or closest_dx.is_empty(): continue
|
||||
|
||||
for i_m in range(new_sx.size()):
|
||||
for i_t in range(closest_sx.size()):
|
||||
var my_c = (new_sx[i_m].global_position + new_dx[i_m].global_position) / 2.0
|
||||
var your_c = (closest_sx[i_t].global_position + closest_dx[i_t].global_position) / 2.0
|
||||
var dist = my_c.distance_to(your_c)
|
||||
|
||||
if dist < best_distance:
|
||||
best_distance = dist
|
||||
best_closest_to_root = closest_root
|
||||
p_sx_my_best = new_sx[i_m]
|
||||
p_dx_my_best = new_dx[i_m]
|
||||
p_sx_your_best = closest_sx[i_t]
|
||||
p_dx_your_best = closest_dx[i_t]
|
||||
|
||||
if best_closest_to_root == null:
|
||||
for x in range(-ray_research, ray_research + 1):
|
||||
for z in range(-ray_research, ray_research + 1):
|
||||
if x == 0 and z == 0: continue
|
||||
|
||||
var closest_pos = new_board_pos + Vector2i(x, z)
|
||||
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()
|
||||
var closest_sx = _get_lampposts(closest_info, "sx")
|
||||
var closest_dx = _get_lampposts(closest_info, "dx")
|
||||
if closest_sx.is_empty() or closest_dx.is_empty(): continue
|
||||
|
||||
for i_m in range(new_sx.size()):
|
||||
for i_t in range(closest_sx.size()):
|
||||
var c_mio = (new_sx[i_m].global_position + new_dx[i_m].global_position) / 2.0
|
||||
var c_tuo = (closest_sx[i_t].global_position + closest_dx[i_t].global_position) / 2.0
|
||||
var dist = c_mio.distance_to(c_tuo)
|
||||
|
||||
if dist < best_distance:
|
||||
best_distance = dist
|
||||
best_closest_to_root = closest_root
|
||||
p_sx_my_best = new_sx[i_m]
|
||||
p_dx_my_best = new_dx[i_m]
|
||||
p_sx_your_best = closest_sx[i_t]
|
||||
p_dx_your_best = closest_dx[i_t]
|
||||
|
||||
var max_dist = chunk_size * lamppost_dist_factor
|
||||
|
||||
if best_closest_to_root != null and best_distance < max_dist:
|
||||
var dist_streight = p_sx_my_best.global_position.distance_to(p_sx_your_best.global_position) + p_dx_my_best.global_position.distance_to(p_dx_your_best.global_position)
|
||||
var dist_cross = p_sx_my_best.global_position.distance_to(p_dx_your_best.global_position) + p_dx_my_best.global_position.distance_to(p_sx_your_best.global_position)
|
||||
|
||||
if dist_streight <= dist_cross:
|
||||
_draw_parable(p_sx_my_best.global_position, p_sx_your_best.global_position, new_root)
|
||||
_draw_parable(p_dx_my_best.global_position, p_dx_your_best.global_position, new_root)
|
||||
else:
|
||||
_draw_parable(p_sx_my_best.global_position, p_dx_your_best.global_position, new_root)
|
||||
_draw_parable(p_dx_my_best.global_position, p_sx_your_best.global_position, new_root)
|
||||
|
||||
wire_connections[new_id] += 1
|
||||
var closest_id = best_closest_to_root.get_instance_id()
|
||||
if not wire_connections.has(closest_id): wire_connections[closest_id] = 0
|
||||
wire_connections[closest_id] += 1
|
||||
|
||||
#draw lamppost
|
||||
func _draw_parable(p1: Vector3, p2: Vector3, parent: Node3D) -> void:
|
||||
var segments = 15
|
||||
var lowering = 1.5
|
||||
var curve_points = []
|
||||
var sag_factors = []
|
||||
|
||||
for i in range(segments + 1):
|
||||
var t = float(i) / float(segments)
|
||||
var global_post = p1.lerp(p2, t)
|
||||
var gravity = lowering * (1.0 - pow(2.0 * t - 1.0, 2.0))
|
||||
global_post.y -= gravity
|
||||
|
||||
curve_points.append(parent.to_local(global_post))
|
||||
sag_factors.append(sin(t * PI))
|
||||
|
||||
var st = SurfaceTool.new()
|
||||
st.begin(Mesh.PRIMITIVE_TRIANGLES)
|
||||
|
||||
var lati = 4
|
||||
var ray = wire_thickness / 2.0
|
||||
|
||||
for i in range(curve_points.size() - 1):
|
||||
var p_current = curve_points[i]
|
||||
var p_next = curve_points[i+1]
|
||||
var sag_currnet = sag_factors[i]
|
||||
var sag_next = sag_factors[i+1]
|
||||
|
||||
var dir = (p_next - p_current).normalized()
|
||||
var up = Vector3.UP
|
||||
var right = dir.cross(up).normalized()
|
||||
if right.length_squared() < 0.01:
|
||||
right = dir.cross(Vector3.RIGHT).normalized()
|
||||
up = right.cross(dir).normalized()
|
||||
|
||||
for s in range(lati):
|
||||
var ang1 = (float(s) / lati) * TAU
|
||||
var ang2 = (float((s + 1) % lati) / lati) * TAU
|
||||
var offset1 = (right * cos(ang1) + up * sin(ang1)) * ray
|
||||
var offset2 = (right * cos(ang2) + up * sin(ang2)) * ray
|
||||
|
||||
st.set_color(Color(sag_currnet, 0, 0, 1))
|
||||
st.add_vertex(p_current + offset1)
|
||||
st.set_color(Color(sag_currnet, 0, 0, 1))
|
||||
st.add_vertex(p_current + offset2)
|
||||
st.set_color(Color(sag_next, 0, 0, 1))
|
||||
st.add_vertex(p_next + offset1)
|
||||
|
||||
st.set_color(Color(sag_currnet, 0, 0, 1))
|
||||
st.add_vertex(p_current + offset2)
|
||||
st.set_color(Color(sag_next, 0, 0, 1))
|
||||
st.add_vertex(p_next + offset2)
|
||||
st.set_color(Color(sag_next, 0, 0, 1))
|
||||
st.add_vertex(p_next + offset1)
|
||||
|
||||
var wire_node = MeshInstance3D.new()
|
||||
wire_node.mesh = st.commit()
|
||||
if lamppost_wire_material: wire_node.material_override = lamppost_wire_material
|
||||
parent.add_child(wire_node)
|
||||
1
core/biome_generator/biome_generator.gd.uid
Normal file
1
core/biome_generator/biome_generator.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://ct2k25kslaxe5
|
||||
8
core/biome_generator/biome_generator.tscn
Normal file
8
core/biome_generator/biome_generator.tscn
Normal file
@@ -0,0 +1,8 @@
|
||||
[gd_scene format=3 uid="uid://ujv2f1l4d2ps"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://ct2k25kslaxe5" path="res://core/biome_generator/biome_generator.gd" id="1_c7ilo"]
|
||||
[ext_resource type="Material" uid="uid://b8p1sjxisi522" path="res://core/biome_generator/wires.tres" id="2_w42pm"]
|
||||
|
||||
[node name="biome_generator" type="Node3D" unique_id=1861369341]
|
||||
script = ExtResource("1_c7ilo")
|
||||
lamppost_wire_material = ExtResource("2_w42pm")
|
||||
64
core/biome_generator/chunk_info.gd
Normal file
64
core/biome_generator/chunk_info.gd
Normal file
@@ -0,0 +1,64 @@
|
||||
extends Node3D
|
||||
class_name ChunkInfo
|
||||
|
||||
@export_enum("Biome", "straight_track", "curved_track") var chunk_type: int = 0
|
||||
|
||||
@export_group("Set Piece Rules (Unique pieces)")
|
||||
@export var exclusive_biome: String = "" # Es: "Forest"
|
||||
|
||||
@export_group("Base exit")
|
||||
@export var north: bool = false
|
||||
@export var est: bool = false
|
||||
@export var south: bool = false
|
||||
@export var west: bool = false
|
||||
|
||||
@export_group("River exit")
|
||||
@export var river_north: bool = false
|
||||
@export var river_est: bool = false
|
||||
@export var river_south: bool = false
|
||||
@export var river_west: bool = false
|
||||
|
||||
@export_group("Margin heights (level 0, 1, 2)")
|
||||
@export_range(0, 2, 1) var height_north: int = 0
|
||||
@export_range(0, 2, 1) var height_est: int = 0
|
||||
@export_range(0, 2, 1) var height_south: int = 0
|
||||
@export_range(0, 2, 1) var height_west: int = 0
|
||||
|
||||
@export_group("Lamppost")
|
||||
@export var have_lamppost: bool = false
|
||||
@export var connection_left: Array[Node3D]
|
||||
@export var connection_right: Array[Node3D]
|
||||
|
||||
func _ready() -> void:
|
||||
if exclusive_biome != "":
|
||||
add_to_group("set_pieces")
|
||||
|
||||
func get_rotated_data(steps_90: int) -> Dictionary:
|
||||
var original_exit = [north, est, south, west]
|
||||
var original_river_exit = [river_north, river_est, river_south, river_west]
|
||||
var original_height = [height_north, height_est, height_south, height_west]
|
||||
|
||||
var calculated_exit = []
|
||||
var calculated_river_exit = []
|
||||
var calculated_height = []
|
||||
|
||||
for i in range(4):
|
||||
var index = (i - steps_90 + 4) % 4
|
||||
calculated_exit.append(original_exit[index])
|
||||
calculated_river_exit.append(original_river_exit[index])
|
||||
calculated_height.append(original_height[index])
|
||||
|
||||
return {
|
||||
"connections": {
|
||||
"north": calculated_exit[0], "est": calculated_exit[1],
|
||||
"south": calculated_exit[2], "west": calculated_exit[3]
|
||||
},
|
||||
"river_connections": {
|
||||
"north": calculated_river_exit[0], "est": calculated_river_exit[1],
|
||||
"south": calculated_river_exit[2], "west": calculated_river_exit[3]
|
||||
},
|
||||
"heights": {
|
||||
"north": calculated_height[0], "est": calculated_height[1],
|
||||
"south": calculated_height[2], "west": calculated_height[3]
|
||||
}
|
||||
}
|
||||
1
core/biome_generator/chunk_info.gd.uid
Normal file
1
core/biome_generator/chunk_info.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://dg2h4kbqe8j3m
|
||||
437
core/biome_generator/rails.gd
Normal file
437
core/biome_generator/rails.gd
Normal file
@@ -0,0 +1,437 @@
|
||||
extends Path3D
|
||||
|
||||
@export_group("Train")
|
||||
@export var train_speed: float = 6.0
|
||||
@export var is_inmotion: bool = true
|
||||
@export var train_model: PackedScene
|
||||
@export var axes_distance: float = 3.0
|
||||
@export var rail_distance: float = 1.2
|
||||
@export var cameras: Node3D
|
||||
@export_range(0.0, 1.0) var basic_swing: float = 0.1
|
||||
|
||||
@export_group("Rails Bulding")
|
||||
@export var sleepers_distance: float = 1.0
|
||||
@export var sleepers_model: PackedScene
|
||||
|
||||
@export_group("Manual Controls")
|
||||
@export var speed_max: float = 15.0
|
||||
@export var speed_min: float = -5.0
|
||||
@export var manual_acceleration: float = 5.0
|
||||
|
||||
@export_group("Train Stops")
|
||||
@export var enable_stops: bool = true
|
||||
@export var stop_time: float = 4.0
|
||||
@export var brake_distance: float = 15.0
|
||||
@export var restart_time: float = 3.0
|
||||
@export var fireworks_scene: PackedScene
|
||||
|
||||
var fireworks_colors: Array[Color] = [
|
||||
Color(1.0, 0.2, 0.2), # Rosso vivo
|
||||
Color(0.2, 1.0, 0.2), # Verde lime
|
||||
Color(0.3, 0.5, 1.0), # Blu cielo
|
||||
Color(1.0, 0.8, 0.1), # Oro
|
||||
Color(0.8, 0.2, 1.0), # Viola
|
||||
Color(0.1, 1.0, 0.9) # Ciano
|
||||
]
|
||||
|
||||
var train_instance: Node3D
|
||||
var train_progress: float = 0.0
|
||||
var swing_time: float = 0.0
|
||||
var curve_roll: float = 0.0
|
||||
var curve_pitch: float = 0.0
|
||||
|
||||
var stop_offset: Array[float] = []
|
||||
var stops_position: Array[Vector3] = []
|
||||
var stop_ongoing: bool = false
|
||||
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)
|
||||
var mat_iron = StandardMaterial3D.new()
|
||||
mat_iron.albedo_color = Color(0.6, 0.6, 0.65)
|
||||
mat_iron.metallic = 0.8
|
||||
|
||||
var mesh_sleeper = BoxMesh.new()
|
||||
mesh_sleeper.size = Vector3(rail_distance + 0.6, 0.1, 0.3)
|
||||
var mesh_rail = BoxMesh.new()
|
||||
mesh_rail.size = Vector3(0.1, 0.15, sleepers_distance + 0.05)
|
||||
|
||||
var total_length = curve.get_baked_length()
|
||||
var piece_number = int(total_length / sleepers_distance)
|
||||
|
||||
for i in range(piece_number):
|
||||
var distance = i * sleepers_distance
|
||||
var rail_piece = Node3D.new()
|
||||
add_child(rail_piece)
|
||||
|
||||
var local_pos = curve.sample_baked(distance, true)
|
||||
var distance_forward = distance + 0.1
|
||||
var local_pos_forward = Vector3.ZERO
|
||||
|
||||
if distance_forward > total_length:
|
||||
var pos_back = curve.sample_baked(distance - 0.1, true)
|
||||
local_pos_forward = local_pos + (local_pos - pos_back)
|
||||
else:
|
||||
local_pos_forward = curve.sample_baked(distance_forward, true)
|
||||
|
||||
rail_piece.position = local_pos
|
||||
var global_pos = to_global(local_pos)
|
||||
var global_pos_forward = to_global(local_pos_forward)
|
||||
if global_pos.distance_to(global_pos_forward) > 0.001:
|
||||
rail_piece.look_at(global_pos_forward, Vector3.UP)
|
||||
|
||||
if sleepers_model != null:
|
||||
var sleeper_custom = sleepers_model.instantiate()
|
||||
rail_piece.add_child(sleeper_custom)
|
||||
else:
|
||||
var sleeper = MeshInstance3D.new()
|
||||
sleeper.mesh = mesh_sleeper
|
||||
sleeper.material_override = mat_wood
|
||||
rail_piece.add_child(sleeper)
|
||||
|
||||
var rail_sx = MeshInstance3D.new()
|
||||
rail_sx.mesh = mesh_rail
|
||||
rail_sx.material_override = mat_iron
|
||||
rail_sx.position = Vector3(-rail_distance / 2.0, 0.1, 0)
|
||||
rail_piece.add_child(rail_sx)
|
||||
|
||||
var rail_dx = MeshInstance3D.new()
|
||||
rail_dx.mesh = mesh_rail
|
||||
rail_dx.material_override = mat_iron
|
||||
rail_dx.position = Vector3(rail_distance / 2.0, 0.1, 0)
|
||||
rail_piece.add_child(rail_dx)
|
||||
|
||||
func _plan_stops() -> void:
|
||||
var current_stops = []
|
||||
for child in get_children():
|
||||
if child is Marker3D:
|
||||
var offset = curve.get_closest_offset(child.position)
|
||||
current_stops.append({
|
||||
"offset": offset,
|
||||
"position": child.global_position
|
||||
})
|
||||
current_stops.sort_custom(func(a, b): return a["offset"] < b["offset"])
|
||||
for data in current_stops:
|
||||
stop_offset.append(data["offset"])
|
||||
stops_position.append(data["position"])
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if event is InputEventKey and event.pressed and not event.echo:
|
||||
if event.keycode == KEY_T:
|
||||
_goto_next_stop()
|
||||
elif event.keycode == KEY_F:
|
||||
_test_manual_fireworks()
|
||||
|
||||
func _test_manual_fireworks() -> void:
|
||||
if fireworks_scene == null or train_instance == null: return
|
||||
|
||||
var firework_number = randi_range(5, 8)
|
||||
for i in range(firework_number):
|
||||
var fire_root = fireworks_scene.instantiate()
|
||||
get_tree().current_scene.add_child(fire_root)
|
||||
|
||||
var offset_x = randf_range(-6.0, 6.0)
|
||||
var offset_z = randf_range(-6.0, 6.0)
|
||||
fire_root.global_position = train_instance.global_position + Vector3(offset_x, 0.5, offset_z)
|
||||
|
||||
if fire_root.has_method("set_color"):
|
||||
fire_root.set_color(fireworks_colors.pick_random())
|
||||
if fire_root.has_method("turn_on"):
|
||||
fire_root.turn_on()
|
||||
|
||||
await get_tree().create_timer(randf_range(0.2, 0.6)).timeout
|
||||
|
||||
func _goto_next_stop() -> void:
|
||||
if stop_offset.size() == 0 or stop_ongoing or is_restarting:
|
||||
return
|
||||
var target_offset = stop_offset[next_stop_index]
|
||||
train_progress = target_offset
|
||||
_execute_stop(train_speed >= 0)
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
input_controls_management(delta)
|
||||
train_move(delta)
|
||||
|
||||
func input_controls_management(delta: float) -> void:
|
||||
if not is_inmotion: return
|
||||
if Input.is_action_pressed("ui_up"):
|
||||
train_speed += manual_acceleration * delta
|
||||
elif Input.is_action_pressed("ui_down"):
|
||||
train_speed -= manual_acceleration * delta
|
||||
elif Input.is_action_pressed("ui_text_backspace"):
|
||||
train_speed = 0
|
||||
train_speed = clamp(train_speed, speed_min, speed_max)
|
||||
|
||||
func train_move(delta: float) -> void:
|
||||
if is_inmotion and train_instance and curve:
|
||||
var total_length = curve.get_baked_length()
|
||||
if total_length <= 0: return
|
||||
|
||||
if not stop_ongoing:
|
||||
var last_progress = train_progress
|
||||
|
||||
if enable_stops and stop_offset.size() > 0 and not is_restarting:
|
||||
var target_offset = stop_offset[next_stop_index]
|
||||
var dist = target_offset - train_progress
|
||||
dist = wrapf(dist + total_length / 2.0, 0.0, total_length) - total_length / 2.0
|
||||
|
||||
if abs(dist) < brake_distance and sign(dist) == sign(train_speed):
|
||||
var t = abs(dist) / brake_distance
|
||||
stop_multiply = max(smoothstep(0.0, 1.0, t), 0.05)
|
||||
else:
|
||||
stop_multiply = 1.0
|
||||
|
||||
var current_speed = train_speed * stop_multiply
|
||||
train_progress += current_speed * delta
|
||||
|
||||
if enable_stops and stop_offset.size() > 0:
|
||||
var target_offset = stop_offset[next_stop_index]
|
||||
var exceeded_forward = (current_speed > 0 and last_progress < target_offset and train_progress >= target_offset)
|
||||
var exceeded_back = (current_speed < 0 and last_progress > target_offset and train_progress <= target_offset)
|
||||
|
||||
if exceeded_forward or exceeded_back:
|
||||
train_progress = target_offset
|
||||
_execute_stop(current_speed > 0)
|
||||
|
||||
if train_progress > total_length:
|
||||
train_progress -= total_length
|
||||
if stop_offset.size() > 0: next_stop_index = 0
|
||||
elif train_progress < 0:
|
||||
train_progress += total_length
|
||||
if stop_offset.size() > 0: next_stop_index = stop_offset.size() - 1
|
||||
|
||||
var center_position = to_global(curve.sample_baked(train_progress, true))
|
||||
var prog_back = wrapf(train_progress - 2.0, 0.0, total_length)
|
||||
var back_position = to_global(curve.sample_baked(prog_back, true))
|
||||
var prog_forward = wrapf(train_progress + 2.0, 0.0, total_length)
|
||||
var forward_position = to_global(curve.sample_baked(prog_forward, true))
|
||||
|
||||
if center_position.distance_to(forward_position) > 0.01:
|
||||
train_instance.global_position = center_position
|
||||
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
|
||||
|
||||
var real_speed = abs(train_speed * stop_multiply)
|
||||
var speed_factor = clamp(real_speed / max(speed_max, 0.001), 0.0, 1.0)
|
||||
var dir_prev = (center_position - back_position).normalized()
|
||||
var dir_next = (forward_position - center_position).normalized()
|
||||
var signed_curve = dir_prev.cross(dir_next).y
|
||||
var curve_amount = clamp(abs(signed_curve) * 8.0, 0.0, 1.0)
|
||||
|
||||
curve_roll = lerp(curve_roll, (-signed_curve * 0.08) * speed_factor, delta * 4.0)
|
||||
curve_pitch = lerp(curve_pitch, curve_amount * 0.012 * speed_factor, delta * 4.0)
|
||||
|
||||
if not stop_ongoing:
|
||||
swing_time += delta * real_speed * (2.0 + curve_amount)
|
||||
var amplitude_z = 0.006 * basic_swing
|
||||
var amplitude_x = 0.004 * basic_swing
|
||||
var curve_sway = sin(swing_time * 1.35) * 0.01 * curve_amount * speed_factor
|
||||
train_instance.rotation.z += sin(swing_time) * amplitude_z
|
||||
train_instance.rotation.x += cos(swing_time * 0.8) * amplitude_x
|
||||
train_instance.rotation.z += curve_roll + curve_sway
|
||||
train_instance.rotation.x += curve_pitch
|
||||
else:
|
||||
train_instance.rotation.z += curve_roll
|
||||
train_instance.rotation.x += curve_pitch
|
||||
|
||||
func _execute_stop(go_forward: bool = true) -> void:
|
||||
stop_ongoing = true
|
||||
stop_multiply = 0.0
|
||||
|
||||
var current_stop_index = next_stop_index
|
||||
|
||||
if go_forward:
|
||||
next_stop_index += 1
|
||||
if next_stop_index >= stop_offset.size():
|
||||
next_stop_index = 0
|
||||
else:
|
||||
next_stop_index -= 1
|
||||
if next_stop_index < 0:
|
||||
next_stop_index = stop_offset.size() - 1
|
||||
|
||||
if fireworks_scene != null:
|
||||
var marker_position = stops_position[current_stop_index]
|
||||
var firework_number = randi_range(5, 8)
|
||||
for i in range(firework_number):
|
||||
var fire_root = fireworks_scene.instantiate()
|
||||
get_tree().current_scene.add_child(fire_root)
|
||||
|
||||
var offset_x = randf_range(-5.0, 5.0)
|
||||
var offset_z = randf_range(-5.0, 5.0)
|
||||
|
||||
fire_root.global_position = marker_position + Vector3(offset_x, 0.5, offset_z)
|
||||
|
||||
if fire_root.has_method("set_color"):
|
||||
fire_root.set_color(fireworks_colors.pick_random())
|
||||
if fire_root.has_method("turn_on"):
|
||||
fire_root.turn_on()
|
||||
|
||||
await get_tree().create_timer(randf_range(0.3, 0.8)).timeout
|
||||
|
||||
await get_tree().create_timer(stop_time).timeout
|
||||
|
||||
stop_ongoing = false
|
||||
is_restarting = true
|
||||
|
||||
if tween_restart and tween_restart.is_valid():
|
||||
tween_restart.kill()
|
||||
|
||||
tween_restart = create_tween()
|
||||
tween_restart.set_trans(Tween.TRANS_SINE).set_ease(Tween.EASE_IN_OUT)
|
||||
tween_restart.tween_property(self, "stop_multiply", 1.0, restart_time)
|
||||
tween_restart.tween_callback(func(): is_restarting = false)
|
||||
|
||||
func build_train() -> void:
|
||||
if train_model != null:
|
||||
train_instance = train_model.instantiate()
|
||||
add_child(train_instance)
|
||||
else:
|
||||
build_default_train()
|
||||
|
||||
func build_default_train() -> void:
|
||||
train_instance = Node3D.new()
|
||||
add_child(train_instance)
|
||||
|
||||
var mat_body = StandardMaterial3D.new()
|
||||
mat_body.albedo_color = Color(0.8, 0.15, 0.15)
|
||||
var mat_glass = StandardMaterial3D.new()
|
||||
mat_glass.albedo_color = Color(0.2, 0.8, 1.0)
|
||||
|
||||
var train_base = MeshInstance3D.new()
|
||||
var mesh_base = BoxMesh.new()
|
||||
mesh_base.size = Vector3(1.4, 0.8, 3.0)
|
||||
train_base.mesh = mesh_base
|
||||
train_base.material_override = mat_body
|
||||
train_base.position = Vector3(0, 0.6, 0)
|
||||
train_instance.add_child(train_base)
|
||||
|
||||
var cabin = MeshInstance3D.new()
|
||||
var mesh_cabin = BoxMesh.new()
|
||||
mesh_cabin.size = Vector3(1.4, 1.0, 1.2)
|
||||
cabin.mesh = mesh_cabin
|
||||
cabin.material_override = mat_glass
|
||||
cabin.position = Vector3(0, 1.5, -0.8)
|
||||
train_instance.add_child(cabin)
|
||||
|
||||
var stack = MeshInstance3D.new()
|
||||
var mesh_stack = CylinderMesh.new()
|
||||
mesh_stack.top_radius = 0.2
|
||||
mesh_stack.bottom_radius = 0.3
|
||||
mesh_stack.height = 0.8
|
||||
stack.mesh = mesh_stack
|
||||
stack.material_override = mat_body
|
||||
stack.position = Vector3(0, 1.2, 1.0)
|
||||
train_instance.add_child(stack)
|
||||
1
core/biome_generator/rails.gd.uid
Normal file
1
core/biome_generator/rails.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://dboerd4a6dwj7
|
||||
32
core/biome_generator/wires.gdshader
Normal file
32
core/biome_generator/wires.gdshader
Normal file
@@ -0,0 +1,32 @@
|
||||
shader_type spatial;
|
||||
render_mode blend_mix, depth_draw_opaque, cull_disabled;
|
||||
|
||||
//Wire color
|
||||
uniform vec4 albedo_color : source_color = vec4(0.1, 0.1, 0.1, 1.0);
|
||||
|
||||
global uniform float global_wind_strength;
|
||||
global uniform float global_wind_speed;
|
||||
global uniform float global_wind_fade;
|
||||
|
||||
void vertex() {
|
||||
//COLOR.r is the drawing. 0 -> lampost (no move); 1.0 is the center of the wire
|
||||
float movement = COLOR.r;
|
||||
float wind_amount = global_wind_strength * global_wind_fade;
|
||||
|
||||
//Create a wave (based on position and time to be random)
|
||||
float wind_wave = 0.0;
|
||||
float vertical_wave = 0.0;
|
||||
if (global_wind_speed > 0.0 && wind_amount > 0.0) {
|
||||
wind_wave = sin(TIME * global_wind_speed + NODE_POSITION_WORLD.x * 0.5 + NODE_POSITION_WORLD.z * 0.35) * wind_amount;
|
||||
vertical_wave = sin(TIME * global_wind_speed * 0.7 + NODE_POSITION_WORLD.z * 0.35) * wind_amount;
|
||||
}
|
||||
|
||||
VERTEX.x += wind_wave * 0.28 * movement;
|
||||
VERTEX.y += vertical_wave * 0.125 * movement;
|
||||
VERTEX.z += wind_wave * 0.24 * movement;
|
||||
}
|
||||
|
||||
void fragment() {
|
||||
ALBEDO = albedo_color.rgb;
|
||||
ROUGHNESS = 0.9;
|
||||
}
|
||||
1
core/biome_generator/wires.gdshader.uid
Normal file
1
core/biome_generator/wires.gdshader.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://du8cu413q5scy
|
||||
7
core/biome_generator/wires.tres
Normal file
7
core/biome_generator/wires.tres
Normal file
@@ -0,0 +1,7 @@
|
||||
[gd_resource type="ShaderMaterial" format=3 uid="uid://b8p1sjxisi522"]
|
||||
|
||||
[ext_resource type="Shader" uid="uid://du8cu413q5scy" path="res://core/biome_generator/wires.gdshader" id="1_6saq1"]
|
||||
|
||||
[resource]
|
||||
render_priority = 0
|
||||
shader = ExtResource("1_6saq1")
|
||||
43
core/camera.tscn
Normal file
43
core/camera.tscn
Normal file
@@ -0,0 +1,43 @@
|
||||
[gd_scene format=3 uid="uid://cv5xmnow451kl"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://b3nmswr1iaexw" path="res://core/camera_move.gd" id="1_6doux"]
|
||||
|
||||
[node name="camera" type="Node3D" unique_id=310254818]
|
||||
|
||||
[node name="camera_front" type="Camera3D" parent="." unique_id=849013180]
|
||||
transform = Transform3D(-1, 0, -8.742278e-08, 0, 1, 0, 8.742278e-08, 0, -1, 0, 2.55, 7.1)
|
||||
fov = 86.0
|
||||
near = 0.001
|
||||
far = 5000.0
|
||||
|
||||
[node name="camera_top" type="Camera3D" parent="." unique_id=454024645]
|
||||
transform = Transform3D(-0.9998601, 0.0062594875, -0.015508555, -0.0015509288, 0.88861585, 0.45864955, 0.016652059, 0.45860943, -0.8884819, 0, 7.4, 0.53)
|
||||
fov = 82.7
|
||||
near = 0.001
|
||||
far = 5000.0
|
||||
|
||||
[node name="camera_side1" type="Camera3D" parent="." unique_id=1328559378]
|
||||
transform = Transform3D(-0.18395132, 0, 0.98293537, 0, 1, 0, -0.98293537, 0, -0.18395132, -0.57, 2.257, 2.776)
|
||||
fov = 60.0
|
||||
|
||||
[node name="camera_side2" type="Camera3D" parent="." unique_id=888646238]
|
||||
transform = Transform3D(-4.371139e-08, 0.005235964, -0.9999863, 0, 0.9999863, 0.005235964, 1, 2.2887126e-10, -4.3710788e-08, 0.89, 2.207, 2.814)
|
||||
fov = 96.6
|
||||
far = 5000.0
|
||||
|
||||
[node name="camera_iso" type="Camera3D" parent="." unique_id=308091984]
|
||||
transform = Transform3D(0.5778576, -0.5770964, 0.5770964, 0, 0.70710677, 0.70710677, -0.8161376, -0.40860704, 0.40860704, 225, 290, 173.7)
|
||||
projection = 1
|
||||
fov = 96.6
|
||||
size = 35.0
|
||||
near = 0.001
|
||||
far = 500.0
|
||||
|
||||
[node name="pivot" type="Node3D" parent="." unique_id=1852377804 node_paths=PackedStringArray("camera_iso", "pivot", "camera_front", "camera_side1", "camera_side2", "camera_top")]
|
||||
script = ExtResource("1_6doux")
|
||||
camera_iso = NodePath("../camera_iso")
|
||||
pivot = NodePath(".")
|
||||
camera_front = NodePath("../camera_front")
|
||||
camera_side1 = NodePath("../camera_side1")
|
||||
camera_side2 = NodePath("../camera_side2")
|
||||
camera_top = NodePath("../camera_top")
|
||||
156
core/camera_move.gd
Normal file
156
core/camera_move.gd
Normal file
@@ -0,0 +1,156 @@
|
||||
extends Node3D
|
||||
|
||||
signal camera_changed(camera: Camera3D)
|
||||
|
||||
@export_group("Camera")
|
||||
@export var camera_iso : Camera3D
|
||||
@export var pivot : Node3D
|
||||
@export var camera_front : Camera3D
|
||||
@export var camera_side1 : Camera3D
|
||||
@export var camera_side2 : Camera3D
|
||||
@export var camera_top : Camera3D
|
||||
|
||||
@export_group("Camera Movememnt")
|
||||
@export var move_speed : float = 20.0
|
||||
@export var rotation_speed : float = 0.2
|
||||
|
||||
@export_group("Cinematic Mode")
|
||||
@export var change_camera_time : float = 10.0
|
||||
|
||||
@export_group("Isometric Zoom")
|
||||
@export var normal_size : float = 35.0
|
||||
@export var zoom_size : float = 60.0
|
||||
@export var zoom_time : float = 1.2
|
||||
var is_zoomed : bool = false
|
||||
var zoom_tween : Tween
|
||||
|
||||
var is_moving_enabled : bool = true
|
||||
|
||||
var is_cinematic_mode : bool = false
|
||||
var cinematic_timer : float = 0.0
|
||||
var cinematic_index : int = 0
|
||||
var array_camera : Array[Camera3D] = []
|
||||
|
||||
var initial_pivot_transformation : Transform3D
|
||||
|
||||
func _ready():
|
||||
if pivot:
|
||||
initial_pivot_transformation = pivot.transform
|
||||
|
||||
if camera_iso: array_camera.append(camera_iso)
|
||||
if camera_front: array_camera.append(camera_front)
|
||||
if camera_side1: array_camera.append(camera_side1)
|
||||
if camera_side2: array_camera.append(camera_side2)
|
||||
if camera_top: array_camera.append(camera_top)
|
||||
|
||||
if camera_iso:
|
||||
set_camera(camera_iso)
|
||||
|
||||
func set_camera(camera: Camera3D):
|
||||
camera.make_current()
|
||||
emit_signal("camera_changed", camera)
|
||||
|
||||
func _input(event):
|
||||
if event is InputEventKey and event.pressed and not event.echo:
|
||||
|
||||
#R-> Reset isometric camera
|
||||
if event.keycode == KEY_R and is_moving_enabled and pivot:
|
||||
pivot.transform = initial_pivot_transformation
|
||||
print("Isometric camera resetted!")
|
||||
return
|
||||
|
||||
#C-> Toggle cinematic mode
|
||||
if event.keycode == KEY_C:
|
||||
is_cinematic_mode = !is_cinematic_mode
|
||||
if is_cinematic_mode:
|
||||
cinematic_timer = 0.0
|
||||
for i in range(array_camera.size()):
|
||||
if array_camera[i].current:
|
||||
cinematic_index = i
|
||||
break
|
||||
print("Cinematic Mode: enabled")
|
||||
else:
|
||||
print("Cinematic Mode: disabled")
|
||||
return
|
||||
|
||||
#Z-> soft zoom
|
||||
if event.keycode == KEY_Z and camera_iso:
|
||||
is_zoomed = !is_zoomed
|
||||
var target_size = zoom_size if is_zoomed else normal_size
|
||||
|
||||
if zoom_tween and zoom_tween.is_valid():
|
||||
zoom_tween.kill()
|
||||
|
||||
zoom_tween = create_tween()
|
||||
zoom_tween.set_trans(Tween.TRANS_SINE).set_ease(Tween.EASE_IN_OUT)
|
||||
zoom_tween.tween_property(camera_iso, "size", target_size, zoom_time)
|
||||
return
|
||||
|
||||
#manual controls (1-5)
|
||||
var manual_action = false
|
||||
|
||||
if event.keycode == KEY_1 and camera_iso:
|
||||
set_camera(camera_iso)
|
||||
is_moving_enabled = true
|
||||
manual_action = true
|
||||
|
||||
elif event.keycode == KEY_2 and camera_front:
|
||||
set_camera(camera_front)
|
||||
is_moving_enabled = false
|
||||
manual_action = true
|
||||
|
||||
elif event.keycode == KEY_3 and camera_side1:
|
||||
set_camera(camera_side1)
|
||||
is_moving_enabled = false
|
||||
manual_action = true
|
||||
|
||||
elif event.keycode == KEY_4 and camera_side2:
|
||||
set_camera(camera_side2)
|
||||
is_moving_enabled = false
|
||||
manual_action = true
|
||||
|
||||
elif event.keycode == KEY_5 and camera_top:
|
||||
set_camera(camera_top)
|
||||
is_moving_enabled = false
|
||||
manual_action = true
|
||||
|
||||
if manual_action and is_cinematic_mode:
|
||||
is_cinematic_mode = false
|
||||
print("Cinematic Mode: Disabled")
|
||||
|
||||
if is_moving_enabled and pivot:
|
||||
if event is InputEventMouseMotion and Input.is_mouse_button_pressed(MOUSE_BUTTON_RIGHT):
|
||||
pivot.rotate_y(deg_to_rad(-event.relative.x * rotation_speed))
|
||||
|
||||
func _process(delta):
|
||||
if is_cinematic_mode and array_camera.size() > 0:
|
||||
cinematic_timer += delta
|
||||
if cinematic_timer >= change_camera_time:
|
||||
cinematic_timer = 0.0
|
||||
cinematic_index = (cinematic_index + 1) % array_camera.size()
|
||||
var next_cam = array_camera[cinematic_index]
|
||||
set_camera(next_cam)
|
||||
is_moving_enabled = (next_cam == camera_iso)
|
||||
|
||||
if not is_moving_enabled or pivot == null:
|
||||
return
|
||||
|
||||
var input_dir = Vector3.ZERO
|
||||
if Input.is_key_pressed(KEY_W): input_dir.z -= 1
|
||||
if Input.is_key_pressed(KEY_S): input_dir.z += 1
|
||||
if Input.is_key_pressed(KEY_A): input_dir.x -= 1
|
||||
if Input.is_key_pressed(KEY_D): input_dir.x += 1
|
||||
|
||||
if input_dir != Vector3.ZERO:
|
||||
input_dir = input_dir.normalized()
|
||||
|
||||
var forward = pivot.transform.basis.z
|
||||
var right = pivot.transform.basis.x
|
||||
forward.y = 0
|
||||
right.y = 0
|
||||
|
||||
forward = forward.normalized()
|
||||
right = right.normalized()
|
||||
|
||||
var motion = (forward * input_dir.z + right * input_dir.x)
|
||||
pivot.position += motion * move_speed * delta
|
||||
1
core/camera_move.gd.uid
Normal file
1
core/camera_move.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://b3nmswr1iaexw
|
||||
7
core/daynight/FogNoise.tres
Normal file
7
core/daynight/FogNoise.tres
Normal file
@@ -0,0 +1,7 @@
|
||||
[gd_resource type="NoiseTexture2D" format=3 uid="uid://b2xcpt2y8v32x"]
|
||||
|
||||
[sub_resource type="FastNoiseLite" id="FastNoiseLite_oqwsk"]
|
||||
|
||||
[resource]
|
||||
noise = SubResource("FastNoiseLite_oqwsk")
|
||||
seamless = true
|
||||
@@ -1,5 +1,6 @@
|
||||
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;
|
||||
@@ -10,7 +11,7 @@ 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);
|
||||
|
||||
//Apply blur
|
||||
// Applica il blur
|
||||
vec4 blurred_screen = textureLod(screen_texture, SCREEN_UV, blur_amount * mask);
|
||||
COLOR = blurred_screen;
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
shader_type spatial;
|
||||
render_mode unshaded, depth_test_disabled, cull_disabled;
|
||||
/*render_mode unshaded, depth_test_disabled, cull_disabled;
|
||||
|
||||
uniform sampler2D depth_texture : hint_depth_texture, repeat_disable, filter_nearest;
|
||||
uniform sampler2D noise_texture : repeat_enable, filter_linear;
|
||||
@@ -71,3 +71,4 @@ void fragment() {
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
@@ -1,18 +1,21 @@
|
||||
class_name DayNightController
|
||||
extends Node
|
||||
|
||||
#starting time
|
||||
@export_range(0.0, 1.0) var start_time: float = 0.0
|
||||
const TIME_OPTION_SUNRISE: int = 0
|
||||
const TIME_OPTION_DAY: int = 1
|
||||
const TIME_OPTION_SUNSET: int = 2
|
||||
const TIME_OPTION_NIGHT: int = 3
|
||||
|
||||
var environment_config: EnvironmentConfig
|
||||
|
||||
#Multiply for debug
|
||||
@export var time_scale: float = 1.0
|
||||
|
||||
@export var paused: bool = false
|
||||
|
||||
signal time_changed(time: float)
|
||||
|
||||
var current_time: float = 0.0
|
||||
var _current_time_option_index: int = -1
|
||||
|
||||
func _init(environmentconfig: EnvironmentConfig) -> void:
|
||||
environment_config = environmentconfig
|
||||
@@ -21,8 +24,9 @@ func _ready() -> void:
|
||||
#connect events
|
||||
UIEvents.set_day_time.connect(_on_set_day_time)
|
||||
UIEvents.toggle_pause_daytime.connect(_on_toggle_pause_daytime)
|
||||
UIEvents.time_option_item_changed.connect(_time_option_changed)
|
||||
|
||||
current_time = start_time
|
||||
current_time = environment_config.start_time
|
||||
update_time(current_time)
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
@@ -35,7 +39,7 @@ func _process(delta: float) -> void:
|
||||
update_time(current_time)
|
||||
|
||||
func get_time_string() -> String:
|
||||
var total_minutes: int = int(current_time * 1440.0) # 1440 = 24*60
|
||||
var total_minutes: int = int(current_time * 1440.0)
|
||||
@warning_ignore("integer_division")
|
||||
var hours: int = int(total_minutes / 60)
|
||||
var minutes: int = total_minutes % 60
|
||||
@@ -46,7 +50,33 @@ func set_time(t: float) -> void:
|
||||
update_time(current_time)
|
||||
|
||||
func update_time(currtime: float) -> void:
|
||||
var time_option_index: int = get_time_option_index(currtime)
|
||||
if time_option_index != _current_time_option_index:
|
||||
_current_time_option_index = time_option_index
|
||||
UIEvents.day_time_option_changed.emit(time_option_index)
|
||||
|
||||
emit_signal("time_changed", currtime)
|
||||
UIEvents.day_time_changed.emit(currtime, get_time_string())
|
||||
|
||||
func get_time_option_index(currtime: float) -> int:
|
||||
if currtime >= environment_config.night or currtime < environment_config.sunrise:
|
||||
return TIME_OPTION_NIGHT
|
||||
if currtime < environment_config.day:
|
||||
return TIME_OPTION_SUNRISE
|
||||
if currtime < environment_config.sunset:
|
||||
return TIME_OPTION_DAY
|
||||
return TIME_OPTION_SUNSET
|
||||
|
||||
func _time_option_changed(index: int) -> void:
|
||||
match index:
|
||||
TIME_OPTION_SUNRISE:
|
||||
set_time(environment_config.sunrise)
|
||||
TIME_OPTION_DAY:
|
||||
set_time(environment_config.day)
|
||||
TIME_OPTION_SUNSET:
|
||||
set_time(environment_config.sunset)
|
||||
TIME_OPTION_NIGHT:
|
||||
set_time(environment_config.night)
|
||||
|
||||
func _on_set_day_time(value: float) -> void:
|
||||
set_time(value)
|
||||
|
||||
@@ -10,8 +10,11 @@ var parameter_storage_buffer := RID()
|
||||
func _init() -> void:
|
||||
effect_callback_type = CompositorEffect.EFFECT_CALLBACK_TYPE_POST_OPAQUE
|
||||
rd = RenderingServer.get_rendering_device()
|
||||
if rd == null:
|
||||
return
|
||||
|
||||
RenderingServer.call_on_render_thread(_initialize_compute)
|
||||
|
||||
|
||||
var data := PackedFloat32Array()
|
||||
data.resize(20)
|
||||
data.fill(0)
|
||||
@@ -24,7 +27,7 @@ func _init() -> void:
|
||||
# alerts us we are about to be destroyed.
|
||||
func _notification(what: int) -> void:
|
||||
if what == NOTIFICATION_PREDELETE:
|
||||
if shader.is_valid():
|
||||
if rd != null and shader.is_valid():
|
||||
# Freeing our shader will also free any dependents such as the pipeline!
|
||||
rd.free_rid(shader)
|
||||
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
shader_type canvas_item;
|
||||
|
||||
uniform sampler2D screen_texture : hint_screen_texture, filter_linear_mipmap;
|
||||
global uniform float global_wind_speed;
|
||||
global uniform float global_wind_fade;
|
||||
|
||||
uniform vec4 dust_color : source_color = vec4(1.0, 0.456, 0.125, 0.6);
|
||||
|
||||
//Wind -> negative x = to the left. positive y = to the bottom
|
||||
uniform vec2 wind_velocity = vec2(-0.2, 0.05);
|
||||
uniform vec2 wind_speed = vec2(-0.2, 0.05);
|
||||
uniform float wind_oscillation : hint_range(0.0, 1.0) = 0.3;
|
||||
uniform float dust_speed : hint_range(0.01, 1.0) = 0.15;
|
||||
|
||||
@@ -28,12 +29,13 @@ vec3 hash33(vec3 p3) {
|
||||
void fragment() {
|
||||
vec4 scene_color = texture(screen_texture, SCREEN_UV);
|
||||
float base_time = TIME * dust_speed;
|
||||
|
||||
|
||||
vec2 osc = vec2(sin(TIME * 0.5), cos(TIME * 0.3)) * wind_oscillation;
|
||||
vec2 final_wind = (wind_velocity + osc) * dust_speed;
|
||||
float wind_active = global_wind_fade * step(0.0001, abs(global_wind_speed));
|
||||
vec2 final_wind = ((wind_speed + osc) * dust_speed) * wind_active;
|
||||
|
||||
float final_particle_alpha = 0.0;
|
||||
|
||||
|
||||
//Thresolds (near, medium, far)
|
||||
vec3 layer_scales = vec3(20.0, 50.0, 100.0) / dust_density;
|
||||
vec3 layer_thresholds = vec3(0.96, 0.98, 0.99);
|
||||
@@ -70,4 +72,4 @@ void fragment() {
|
||||
vec4 dust_colored_particle = dust_color * final_particle_alpha;
|
||||
|
||||
COLOR = scene_color + dust_colored_particle;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
[resource]
|
||||
shader = ExtResource("1_80hx2")
|
||||
shader_parameter/dust_color = Color(1, 0.9019608, 0.7019608, 0.6)
|
||||
shader_parameter/wind_velocity = Vector2(-1, 0.5)
|
||||
shader_parameter/wind_speed = Vector2(-0.2, 0.05)
|
||||
shader_parameter/wind_oscillation = 0.0150000007125
|
||||
shader_parameter/dust_speed = 0.15
|
||||
shader_parameter/size_min = 0.010000000475
|
||||
|
||||
@@ -9,24 +9,12 @@
|
||||
[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"]
|
||||
render_priority = 0
|
||||
shader = ExtResource("2_i3hjl")
|
||||
shader_parameter/cloud_scale = 0.05
|
||||
shader_parameter/cloud_speed = 0.05
|
||||
shader_parameter/direction = Vector2(0.5, 0.2)
|
||||
shader_parameter/sun_angle = Vector2(0.5, 0.5)
|
||||
shader_parameter/cloud_density = 0.4
|
||||
shader_parameter/center_sharpness = 0.14
|
||||
shader_parameter/shadow_color = Color(0, 0, 0, 1)
|
||||
shader_parameter/opacity_center = 0.5
|
||||
shader_parameter/opacity_edge = 0.2
|
||||
shader_parameter/fade_start = 150.0
|
||||
shader_parameter/fade_end = 300.0
|
||||
shader_parameter/height_fade_start = 10.0
|
||||
shader_parameter/height_fade_end = 50.0
|
||||
|
||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_r4tfj"]
|
||||
transparency = 2
|
||||
@@ -53,9 +41,58 @@ 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
|
||||
water_color_morning = Color(0.33333334, 0.654902, 0.5294118, 1)
|
||||
water_color_afternoon = Color(0.5803922, 0.5137255, 0.2901961, 1)
|
||||
water_color_night = Color(0.48235294, 0.45490196, 0.69411767, 1)
|
||||
metadata/_custom_type_script = "uid://butda6k2tli3o"
|
||||
|
||||
[sub_resource type="Gradient" id="Gradient_i3hjl"]
|
||||
@@ -98,7 +135,7 @@ gradient = SubResource("Gradient_djqkg")
|
||||
lifetime_randomness = 0.5
|
||||
emission_shape_scale = Vector3(5, 5, 5)
|
||||
emission_shape = 3
|
||||
emission_box_extents = Vector3(25, 5, 25)
|
||||
emission_box_extents = Vector3(1, 1, 1)
|
||||
direction = Vector3(0, 1, 0)
|
||||
initial_velocity_min = 6.0
|
||||
initial_velocity_max = 6.0
|
||||
@@ -112,10 +149,9 @@ point_count = 3
|
||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_cer0u"]
|
||||
render_priority = 0
|
||||
shader = ExtResource("5_djqkg")
|
||||
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
|
||||
shader_parameter/time_scale = 3.065
|
||||
shader_parameter/wave_amplitude = 0.3
|
||||
shader_parameter/wave_frequency = 0.25
|
||||
|
||||
[sub_resource type="TubeTrailMesh" id="TubeTrailMesh_vo82p"]
|
||||
material = SubResource("ShaderMaterial_cer0u")
|
||||
@@ -187,9 +223,9 @@ size = Vector2(0.05, 0.8)
|
||||
|
||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_kavln"]
|
||||
shader = ExtResource("9_amaf0")
|
||||
shader_parameter/blur_amount = 0.70000003325
|
||||
shader_parameter/focus_size = 0.250000011875
|
||||
shader_parameter/transition_softness = 0.40000001830148
|
||||
shader_parameter/blur_amount = 0.50000002375
|
||||
shader_parameter/focus_size = 0.54400002584
|
||||
shader_parameter/transition_softness = 0.00999999977648
|
||||
|
||||
[sub_resource type="QuadMesh" id="QuadMesh_sxgg7"]
|
||||
size = Vector2(2, 2)
|
||||
@@ -199,12 +235,12 @@ noise = ExtResource("11_yn8v8")
|
||||
seamless = true
|
||||
|
||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_oqt1s"]
|
||||
render_priority = 0
|
||||
render_priority = -1
|
||||
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.5, 0.2)
|
||||
shader_parameter/direction = Vector2(0.1, 0.025)
|
||||
shader_parameter/sun_angle = Vector2(0.5, 0.5)
|
||||
shader_parameter/cloud_density = 0.400000019
|
||||
shader_parameter/center_sharpness = 0.138000006555
|
||||
@@ -216,7 +252,23 @@ shader_parameter/fade_end = 800.000035625
|
||||
shader_parameter/height_fade_start = 10.0
|
||||
shader_parameter/height_fade_end = 50.0
|
||||
|
||||
[node name="EnvironmentManager" type="Node3D" unique_id=1611939731 node_paths=PackedStringArray("particles_wind", "particles_snow", "particles_fireflies", "particles_rain", "environment_dust", "blur", "environment_shadows")]
|
||||
[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")]
|
||||
script = ExtResource("1_wecen")
|
||||
environment_config = SubResource("Resource_r4tfj")
|
||||
particles_wind = NodePath("Particles_Wind")
|
||||
@@ -227,6 +279,7 @@ 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)
|
||||
@@ -237,9 +290,10 @@ process_material = SubResource("ParticleProcessMaterial_i3hjl")
|
||||
draw_pass_1 = SubResource("QuadMesh_b5atu")
|
||||
|
||||
[node name="Particles_Wind" type="GPUParticles3D" parent="." unique_id=1238214694]
|
||||
transform = Transform3D(-0.9999756, -8.742171e-08, -0.0069812723, -0.0069812723, -3.051611e-10, 0.9999756, -8.742171e-08, 1, -3.051611e-10, 0, 50, 0)
|
||||
transform = Transform3D(1, 0, 0, 0, -4.371139e-08, -1, 0, 1, -4.371139e-08, 0, 50, 0)
|
||||
cast_shadow = 0
|
||||
emitting = false
|
||||
amount = 100
|
||||
amount = 25
|
||||
lifetime = 3.0
|
||||
fixed_fps = 60
|
||||
process_material = SubResource("ParticleProcessMaterial_ruhh7")
|
||||
@@ -287,4 +341,14 @@ extra_cull_margin = 16384.0
|
||||
mesh = SubResource("QuadMesh_sxgg7")
|
||||
surface_material_override/0 = SubResource("ShaderMaterial_oqt1s")
|
||||
|
||||
[node name="AudioStreamPlayer3D" type="AudioStreamPlayer3D" parent="." unique_id=902982869]
|
||||
[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,10 +1,16 @@
|
||||
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")
|
||||
@export var camera: Camera3D
|
||||
@export var camera_pivot: Node3D
|
||||
|
||||
@export_group("Particles")
|
||||
@export var particles_wind: GPUParticles3D
|
||||
@@ -15,23 +21,28 @@ extends Node3D
|
||||
@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]
|
||||
@export var rain_sounds: Array[AudioStream]
|
||||
|
||||
#environment nodes
|
||||
@onready var sun: DirectionalLight3D = $"../DirectionalLight3D"
|
||||
@onready var environment: WorldEnvironment = $"../WorldEnvironment"
|
||||
@onready var audio_player: AudioStreamPlayer3D = $AudioStreamPlayer3D
|
||||
|
||||
var day_night_controller: DayNightController
|
||||
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
|
||||
@@ -51,58 +62,144 @@ func _ready() -> void:
|
||||
particles_snow,
|
||||
particles_fireflies,
|
||||
particles_rain,
|
||||
godray,
|
||||
godray,
|
||||
environment_dust,
|
||||
blur,
|
||||
fog,
|
||||
environment_shadows,
|
||||
sun,
|
||||
sun,
|
||||
environment,
|
||||
environment_config,
|
||||
camera,
|
||||
audio_player,
|
||||
thunder_sounds
|
||||
camera_pivot,
|
||||
thunder_sounds,
|
||||
rain_sounds
|
||||
)
|
||||
weather_controller.name = "WeatherController"
|
||||
add_child(weather_controller)
|
||||
|
||||
func ApplyWindNoiseToMaterials():
|
||||
var noise_tex = preload("res://core/daynight/noise.tres")
|
||||
for node in get_tree().get_nodes_in_group("wind_node"):
|
||||
if node is GeometryInstance3D:
|
||||
node.material_override.set_shader_parameter("wind_noise", noise_tex)
|
||||
|
||||
func ApplyWeatherShaderToMaterials():
|
||||
var weather_shader = preload("res://core/daynight/weather_overlay.tres")
|
||||
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():
|
||||
for node in get_tree().get_nodes_in_group("wind_node"):
|
||||
_apply_wind_noise_to_node(node, NOISE_TEXTURE)
|
||||
|
||||
func _apply_wind_noise_to_node(node: Node, noise_tex: Texture2D) -> void:
|
||||
if node is GeometryInstance3D:
|
||||
var material_override := node.material_override as ShaderMaterial
|
||||
if material_override:
|
||||
material_override.set_shader_parameter("wind_noise", noise_tex)
|
||||
|
||||
if node is MeshInstance3D:
|
||||
for surface_index in node.get_surface_override_material_count():
|
||||
var surface_material := node.get_surface_override_material(surface_index) as ShaderMaterial
|
||||
if surface_material:
|
||||
surface_material.set_shader_parameter("wind_noise", noise_tex)
|
||||
|
||||
for child in node.get_children():
|
||||
_apply_wind_noise_to_node(child, noise_tex)
|
||||
|
||||
func ApplyWeatherShaderToMaterials():
|
||||
for node in get_tree().get_nodes_in_group("weather_node"):
|
||||
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
|
||||
_apply_weather_overlay_to_node(node, WEATHER_SHADER)
|
||||
|
||||
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)
|
||||
|
||||
func select_day_time(normalized_time: float) -> void:
|
||||
# 0.0→0.25 = sunrise: day_time 1.0→2.0 (night colors → morning colors)
|
||||
# 0.25→0.5 = day: day_time 2.0→2.0 (stays morning/afternoon)
|
||||
# 0.5→0.75 = sunset: day_time 2.0→3.0 (afternoon colors → night colors)
|
||||
# 0.75→1.0 = night: day_time 3.0→3.0 (stays night)
|
||||
# At wrap 1.0→0.0: day_time stays 3.0, then fades back via sunrise
|
||||
#set show_day_time_debug = true to show debug on screen
|
||||
#normalized_time is a value between 0 and 1; the time of the day is calculate as "normalized_time" * 1440; day_time is the step to pass from sunrise, to day, to sunset, to night
|
||||
#e.g.
|
||||
#Time normalized_time day_time
|
||||
#00:00 0.0000 3.0
|
||||
#06:00 0.2500 1.0
|
||||
#09:36 0.4000 1.75
|
||||
#10:48 0.4500 2.0
|
||||
#12:00 0.5000 2.0
|
||||
#19:12 0.8000 2.0
|
||||
#21:36 0.9000 2.5
|
||||
#24:00 1.0000 3.0
|
||||
|
||||
if normalized_time < 0.25:
|
||||
if normalized_time < environment_config.sunrise:
|
||||
#Sunrise: night → morning
|
||||
day_time = 3.0 - (normalized_time / 0.25) * 2.0 # 3.0 → 1.0
|
||||
elif normalized_time < 0.5:
|
||||
#Broad daylight
|
||||
var t: float = (normalized_time - 0.25) / 0.25
|
||||
day_time = 3.0 - (normalized_time / environment_config.sunrise) * 2.0 # 3.0 → 1.0
|
||||
elif normalized_time < environment_config.day:
|
||||
#Morning: morning → afternoon
|
||||
var t: float = (normalized_time - environment_config.sunrise) / (environment_config.day - environment_config.sunrise)
|
||||
day_time = 1.0 + t # 1.0 → 2.0
|
||||
elif normalized_time < 0.75:
|
||||
elif normalized_time < environment_config.sunset:
|
||||
#Broad daylight
|
||||
day_time = 2.0
|
||||
elif normalized_time < environment_config.night:
|
||||
#Sunset: afternoon → night
|
||||
var t: float = (normalized_time - 0.5) / 0.25
|
||||
var t: float = (normalized_time - environment_config.sunset) / (environment_config.night - environment_config.sunset)
|
||||
day_time = 2.0 + t # 2.0 → 3.0
|
||||
else:
|
||||
#Night
|
||||
day_time = 3.0
|
||||
|
||||
|
||||
if weather_controller:
|
||||
weather_controller.day_time = day_time
|
||||
|
||||
@@ -29,9 +29,9 @@ shader_parameter/edge_fade_power = 2.0
|
||||
shader_parameter/intensity_multiplier = 0.5330000253175
|
||||
|
||||
[node name="GodRay" type="Node3D" unique_id=1679441931]
|
||||
script = ExtResource("2_v3yr3")
|
||||
|
||||
[node name="GodRays" type="MeshInstance3D" parent="." unique_id=341055819]
|
||||
transform = Transform3D(3.39, 0, 0, 0, -3.1996737e-07, 13, 0, -7.32, -5.68248e-07, 0, 0, 0)
|
||||
mesh = SubResource("PlaneMesh_l01hg")
|
||||
surface_material_override/0 = SubResource("ShaderMaterial_joqvq")
|
||||
script = ExtResource("2_v3yr3")
|
||||
|
||||
@@ -1,21 +1,72 @@
|
||||
extends MeshInstance3D
|
||||
extends Node3D
|
||||
|
||||
@export_group("Animation")
|
||||
@export var life_time: float = 8.0
|
||||
@export var fade_in_time: float = 4.0
|
||||
@export var max_base_alpha: float = 1.0
|
||||
|
||||
var _visual_scale: Vector3 = Vector3.ONE
|
||||
var _visual_rotation_degrees: Vector3 = Vector3.ZERO
|
||||
var _mesh_base_position: Vector3 = Vector3.ZERO
|
||||
var _mesh_base_rotation_degrees: Vector3 = Vector3.ZERO
|
||||
var _mesh_base_scale: Vector3 = Vector3.ONE
|
||||
|
||||
@onready var godrays_mesh: MeshInstance3D = $GodRays
|
||||
|
||||
func _ready():
|
||||
var mat = get_active_material(0).duplicate()
|
||||
set_surface_override_material(0, mat)
|
||||
|
||||
#add_to_group("camere")
|
||||
_mesh_base_position = godrays_mesh.position
|
||||
_mesh_base_rotation_degrees = godrays_mesh.rotation_degrees
|
||||
_mesh_base_scale = godrays_mesh.scale
|
||||
_apply_visual_transform()
|
||||
|
||||
var mat: ShaderMaterial = godrays_mesh.get_active_material(0).duplicate()
|
||||
godrays_mesh.set_surface_override_material(0, mat)
|
||||
|
||||
#set alpha to 0 before first frame to avoid "pop"
|
||||
mat.set_shader_parameter("base_alpha", 0.0)
|
||||
orient_to_camera()
|
||||
|
||||
animate_godray(mat)
|
||||
|
||||
|
||||
func _process(_delta: float) -> void:
|
||||
orient_to_camera()
|
||||
|
||||
|
||||
func set_visual_rotation_degrees(value: Vector3) -> void:
|
||||
_visual_rotation_degrees = value
|
||||
if is_node_ready():
|
||||
_apply_visual_transform()
|
||||
|
||||
|
||||
func set_visual_scale(value: Vector3) -> void:
|
||||
_visual_scale = value
|
||||
if is_node_ready():
|
||||
_apply_visual_transform()
|
||||
|
||||
|
||||
func orient_to_camera() -> void:
|
||||
var current_camera: Camera3D = get_viewport().get_camera_3d()
|
||||
if current_camera == null or not is_instance_valid(current_camera):
|
||||
return
|
||||
var look_direction: Vector3 = current_camera.global_basis.z
|
||||
if look_direction.is_zero_approx():
|
||||
return
|
||||
|
||||
# Use the camera orientation instead of its position so every godray keeps
|
||||
# the same diagonal on screen, even when multiple rays are visible together.
|
||||
look_at(global_position + look_direction, current_camera.global_basis.y, true)
|
||||
|
||||
|
||||
func _apply_visual_transform() -> void:
|
||||
godrays_mesh.position = _mesh_base_position
|
||||
godrays_mesh.rotation_degrees = _mesh_base_rotation_degrees + _visual_rotation_degrees
|
||||
godrays_mesh.scale = Vector3(
|
||||
_mesh_base_scale.x * _visual_scale.x,
|
||||
_mesh_base_scale.y * _visual_scale.y,
|
||||
_mesh_base_scale.z * _visual_scale.z
|
||||
)
|
||||
|
||||
func animate_godray(mat: ShaderMaterial):
|
||||
var tween_alpha = create_tween()
|
||||
tween_alpha.tween_property(mat, "shader_parameter/base_alpha", max_base_alpha, fade_in_time).from(0.0)
|
||||
|
||||
146
core/daynight/grass_leaves.gdshader
Normal file
146
core/daynight/grass_leaves.gdshader
Normal file
@@ -0,0 +1,146 @@
|
||||
shader_type spatial;
|
||||
|
||||
render_mode specular_disabled, cull_disabled, ambient_light_disabled;
|
||||
|
||||
// --- GLOBAL UNIFORMS (Vento e Neve) ---
|
||||
global uniform float global_wind_scale;
|
||||
global uniform float global_wind_speed;
|
||||
global uniform float global_wind_strength;
|
||||
global uniform vec2 global_wind_direction;
|
||||
//global uniform sampler2D global_wind_noise : filter_linear_mipmap;
|
||||
global uniform float global_snow_start_time;
|
||||
global uniform float global_snow_accumulation_speed;
|
||||
global uniform float global_snow_melt_time;
|
||||
global uniform float global_snow_melt_speed;
|
||||
|
||||
// --- PARAMETRI ESTETICI ---
|
||||
uniform bool billboard_enabled = true;
|
||||
uniform bool wind_enabled = true;
|
||||
uniform vec4 base_color : source_color = vec4(0.2, 0.6, 0.3, 1.0);
|
||||
uniform sampler2D alpha_texture : source_color, filter_nearest;
|
||||
uniform float leaves_scale = 1.0;
|
||||
uniform float rotation_degrees = 0.0;
|
||||
uniform vec2 texture_offset = vec2(0.0, 0.0);
|
||||
uniform float opacity : hint_range(0.0, 1.0) = 1.0;
|
||||
|
||||
// ---> NUOVI PARAMETRI PER VARIAZIONE ERBA <---
|
||||
group_uniforms Grass_Variance;
|
||||
uniform sampler2D color_variance_noise : filter_linear_mipmap; // Trascina qui un FastNoiseLite
|
||||
uniform float variance_scale = 0.1; // Grandezza delle chiazze (più basso = chiazze più grandi)
|
||||
uniform vec4 variance_color : source_color = vec4(0.3, 0.5, 0.2, 1.0); // Colore delle chiazze (es: verde più scuro o giallastro)
|
||||
uniform float variance_intensity : hint_range(0.0, 1.0) = 0.4; // Quanto si vedono le chiazze
|
||||
|
||||
uniform vec4 snow_color : source_color = vec4(0.85, 0.9, 0.95, 1.0);
|
||||
|
||||
// --- CONTROLLO GRADIENTE E RANDOM ---
|
||||
uniform float height_min = 0.0;
|
||||
uniform float height_max = 5.0;
|
||||
uniform float shadow_intensity : hint_range(0.0, 1.0) = 0.5;
|
||||
uniform float highlight_intensity : hint_range(0.0, 1.0) = 0.3;
|
||||
uniform float light_steps : hint_range(1.0, 10.0) = 4.0;
|
||||
uniform float random_mix : hint_range(0.0, 1.0) = 0.3;
|
||||
|
||||
uniform float cast_shadow_strength : hint_range(0.0, 1.0) = 0.6;
|
||||
|
||||
varying vec3 v_final_color;
|
||||
varying float v_shade_factor;
|
||||
varying vec3 v_world_pos; // Passiamo la posizione mondo per il rumore
|
||||
|
||||
float hash(vec3 p) {
|
||||
p = fract(p * 0.1031);
|
||||
p += dot(p, p.yzx + 33.33);
|
||||
return fract((p.x + p.y) * p.z);
|
||||
}
|
||||
|
||||
void vertex() {
|
||||
vec3 instance_pos = MODEL_MATRIX[3].xyz;
|
||||
v_world_pos = instance_pos; // Salviamo la posizione dell'istanza
|
||||
|
||||
// --- LOGICA VENTO ---
|
||||
float total_angle = radians(rotation_degrees);
|
||||
if (wind_enabled) {
|
||||
float time = TIME * global_wind_speed;
|
||||
vec2 noise_uv = (instance_pos.xz * global_wind_scale) + (time * global_wind_direction.xy * 0.5);
|
||||
//float noise_val = textureLod(wind_noise, noise_uv, 2.0).r;
|
||||
//float sway = sin(time + (noise_val * 10.0));
|
||||
float sway = sin(time + (0.1 * 10.0));
|
||||
total_angle += (sway * global_wind_strength);
|
||||
}
|
||||
|
||||
// --- CALCOLO COLORE ---
|
||||
float h_factor = clamp((instance_pos.y - height_min) / (height_max - height_min), 0.0, 1.0);
|
||||
float leaf_rand = hash(instance_pos);
|
||||
float combined_factor = mix(h_factor, leaf_rand, random_mix);
|
||||
combined_factor = ceil(combined_factor * light_steps) / light_steps;
|
||||
|
||||
v_shade_factor = combined_factor;
|
||||
|
||||
vec3 dark_color = base_color.rgb * (1.0 - shadow_intensity);
|
||||
vec3 light_color = base_color.rgb + (vec3(1.0) - base_color.rgb) * highlight_intensity;
|
||||
v_final_color = mix(dark_color, light_color, combined_factor);
|
||||
|
||||
// --- LOGICA TRASFORMAZIONE ---
|
||||
if (billboard_enabled) {
|
||||
vec3 view_pos_origin = (VIEW_MATRIX * vec4(instance_pos, 1.0)).xyz;
|
||||
vec2 offset = (UV - 0.5) * leaves_scale;
|
||||
|
||||
float c = cos(total_angle);
|
||||
float s = sin(total_angle);
|
||||
vec2 rotated_offset = vec2(offset.x * c - offset.y * s, offset.x * s + offset.y * c);
|
||||
|
||||
vec3 final_pos = view_pos_origin + vec3(rotated_offset.x, rotated_offset.y, 0.0);
|
||||
|
||||
MODELVIEW_MATRIX = mat4(1.0);
|
||||
MODELVIEW_MATRIX[3].xyz = final_pos;
|
||||
VERTEX = vec3(0.0);
|
||||
} else {
|
||||
float c = cos(total_angle);
|
||||
float s = sin(total_angle);
|
||||
|
||||
vec2 local_v = (VERTEX.xy) * leaves_scale;
|
||||
VERTEX.x = local_v.x * c - local_v.y * s;
|
||||
VERTEX.y = local_v.x * s + local_v.y * c;
|
||||
}
|
||||
}
|
||||
|
||||
void fragment() {
|
||||
vec2 shifted_uv = UV + texture_offset;
|
||||
vec4 tex = texture(alpha_texture, shifted_uv);
|
||||
|
||||
// ---> LOGICA VARIAZIONE COLORE MONDO <---
|
||||
// Usiamo la posizione XZ del mondo per campionare il rumore
|
||||
float noise_sample = texture(color_variance_noise, v_world_pos.xz * variance_scale).r;
|
||||
// Applichiamo la variazione al colore finale dell'erba
|
||||
vec3 varied_grass_color = mix(v_final_color, variance_color.rgb, noise_sample * variance_intensity);
|
||||
|
||||
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 top_mask = 1.0 - shifted_uv.y;
|
||||
float snow_mask = smoothstep(1.0 - snow_amount, 1.2 - snow_amount, top_mask);
|
||||
snow_mask *= step(0.01, snow_amount);
|
||||
|
||||
vec3 dark_snow = snow_color.rgb * (1.0 - shadow_intensity);
|
||||
vec3 shaded_snow = mix(dark_snow, snow_color.rgb, v_shade_factor);
|
||||
|
||||
// Mescoliamo il colore variato con la neve
|
||||
vec3 final_albedo = mix(varied_grass_color, shaded_snow, snow_mask);
|
||||
|
||||
ALBEDO = final_albedo;
|
||||
ALPHA = tex.r * opacity;
|
||||
ALPHA_SCISSOR_THRESHOLD = 0.5;
|
||||
|
||||
ROUGHNESS = 0.02;
|
||||
}
|
||||
|
||||
void light() {
|
||||
float shadow_factor = mix(1.0 - cast_shadow_strength, 1.0, ATTENUATION);
|
||||
float cutoff_mask = smoothstep(0.0, 0.05, ATTENUATION);
|
||||
DIFFUSE_LIGHT += (shadow_factor * LIGHT_COLOR) * cutoff_mask;
|
||||
}
|
||||
1
core/daynight/grass_leaves.gdshader.uid
Normal file
1
core/daynight/grass_leaves.gdshader.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://8l8glwvvs7fb
|
||||
107
core/daynight/snow_cap.gd
Normal file
107
core/daynight/snow_cap.gd
Normal file
@@ -0,0 +1,107 @@
|
||||
## 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
core/daynight/snow_cap.gd.uid
Normal file
1
core/daynight/snow_cap.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://bxc6ketfgedxw
|
||||
114
core/daynight/snow_cap.gdshader
Normal file
114
core/daynight/snow_cap.gdshader
Normal file
@@ -0,0 +1,114 @@
|
||||
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
core/daynight/snow_cap.gdshader.uid
Normal file
1
core/daynight/snow_cap.gdshader.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://c7js7ytvewmab
|
||||
@@ -1,19 +0,0 @@
|
||||
[remap]
|
||||
|
||||
importer="mp3"
|
||||
type="AudioStreamMP3"
|
||||
uid="uid://bfn6kxtpb8b7a"
|
||||
path="res://.godot/imported/thunder_1.mp3-5dfac75637d4484715fa2c52227bbb39.mp3str"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://core/daynight/sound/thunder_1.mp3"
|
||||
dest_files=["res://.godot/imported/thunder_1.mp3-5dfac75637d4484715fa2c52227bbb39.mp3str"]
|
||||
|
||||
[params]
|
||||
|
||||
loop=false
|
||||
loop_offset=0
|
||||
bpm=0
|
||||
beat_count=0
|
||||
bar_beats=4
|
||||
@@ -1,19 +0,0 @@
|
||||
[remap]
|
||||
|
||||
importer="mp3"
|
||||
type="AudioStreamMP3"
|
||||
uid="uid://br2ye0dto487h"
|
||||
path="res://.godot/imported/thunder_2.mp3-e0bc5cdbb7a7380e5c0e7af073c47559.mp3str"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://core/daynight/sound/thunder_2.mp3"
|
||||
dest_files=["res://.godot/imported/thunder_2.mp3-e0bc5cdbb7a7380e5c0e7af073c47559.mp3str"]
|
||||
|
||||
[params]
|
||||
|
||||
loop=false
|
||||
loop_offset=0
|
||||
bpm=0
|
||||
beat_count=0
|
||||
bar_beats=4
|
||||
@@ -1,19 +0,0 @@
|
||||
[remap]
|
||||
|
||||
importer="mp3"
|
||||
type="AudioStreamMP3"
|
||||
uid="uid://dvabvoqyya0g5"
|
||||
path="res://.godot/imported/thunder_3.mp3-2057b93f6a6b1db545b448579512d302.mp3str"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://core/daynight/sound/thunder_3.mp3"
|
||||
dest_files=["res://.godot/imported/thunder_3.mp3-2057b93f6a6b1db545b448579512d302.mp3str"]
|
||||
|
||||
[params]
|
||||
|
||||
loop=false
|
||||
loop_offset=0
|
||||
bpm=0
|
||||
beat_count=0
|
||||
bar_beats=4
|
||||
@@ -1,19 +0,0 @@
|
||||
[remap]
|
||||
|
||||
importer="mp3"
|
||||
type="AudioStreamMP3"
|
||||
uid="uid://creenugno7hm"
|
||||
path="res://.godot/imported/thunder_4.mp3-ab350a8d3ed7b106a20bdb2005be826d.mp3str"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://core/daynight/sound/thunder_4.mp3"
|
||||
dest_files=["res://.godot/imported/thunder_4.mp3-ab350a8d3ed7b106a20bdb2005be826d.mp3str"]
|
||||
|
||||
[params]
|
||||
|
||||
loop=false
|
||||
loop_offset=0
|
||||
bpm=0
|
||||
beat_count=0
|
||||
bar_beats=4
|
||||
@@ -1,19 +0,0 @@
|
||||
[remap]
|
||||
|
||||
importer="mp3"
|
||||
type="AudioStreamMP3"
|
||||
uid="uid://bm6dq4jwsbxf6"
|
||||
path="res://.godot/imported/thunder_5.mp3-bac65d0a703be3ab04d2144b8eef2bce.mp3str"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://core/daynight/sound/thunder_5.mp3"
|
||||
dest_files=["res://.godot/imported/thunder_5.mp3-bac65d0a703be3ab04d2144b8eef2bce.mp3str"]
|
||||
|
||||
[params]
|
||||
|
||||
loop=false
|
||||
loop_offset=0
|
||||
bpm=0
|
||||
beat_count=0
|
||||
bar_beats=4
|
||||
BIN
core/daynight/sounds/rain_1.mp3
Normal file
BIN
core/daynight/sounds/rain_1.mp3
Normal file
Binary file not shown.
19
core/daynight/sounds/rain_1.mp3.import
Normal file
19
core/daynight/sounds/rain_1.mp3.import
Normal file
@@ -0,0 +1,19 @@
|
||||
[remap]
|
||||
|
||||
importer="mp3"
|
||||
type="AudioStreamMP3"
|
||||
uid="uid://byuxpukhy72n8"
|
||||
path="res://.godot/imported/rain_1.mp3-b38c5c2051e16525931f27bf63462ca9.mp3str"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://core/daynight/sounds/rain_1.mp3"
|
||||
dest_files=["res://.godot/imported/rain_1.mp3-b38c5c2051e16525931f27bf63462ca9.mp3str"]
|
||||
|
||||
[params]
|
||||
|
||||
loop=false
|
||||
loop_offset=0
|
||||
bpm=0
|
||||
beat_count=0
|
||||
bar_beats=4
|
||||
BIN
core/daynight/sounds/rain_2.mp3
Normal file
BIN
core/daynight/sounds/rain_2.mp3
Normal file
Binary file not shown.
19
core/daynight/sounds/rain_2.mp3.import
Normal file
19
core/daynight/sounds/rain_2.mp3.import
Normal file
@@ -0,0 +1,19 @@
|
||||
[remap]
|
||||
|
||||
importer="mp3"
|
||||
type="AudioStreamMP3"
|
||||
uid="uid://h5yhjn1x3f4j"
|
||||
path="res://.godot/imported/rain_2.mp3-bcb3e8cb8ab98e668d60ed670be6de0f.mp3str"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://core/daynight/sounds/rain_2.mp3"
|
||||
dest_files=["res://.godot/imported/rain_2.mp3-bcb3e8cb8ab98e668d60ed670be6de0f.mp3str"]
|
||||
|
||||
[params]
|
||||
|
||||
loop=false
|
||||
loop_offset=0
|
||||
bpm=0
|
||||
beat_count=0
|
||||
bar_beats=4
|
||||
BIN
core/daynight/sounds/rain_3.mp3
Normal file
BIN
core/daynight/sounds/rain_3.mp3
Normal file
Binary file not shown.
19
core/daynight/sounds/rain_3.mp3.import
Normal file
19
core/daynight/sounds/rain_3.mp3.import
Normal file
@@ -0,0 +1,19 @@
|
||||
[remap]
|
||||
|
||||
importer="mp3"
|
||||
type="AudioStreamMP3"
|
||||
uid="uid://elrjw0smm0cj"
|
||||
path="res://.godot/imported/rain_3.mp3-b39c461eabf9a5f3502ac452c08310c1.mp3str"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://core/daynight/sounds/rain_3.mp3"
|
||||
dest_files=["res://.godot/imported/rain_3.mp3-b39c461eabf9a5f3502ac452c08310c1.mp3str"]
|
||||
|
||||
[params]
|
||||
|
||||
loop=false
|
||||
loop_offset=0
|
||||
bpm=0
|
||||
beat_count=0
|
||||
bar_beats=4
|
||||
19
core/daynight/sounds/thunder_1.mp3.import
Normal file
19
core/daynight/sounds/thunder_1.mp3.import
Normal file
@@ -0,0 +1,19 @@
|
||||
[remap]
|
||||
|
||||
importer="mp3"
|
||||
type="AudioStreamMP3"
|
||||
uid="uid://bfn6kxtpb8b7a"
|
||||
path="res://.godot/imported/thunder_1.mp3-a69332dc48adeec56bf6cc67c3bb4ceb.mp3str"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://core/daynight/sounds/thunder_1.mp3"
|
||||
dest_files=["res://.godot/imported/thunder_1.mp3-a69332dc48adeec56bf6cc67c3bb4ceb.mp3str"]
|
||||
|
||||
[params]
|
||||
|
||||
loop=false
|
||||
loop_offset=0
|
||||
bpm=0
|
||||
beat_count=0
|
||||
bar_beats=4
|
||||
19
core/daynight/sounds/thunder_2.mp3.import
Normal file
19
core/daynight/sounds/thunder_2.mp3.import
Normal file
@@ -0,0 +1,19 @@
|
||||
[remap]
|
||||
|
||||
importer="mp3"
|
||||
type="AudioStreamMP3"
|
||||
uid="uid://br2ye0dto487h"
|
||||
path="res://.godot/imported/thunder_2.mp3-928b4a280c9174e8f9ec4888d6e47d04.mp3str"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://core/daynight/sounds/thunder_2.mp3"
|
||||
dest_files=["res://.godot/imported/thunder_2.mp3-928b4a280c9174e8f9ec4888d6e47d04.mp3str"]
|
||||
|
||||
[params]
|
||||
|
||||
loop=false
|
||||
loop_offset=0
|
||||
bpm=0
|
||||
beat_count=0
|
||||
bar_beats=4
|
||||
19
core/daynight/sounds/thunder_3.mp3.import
Normal file
19
core/daynight/sounds/thunder_3.mp3.import
Normal file
@@ -0,0 +1,19 @@
|
||||
[remap]
|
||||
|
||||
importer="mp3"
|
||||
type="AudioStreamMP3"
|
||||
uid="uid://dvabvoqyya0g5"
|
||||
path="res://.godot/imported/thunder_3.mp3-af1ebec5599ef6a58950c7f353a6f8dd.mp3str"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://core/daynight/sounds/thunder_3.mp3"
|
||||
dest_files=["res://.godot/imported/thunder_3.mp3-af1ebec5599ef6a58950c7f353a6f8dd.mp3str"]
|
||||
|
||||
[params]
|
||||
|
||||
loop=false
|
||||
loop_offset=0
|
||||
bpm=0
|
||||
beat_count=0
|
||||
bar_beats=4
|
||||
19
core/daynight/sounds/thunder_4.mp3.import
Normal file
19
core/daynight/sounds/thunder_4.mp3.import
Normal file
@@ -0,0 +1,19 @@
|
||||
[remap]
|
||||
|
||||
importer="mp3"
|
||||
type="AudioStreamMP3"
|
||||
uid="uid://creenugno7hm"
|
||||
path="res://.godot/imported/thunder_4.mp3-3b7e59285fedb20a25988d2987168f33.mp3str"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://core/daynight/sounds/thunder_4.mp3"
|
||||
dest_files=["res://.godot/imported/thunder_4.mp3-3b7e59285fedb20a25988d2987168f33.mp3str"]
|
||||
|
||||
[params]
|
||||
|
||||
loop=false
|
||||
loop_offset=0
|
||||
bpm=0
|
||||
beat_count=0
|
||||
bar_beats=4
|
||||
19
core/daynight/sounds/thunder_5.mp3.import
Normal file
19
core/daynight/sounds/thunder_5.mp3.import
Normal file
@@ -0,0 +1,19 @@
|
||||
[remap]
|
||||
|
||||
importer="mp3"
|
||||
type="AudioStreamMP3"
|
||||
uid="uid://bm6dq4jwsbxf6"
|
||||
path="res://.godot/imported/thunder_5.mp3-2dadd721b078f5baaa97664ed875a6b4.mp3str"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://core/daynight/sounds/thunder_5.mp3"
|
||||
dest_files=["res://.godot/imported/thunder_5.mp3-2dadd721b078f5baaa97664ed875a6b4.mp3str"]
|
||||
|
||||
[params]
|
||||
|
||||
loop=false
|
||||
loop_offset=0
|
||||
bpm=0
|
||||
beat_count=0
|
||||
bar_beats=4
|
||||
@@ -5,11 +5,13 @@ global uniform float global_wind_speed;
|
||||
global uniform vec2 global_wind_direction;
|
||||
global uniform float global_wind_scale;
|
||||
global uniform float global_wind_strength;
|
||||
global uniform float global_wind_fade;
|
||||
/*
|
||||
global uniform float global_snow_start_time;
|
||||
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;
|
||||
global uniform vec4 global_snow_color;*/
|
||||
global uniform float global_rain_intensity;
|
||||
|
||||
uniform sampler2D wind_noise : filter_linear_mipmap;
|
||||
@@ -43,12 +45,12 @@ void vertex() {
|
||||
vec3 instance_pos = MODEL_MATRIX[3].xyz;
|
||||
|
||||
float total_angle = radians(rotation_degrees);
|
||||
if (wind_enabled) {
|
||||
if (wind_enabled && global_wind_speed > 0.0 && global_wind_strength > 0.0 && global_wind_fade > 0.0) {
|
||||
float time = TIME * global_wind_speed;
|
||||
vec2 noise_uv = (instance_pos.xz * global_wind_scale) + (time * global_wind_direction * 0.5);
|
||||
float noise_val = textureLod(wind_noise, noise_uv, 2.0).r;
|
||||
float sway = sin(time + (noise_val * 10.0));
|
||||
total_angle += (sway * global_wind_strength);
|
||||
total_angle += (sway * global_wind_strength * global_wind_fade);
|
||||
}
|
||||
|
||||
float h_factor = clamp((instance_pos.y - height_min) / (height_max - height_min), 0.0, 1.0);
|
||||
@@ -86,24 +88,25 @@ void fragment() {
|
||||
vec2 shifted_uv = UV + texture_offset;
|
||||
vec4 tex = texture(alpha_texture, shifted_uv);
|
||||
|
||||
// Snow 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 top_mask = 1.0 - shifted_uv.y;
|
||||
float snow_mask = smoothstep(1.0 - snow_amount, 1.2 - snow_amount, top_mask);
|
||||
snow_mask *= step(0.01, snow_amount);
|
||||
|
||||
vec3 dark_snow = global_snow_color.rgb * (1.0 - shadow_intensity);
|
||||
vec3 shaded_snow = mix(dark_snow, global_snow_color.rgb, v_shade_factor);
|
||||
vec3 final_albedo = mix(v_final_color, shaded_snow, snow_mask);
|
||||
//// Snow 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 top_mask = 1.0 - shifted_uv.y;
|
||||
//float snow_mask = smoothstep(1.0 - snow_amount, 1.2 - snow_amount, top_mask);
|
||||
//snow_mask *= step(0.01, snow_amount);
|
||||
|
||||
//vec3 dark_snow = global_snow_color.rgb * (1.0 - shadow_intensity);
|
||||
//vec3 shaded_snow = mix(dark_snow, global_snow_color.rgb, v_shade_factor);
|
||||
//vec3 final_albedo = mix(v_final_color, shaded_snow, snow_mask);
|
||||
vec3 final_albedo = v_final_color;
|
||||
|
||||
// Rain wetness: darken and make shinier
|
||||
float rain_int = clamp(global_rain_intensity, 0.0, 1.0);
|
||||
final_albedo *= mix(1.0, 1.0 - wetness_darkening, rain_int);
|
||||
|
||||
95
core/daynight/water_ripple.gdshader
Normal file
95
core/daynight/water_ripple.gdshader
Normal file
@@ -0,0 +1,95 @@
|
||||
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);
|
||||
uniform vec4 shallow_water_color : source_color = vec4(0.0, 0.4, 0.7, 1.0);
|
||||
uniform float beer_law_factor : hint_range(0.0, 10.0) = 5.0;
|
||||
|
||||
group_uniforms Fake_Reflection_Proximity;
|
||||
uniform sampler2D screen_texture : hint_screen_texture, filter_linear_mipmap;
|
||||
uniform float reflection_strength : hint_range(0.0, 1.0) = 0.6;
|
||||
uniform float reflection_offset : hint_range(-0.5, 0.5) = 0.05; // Offset base
|
||||
uniform float reflection_stretch : hint_range(-1.0, 1.0) = 0.1;
|
||||
uniform float max_reflection_distance : hint_range(0.1, 10.0) = 1.5;
|
||||
|
||||
//Ripples parameters
|
||||
group_uniforms Ripple_Settings;
|
||||
uniform vec4 ripple_color : source_color = vec4(1.0, 1.0, 1.0, 0.7);
|
||||
uniform float ripple_density : hint_range(0.0, 1.0) = 0.05;
|
||||
uniform float ripple_scale : hint_range(0.5, 20.0) = 3.0;
|
||||
uniform float ripple_speed : hint_range(0.1, 5.0) = 0.8;
|
||||
uniform float ripple_thickness : hint_range(0.001, 0.1) = 0.02;
|
||||
|
||||
uniform sampler2D depth_texture : hint_depth_texture, filter_linear_mipmap;
|
||||
|
||||
varying vec2 world_pos_xz;
|
||||
varying vec2 local_uv;
|
||||
|
||||
void vertex() {
|
||||
world_pos_xz = (MODEL_MATRIX * vec4(VERTEX, 1.0)).xz;
|
||||
local_uv = UV;
|
||||
}
|
||||
|
||||
void fragment() {
|
||||
float depth = texture(depth_texture, SCREEN_UV).r;
|
||||
vec3 ndc = vec3(SCREEN_UV * 2.0 - 1.0, depth);
|
||||
vec4 view = INV_PROJECTION_MATRIX * vec4(ndc, 1.0);
|
||||
view.xyz /= view.w;
|
||||
float linear_depth = -view.z;
|
||||
float depth_difference = linear_depth + VERTEX.z;
|
||||
|
||||
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 ring = 0.0;
|
||||
if (is_active_cell > 0.0) {
|
||||
float local_time = fract(TIME * ripple_speed + random_val * 10.0);
|
||||
float dist = length(local_pos);
|
||||
ring = smoothstep(local_time - ripple_thickness, local_time, dist)
|
||||
- smoothstep(local_time, local_time + ripple_thickness, dist);
|
||||
ring *= (1.0 - local_time);
|
||||
}
|
||||
ring *= rain_intensity;
|
||||
|
||||
vec2 ref_uv = SCREEN_UV;
|
||||
|
||||
ref_uv.y -= reflection_offset + (local_uv.y * reflection_stretch);
|
||||
ref_uv += ring * 0.01;
|
||||
|
||||
vec3 screen_ref = textureLod(screen_texture, ref_uv, 0.0).rgb;
|
||||
|
||||
float ref_depth_raw = texture(depth_texture, ref_uv).r;
|
||||
vec3 ref_ndc = vec3(ref_uv * 2.0 - 1.0, ref_depth_raw);
|
||||
vec4 ref_view = INV_PROJECTION_MATRIX * vec4(ref_ndc, 1.0);
|
||||
ref_view.xyz /= ref_view.w;
|
||||
float ref_linear_depth = -ref_view.z;
|
||||
|
||||
float distance_from_water = abs(ref_linear_depth - (-VERTEX.z));
|
||||
float reflection_mask = 1.0 - smoothstep(0.0, max_reflection_distance, distance_from_water);
|
||||
float is_sky = step(ref_depth_raw, 0.00001); // Protezione anti-cielo
|
||||
reflection_mask *= (1.0 - is_sky);
|
||||
|
||||
vec3 final_rgb = mix(base_water.rgb, screen_ref, reflection_strength * reflection_mask);
|
||||
final_rgb = mix(final_rgb, ripple_color.rgb, ring * ripple_color.a);
|
||||
|
||||
ALBEDO = final_rgb;
|
||||
|
||||
ALPHA = mix(0.98, 0.4, water_depth_gradient);
|
||||
ALPHA = clamp(ALPHA + (ring * ripple_color.a), 0.0, 1.0);
|
||||
|
||||
ROUGHNESS = 1.0;
|
||||
SPECULAR = 0.0;
|
||||
}
|
||||
1
core/daynight/water_ripple.gdshader.uid
Normal file
1
core/daynight/water_ripple.gdshader.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://064bybt6le3h
|
||||
@@ -1,8 +1,10 @@
|
||||
class_name WeatherController
|
||||
extends Node
|
||||
|
||||
var audio_player: AudioStreamPlayer3D
|
||||
var thunder_audio_player: AudioStreamPlayer
|
||||
var thunder_sounds: Array[AudioStream]
|
||||
var rain_sounds: Array[AudioStream]
|
||||
var rain_audio_player: AudioStreamPlayer
|
||||
|
||||
var particles_wind: GPUParticles3D
|
||||
var particles_snow: GPUParticles3D
|
||||
@@ -12,11 +14,13 @@ var godray: PackedScene
|
||||
var environment_dust: ColorRect
|
||||
var blur: ColorRect
|
||||
var environment_shadows: MeshInstance3D
|
||||
var fog: Node3D
|
||||
|
||||
var sun: DirectionalLight3D
|
||||
var environment: WorldEnvironment
|
||||
var environment_config: EnvironmentConfig
|
||||
var camera: Camera3D
|
||||
var camera_pivot: Node3D
|
||||
|
||||
var day_time: float = 0.0
|
||||
|
||||
@@ -27,6 +31,7 @@ var timer_next_lightning: float = 0.0
|
||||
var is_raining: bool = false
|
||||
var rain_intensity: float = 0.0
|
||||
var rain_tween: Tween
|
||||
var rain_audio_tween: Tween
|
||||
var puddle_tween: Tween
|
||||
var puddle_amount: float = 0.0
|
||||
|
||||
@@ -38,14 +43,22 @@ var actual_snow_amount: float = 0.0
|
||||
|
||||
var is_storm: bool = false
|
||||
var cold_tween: Tween
|
||||
var wind_tween: Tween
|
||||
var is_windy: bool = false
|
||||
var thereare_fireflies: bool = false
|
||||
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
|
||||
var random_event_remaining: float = 0.0
|
||||
var random_event_label_seconds: int = -1
|
||||
|
||||
func _init(wind: GPUParticles3D, snow: GPUParticles3D,
|
||||
fireflies: GPUParticles3D, rain: GPUParticles3D, ray: PackedScene,
|
||||
dust: ColorRect, blurr: ColorRect, envshadows: MeshInstance3D,
|
||||
dust: ColorRect, blurr: ColorRect, thefog: Node3D, envshadows: MeshInstance3D,
|
||||
thesun: DirectionalLight3D, theenvironment: WorldEnvironment, environmentconfig: EnvironmentConfig,
|
||||
thecamera: Camera3D, audiostreamplayer: AudioStreamPlayer3D, thundersounds: Array[AudioStream]) -> void:
|
||||
thecamera: Camera3D, thecamerapivot: Node3D, thundersounds: Array[AudioStream], rainsounds: Array[AudioStream]) -> void:
|
||||
particles_wind = wind
|
||||
particles_snow = snow
|
||||
particles_fireflies = fireflies
|
||||
@@ -54,36 +67,54 @@ func _init(wind: GPUParticles3D, snow: GPUParticles3D,
|
||||
sun = thesun
|
||||
environment_dust = dust
|
||||
blur = blurr
|
||||
fog = thefog
|
||||
environment_shadows = envshadows
|
||||
environment = theenvironment
|
||||
environment_config = environmentconfig
|
||||
max_wind_amount = environment_config.wind_amount if environment_config != null else 0
|
||||
camera = thecamera
|
||||
camera_pivot = thecamerapivot
|
||||
thunder_sounds = thundersounds
|
||||
audio_player = audiostreamplayer
|
||||
rain_sounds = rainsounds
|
||||
|
||||
set_rain()
|
||||
init_rain()
|
||||
|
||||
set_fireflies()
|
||||
init_fireflies()
|
||||
|
||||
set_wind()
|
||||
init_wind()
|
||||
|
||||
set_snow()
|
||||
init_snow()
|
||||
|
||||
set_lightning()
|
||||
init_lightning()
|
||||
|
||||
create_sound_players()
|
||||
|
||||
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:
|
||||
camera_pivot.get_node("pivot").camera_changed.connect(_set_camera)
|
||||
|
||||
func _ready() -> void:
|
||||
|
||||
#connect events
|
||||
UIEvents.toggle_rain.connect(toggle_rain)
|
||||
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_fog_overlay.connect(toggle_fog_overlay)
|
||||
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:
|
||||
_update_random_event_label(delta)
|
||||
|
||||
_follow_camera()
|
||||
|
||||
@@ -101,6 +132,7 @@ 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:
|
||||
@@ -110,7 +142,7 @@ func _process(delta: float) -> void:
|
||||
timer_next_lightning -= delta
|
||||
if timer_next_lightning <= 0.0:
|
||||
start_lightning()
|
||||
set_lightning_timer()
|
||||
init_lightning_timer()
|
||||
else:
|
||||
rain_intensity = move_toward(rain_intensity, 0.0, delta * 0.5)
|
||||
|
||||
@@ -128,6 +160,7 @@ 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
|
||||
@@ -141,6 +174,7 @@ 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
|
||||
@@ -152,6 +186,7 @@ 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)
|
||||
@@ -165,17 +200,17 @@ 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)
|
||||
|
||||
#Snow exposure compensation
|
||||
var snow_light_attenuation = lerp(1.0, 0.55, actual_snow_amount * (1.0 - night_val))
|
||||
var snow_glow_attenuation = lerp(1.0, 0.5, actual_snow_amount)
|
||||
|
||||
var final_bloom = lerp(base_bloom, base_bloom * 0.5, rain_intensity) * snow_glow_attenuation
|
||||
|
||||
# We calculate the final exposure by applying snow damping directly to the camera exposure
|
||||
var final_esposizione = base_exposure * snow_light_attenuation
|
||||
var final_exposure = base_exposure * snow_light_attenuation
|
||||
|
||||
var reflected_color = Color(0.4, 0.5, 0.6, 1.0)
|
||||
var drops_color = final_sky_horizon.lerp(reflected_color, 0.15)
|
||||
@@ -203,9 +238,7 @@ func _process(delta: float) -> void:
|
||||
# Apply glow
|
||||
environment.environment.glow_enabled = true
|
||||
environment.environment.glow_intensity = final_bloom
|
||||
|
||||
# Make sure the Tonemap Mode in the Environment is set to ACES or Filmic for best results!
|
||||
environment.environment.tonemap_exposure = final_esposizione
|
||||
environment.environment.tonemap_exposure = final_exposure
|
||||
|
||||
var sky_mat = environment.environment.sky.sky_material as ShaderMaterial
|
||||
if sky_mat:
|
||||
@@ -223,12 +256,51 @@ func _process(delta: float) -> void:
|
||||
if environment_config.material_fog:
|
||||
environment_config.material_fog.set_shader_parameter("night_intensity", night_val)
|
||||
environment_config.material_fog.set_shader_parameter("sun_color", final_tint)
|
||||
|
||||
|
||||
func create_sound_players():
|
||||
rain_audio_player = AudioStreamPlayer.new()
|
||||
rain_audio_player.name = "RainAudioPlayer"
|
||||
rain_audio_player.volume_db = environment_config.rain_audio_volume_db
|
||||
rain_audio_player.finished.connect(_on_rain_audio_player_finished)
|
||||
add_child(rain_audio_player)
|
||||
|
||||
thunder_audio_player = AudioStreamPlayer.new()
|
||||
thunder_audio_player.name = "ThunderAudioPlayer"
|
||||
thunder_audio_player.volume_db = environment_config.thunder_audio_volume_db
|
||||
add_child(thunder_audio_player)
|
||||
|
||||
#region camera
|
||||
func _set_camera(curr_camera: Camera3D):
|
||||
camera = curr_camera
|
||||
|
||||
func _get_weather_anchor_position() -> Variant:
|
||||
if camera_pivot and is_instance_valid(camera_pivot):
|
||||
return camera_pivot.global_position
|
||||
if camera and is_instance_valid(camera):
|
||||
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:
|
||||
if not camera or not is_instance_valid(camera):
|
||||
var cam_pos = _get_weather_anchor_position()
|
||||
if cam_pos == null:
|
||||
return
|
||||
var cam_pos: Vector3 = camera.global_position
|
||||
if particles_rain:
|
||||
particles_rain.global_position = Vector3(cam_pos.x, particles_rain.position.y, cam_pos.z)
|
||||
if particles_snow:
|
||||
@@ -237,6 +309,13 @@ 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
|
||||
|
||||
@@ -247,7 +326,7 @@ func toggle_fireflies(value: bool):
|
||||
particles_fireflies.emitting = thereare_fireflies and is_night
|
||||
|
||||
#disable fireflies and set default values and materials
|
||||
func set_fireflies():
|
||||
func init_fireflies():
|
||||
if particles_fireflies:
|
||||
particles_fireflies.visible = true
|
||||
particles_fireflies.emitting = false
|
||||
@@ -265,8 +344,12 @@ func toggle_wind(value: bool):
|
||||
if particles_wind:
|
||||
particles_wind.emitting = is_windy
|
||||
|
||||
_apply_wind_state()
|
||||
_emit_weather_event_label()
|
||||
|
||||
#disable wind and set default values and materials
|
||||
func set_wind():
|
||||
func init_wind():
|
||||
_update_wind_amount_from_strength(environment_config.wind_strength)
|
||||
if particles_wind:
|
||||
particles_wind.visible = true
|
||||
particles_wind.emitting = false
|
||||
@@ -278,12 +361,154 @@ func set_wind():
|
||||
if environment_config:
|
||||
_apply_cloud_config()
|
||||
_apply_wind_config()
|
||||
_apply_dust_config()
|
||||
|
||||
func _apply_wind_config() -> void:
|
||||
RenderingServer.global_shader_parameter_set("global_wind_speed", environment_config.wind_speed)
|
||||
RenderingServer.global_shader_parameter_set("global_wind_direction", environment_config.wind_direction)
|
||||
RenderingServer.global_shader_parameter_set("global_wind_scale", environment_config.wind_scale)
|
||||
RenderingServer.global_shader_parameter_set("global_wind_strength", environment_config.wind_strength)
|
||||
RenderingServer.global_shader_parameter_set("global_wind_direction", environment_config.wind_direction)
|
||||
RenderingServer.global_shader_parameter_set("global_wind_scale", environment_config.wind_scale)
|
||||
if particles_wind:
|
||||
var proc_mat_wind = particles_wind.process_material as ParticleProcessMaterial
|
||||
if proc_mat_wind:
|
||||
var wind_direction_3d := Vector3(environment_config.wind_direction.x, 0.0, environment_config.wind_direction.y)
|
||||
if wind_direction_3d.length_squared() > 0.0:
|
||||
var wind_axis := wind_direction_3d.normalized()
|
||||
var wind_cross := wind_axis.cross(Vector3.UP)
|
||||
if wind_cross.length_squared() == 0.0:
|
||||
wind_cross = Vector3.FORWARD
|
||||
else:
|
||||
wind_cross = wind_cross.normalized()
|
||||
var wind_up := wind_cross.cross(wind_axis).normalized()
|
||||
proc_mat_wind.direction = wind_axis
|
||||
particles_wind.global_transform = Transform3D(Basis(wind_cross, wind_axis, wind_up), particles_wind.global_position)
|
||||
|
||||
_apply_wind_state(true)
|
||||
|
||||
func _apply_wind_state(immediate: bool = false) -> void:
|
||||
if environment_config == null:
|
||||
return
|
||||
|
||||
if wind_tween and wind_tween.is_valid():
|
||||
wind_tween.kill()
|
||||
|
||||
var active_wind_speed := environment_config.wind_speed if is_windy else 0.0
|
||||
var active_wind_strength := environment_config.wind_strength if is_windy else 0.0
|
||||
var active_wind_fade := 1.0 if is_windy else 0.0
|
||||
if immediate:
|
||||
_set_current_wind_speed(active_wind_speed)
|
||||
_set_current_wind_strength(active_wind_strength)
|
||||
_set_current_wind_fade(active_wind_fade)
|
||||
return
|
||||
|
||||
_set_current_wind_speed(environment_config.wind_speed)
|
||||
_set_current_wind_strength(environment_config.wind_strength)
|
||||
wind_tween = create_tween()
|
||||
wind_tween.tween_method(_set_current_wind_fade, current_wind_fade, active_wind_fade, environment_config.wind_fade_in_out_time)
|
||||
wind_tween.tween_callback(_finish_wind_fade_out)
|
||||
|
||||
func _set_current_wind_speed(value: float) -> void:
|
||||
current_wind_speed = value
|
||||
RenderingServer.global_shader_parameter_set("global_wind_speed", value)
|
||||
|
||||
func _set_current_wind_strength(value: float) -> void:
|
||||
current_wind_strength = value
|
||||
RenderingServer.global_shader_parameter_set("global_wind_strength", value)
|
||||
|
||||
func _set_current_wind_fade(value: float) -> void:
|
||||
current_wind_fade = value
|
||||
RenderingServer.global_shader_parameter_set("global_wind_fade", value)
|
||||
|
||||
func _finish_wind_fade_out() -> void:
|
||||
if is_windy:
|
||||
return
|
||||
|
||||
_set_current_wind_speed(0.0)
|
||||
_set_current_wind_strength(0.0)
|
||||
_set_current_wind_fade(0.0)
|
||||
|
||||
func change_wind_strength(value: float) -> void:
|
||||
if environment_config == null:
|
||||
return
|
||||
|
||||
environment_config.wind_strength = value
|
||||
_update_wind_amount_from_strength(value)
|
||||
if is_windy or current_wind_fade > 0.0:
|
||||
_set_current_wind_strength(value)
|
||||
if particles_wind:
|
||||
particles_wind.amount = environment_config.wind_amount
|
||||
|
||||
func _update_wind_amount_from_strength(value: float) -> void:
|
||||
if environment_config == null:
|
||||
return
|
||||
if max_wind_amount <= 0:
|
||||
max_wind_amount = max(environment_config.wind_amount, 1)
|
||||
|
||||
var normalized_strength: float = clamp(value, 0.0, 1.0)
|
||||
var amount_ratio: float = normalized_strength
|
||||
if normalized_strength > 0.0 and normalized_strength < 0.3:
|
||||
amount_ratio = lerp(0.08, 0.25, normalized_strength / 0.3)
|
||||
|
||||
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()
|
||||
random_event_remaining = 0.0
|
||||
random_event_label_seconds = -1
|
||||
|
||||
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_event_remaining = duration
|
||||
_emit_weather_event_label()
|
||||
random_weather_restore_tween = create_tween()
|
||||
random_weather_restore_tween.tween_interval(duration)
|
||||
random_weather_restore_tween.tween_callback(func():
|
||||
random_event_remaining = 0.0
|
||||
random_event_label_seconds = -1
|
||||
_apply_weather_event_state(previous_rain, previous_snow, previous_wind, previous_storm)
|
||||
)
|
||||
|
||||
func _update_random_event_label(delta: float) -> void:
|
||||
if random_event_remaining <= 0.0:
|
||||
return
|
||||
|
||||
random_event_remaining = maxf(random_event_remaining - delta, 0.0)
|
||||
var display_seconds: int = ceili(random_event_remaining)
|
||||
if display_seconds != random_event_label_seconds:
|
||||
random_event_label_seconds = display_seconds
|
||||
_emit_weather_event_label()
|
||||
|
||||
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
|
||||
@@ -316,9 +541,10 @@ func _apply_cloud_config() -> void:
|
||||
|
||||
func toggle_storm(value: bool):
|
||||
is_storm = value
|
||||
_emit_weather_event_label()
|
||||
|
||||
#set lightning
|
||||
func set_lightning():
|
||||
func init_lightning():
|
||||
lightning_light.name = "Lightning Light"
|
||||
lightning_light.transform = Transform3D(
|
||||
Vector3(-0.6238797, -0.342596, 0.7024259), # asse X
|
||||
@@ -333,7 +559,7 @@ func set_lightning():
|
||||
add_child(lightning_light)
|
||||
|
||||
create_lightning_sprite()
|
||||
set_lightning_timer()
|
||||
init_lightning_timer()
|
||||
|
||||
func create_lightning_sprite():
|
||||
lightning_sprite = Sprite3D.new()
|
||||
@@ -358,7 +584,7 @@ func create_lightning_sprite():
|
||||
add_child(lightning_sprite)
|
||||
|
||||
#set next lightning timer
|
||||
func set_lightning_timer():
|
||||
func init_lightning_timer():
|
||||
timer_next_lightning = randf_range(environment_config.lightning_min_time, environment_config.lightning_max_time)
|
||||
|
||||
func start_lightning():
|
||||
@@ -400,22 +626,25 @@ func start_lightning():
|
||||
func _play_thunder_delayed(delay: float):
|
||||
await get_tree().create_timer(delay).timeout
|
||||
|
||||
if thunder_sounds.is_empty() or not audio_player:
|
||||
if thunder_sounds.is_empty() or not thunder_audio_player:
|
||||
return
|
||||
#choose a random track
|
||||
audio_player.stream = thunder_sounds[randi() % thunder_sounds.size()]
|
||||
audio_player.pitch_scale = randf_range(0.9, 1.1)
|
||||
audio_player.play()
|
||||
|
||||
|
||||
thunder_audio_player.stream = thunder_sounds[randi() % thunder_sounds.size()]
|
||||
thunder_audio_player.pitch_scale = randf_range(0.9, 1.1)
|
||||
thunder_audio_player.play()
|
||||
|
||||
#endregion
|
||||
|
||||
#region Rain
|
||||
|
||||
#disable rain
|
||||
func set_rain():
|
||||
func init_rain():
|
||||
if particles_rain:
|
||||
particles_rain.visible = true
|
||||
particles_rain.emitting = false
|
||||
if rain_audio_player:
|
||||
rain_audio_player.volume_db = environment_config.rain_audio_volume_db
|
||||
rain_audio_player.stop()
|
||||
RenderingServer.global_shader_parameter_set("global_rain_puddle_amount", 0.0)
|
||||
|
||||
func set_puddle_amount(value: float):
|
||||
@@ -426,6 +655,7 @@ func toggle_rain(value: bool):
|
||||
is_raining = value
|
||||
|
||||
if not particles_rain:
|
||||
_emit_weather_event_label()
|
||||
return
|
||||
|
||||
if is_raining and is_snowing:
|
||||
@@ -440,11 +670,18 @@ func toggle_rain(value: bool):
|
||||
if is_raining:
|
||||
particles_rain.amount_ratio = 0.0
|
||||
particles_rain.emitting = true
|
||||
if rain_audio_player:
|
||||
if not rain_audio_player.playing:
|
||||
rain_audio_player.volume_db = -80.0
|
||||
_play_random_rain_sound()
|
||||
_fade_rain_audio(environment_config.rain_audio_volume_db, false)
|
||||
rain_tween = create_tween()
|
||||
rain_tween.tween_property(particles_rain, "amount_ratio", 1.0, environment_config.rain_fade_time)
|
||||
puddle_tween = create_tween()
|
||||
puddle_tween.tween_method(set_puddle_amount, puddle_amount, 1.0, environment_config.puddle_form_time)
|
||||
else:
|
||||
if rain_audio_player:
|
||||
_fade_rain_audio(-80.0, true)
|
||||
rain_tween = create_tween()
|
||||
rain_tween.tween_property(particles_rain, "amount_ratio", 0.0, environment_config.rain_fade_time)
|
||||
rain_tween.tween_callback(func():
|
||||
@@ -452,6 +689,7 @@ 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()
|
||||
@@ -470,17 +708,51 @@ func spawn_single_godray() -> void:
|
||||
var random_z: float = randf_range(-environment_config.godray_spawn_radius, environment_config.godray_spawn_radius)
|
||||
|
||||
var center := Vector3.ZERO
|
||||
if camera and is_instance_valid(camera):
|
||||
center = camera.global_position
|
||||
var anchor_pos = _get_weather_anchor_position()
|
||||
if anchor_pos != null:
|
||||
center = anchor_pos
|
||||
ray.global_position = Vector3(center.x + random_x, environment_config.godray_spawn_height, center.z + random_z)
|
||||
ray.rotation_degrees = environment_config.godray_rotation_degrees
|
||||
ray.scale = environment_config.godray_scale
|
||||
|
||||
var godray_tween: Tween = create_tween()
|
||||
godray_tween.tween_interval(2.0)
|
||||
godray_tween.tween_property(ray, "scale", Vector3.ZERO, 2.0).set_ease(Tween.EASE_IN).set_trans(Tween.TRANS_SINE)
|
||||
godray_tween.tween_callback(ray.queue_free)
|
||||
if ray.has_method("set_visual_rotation_degrees"):
|
||||
ray.call("set_visual_rotation_degrees", environment_config.godray_rotation_degrees)
|
||||
else:
|
||||
ray.rotation_degrees = environment_config.godray_rotation_degrees
|
||||
if ray.has_method("set_visual_scale"):
|
||||
ray.call("set_visual_scale", environment_config.godray_scale)
|
||||
else:
|
||||
ray.scale = environment_config.godray_scale
|
||||
if ray.has_method("orient_to_camera"):
|
||||
ray.call("orient_to_camera")
|
||||
|
||||
func _play_random_rain_sound() -> void:
|
||||
if rain_sounds.is_empty() or rain_audio_player == null:
|
||||
return
|
||||
|
||||
rain_audio_player.stream = rain_sounds[randi() % rain_sounds.size()]
|
||||
rain_audio_player.pitch_scale = 1.0
|
||||
rain_audio_player.volume_db = minf(rain_audio_player.volume_db, environment_config.rain_audio_volume_db)
|
||||
rain_audio_player.play()
|
||||
|
||||
func _on_rain_audio_player_finished() -> void:
|
||||
if is_raining:
|
||||
_play_random_rain_sound()
|
||||
|
||||
func _fade_rain_audio(target_volume_db: float, stop_after_fade: bool) -> void:
|
||||
if rain_audio_player == null:
|
||||
return
|
||||
|
||||
if rain_audio_tween and rain_audio_tween.is_valid():
|
||||
rain_audio_tween.kill()
|
||||
|
||||
rain_audio_tween = create_tween()
|
||||
rain_audio_tween.tween_property(
|
||||
rain_audio_player,
|
||||
"volume_db",
|
||||
target_volume_db,
|
||||
environment_config.rain_fade_time #same value of the rain particles
|
||||
)
|
||||
if stop_after_fade:
|
||||
rain_audio_tween.tween_callback(func(): rain_audio_player.stop())
|
||||
|
||||
#endregion
|
||||
|
||||
#region Snow
|
||||
@@ -515,10 +787,29 @@ func toggle_snow(value: bool):
|
||||
if snow_tween and snow_tween.is_valid():
|
||||
snow_tween.kill()
|
||||
snow_tween = create_tween()
|
||||
snow_tween.tween_method(set_snow_amount, actual_snow_amount, target_snow_amount, environment_config.snow_transaction_time)
|
||||
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)
|
||||
if random_event_remaining > 0.0:
|
||||
weather_label += " (%s'')" % ceili(random_event_remaining)
|
||||
UIEvents.weather_event_changed.emit(weather_label)
|
||||
|
||||
#disable snow and set default values and shader
|
||||
func set_snow(value: float = 0.0):
|
||||
func init_snow(value: float = 0.0):
|
||||
actual_snow_amount = value
|
||||
RenderingServer.global_shader_parameter_set("global_snow_amount", value)
|
||||
|
||||
@@ -530,10 +821,17 @@ func set_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)
|
||||
|
||||
func set_snow_amount(value: float):
|
||||
func init_snow_amount(value: float):
|
||||
actual_snow_amount = value
|
||||
RenderingServer.global_shader_parameter_set("global_snow_amount", value)
|
||||
|
||||
@@ -557,8 +855,38 @@ func toggle_blur(value: bool) -> void:
|
||||
if blur:
|
||||
blur.visible = value
|
||||
|
||||
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
|
||||
|
||||
func ApplyPostProcessBlurConfig() -> void:
|
||||
if blur == null:
|
||||
return
|
||||
|
||||
var blur_material := blur.material as ShaderMaterial
|
||||
if blur_material:
|
||||
blur_material.set_shader_parameter("blur_amount", environment_config.blur_amount)
|
||||
|
||||
func _apply_dust_config() -> void:
|
||||
var dust_color: Color = environment_config.dust_color
|
||||
var dust_speed: float = environment_config.dust_speed
|
||||
var dust_density: float = environment_config.dust_density
|
||||
var dust_size_min: float = environment_config.dust_size_min
|
||||
var dust_size_max: float = environment_config.dust_size_max
|
||||
|
||||
if environment_dust:
|
||||
var dust_mat = environment_dust.material as ShaderMaterial
|
||||
if dust_mat:
|
||||
dust_mat.set_shader_parameter("dust_color", dust_color)
|
||||
dust_mat.set_shader_parameter("dust_speed", dust_speed)
|
||||
dust_mat.set_shader_parameter("dust_density", dust_density)
|
||||
dust_mat.set_shader_parameter("dust_size_min", dust_size_min)
|
||||
dust_mat.set_shader_parameter("dust_size_max", dust_size_max)
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -6,8 +6,16 @@ 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;
|
||||
@@ -29,6 +37,58 @@ 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;
|
||||
@@ -36,6 +96,27 @@ 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);
|
||||
@@ -43,25 +124,23 @@ void fragment() {
|
||||
float noise_val = texture(noise_texture, world_pos.xz * snow_noise_scale).r;
|
||||
|
||||
//Snow
|
||||
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_progress = v_snow_amount;
|
||||
float snow_accumulation = snow_progress * global_snow_max_accumulation;
|
||||
|
||||
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 snow_coverage = smoothstep(0.0, 0.6, noise_val + snow_amount - 0.4);
|
||||
float snow_factor = snow_edge * snow_coverage * snow_amount;
|
||||
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 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
|
||||
@@ -173,7 +252,7 @@ void fragment() {
|
||||
ALBEDO = snow_albedo;
|
||||
ROUGHNESS = snow_rough;
|
||||
METALLIC = 0.0;
|
||||
ALPHA = snow_factor;
|
||||
ALPHA = snow_opacity;
|
||||
} else {
|
||||
ALBEDO = rain_albedo;
|
||||
ROUGHNESS = rain_rough;
|
||||
|
||||
@@ -5,3 +5,17 @@
|
||||
[resource]
|
||||
render_priority = 0
|
||||
shader = ExtResource("1_weather")
|
||||
shader_parameter/snow_noise_scale = 0.15
|
||||
shader_parameter/snow_edge_softness = 0.2
|
||||
shader_parameter/snow_roughness_variation = 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
|
||||
|
||||
@@ -7,16 +7,13 @@ 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,7 +1,21 @@
|
||||
[gd_resource type="ShaderMaterial" format=3]
|
||||
[gd_resource type="ShaderMaterial" format=3 uid="uid://b34bnqbrtxktw"]
|
||||
|
||||
[ext_resource type="Shader" path="res://core/daynight/weather_plain_shader.gdshader" id="1_weather_plain"]
|
||||
[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"]
|
||||
|
||||
[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,31 +1,26 @@
|
||||
shader_type spatial;
|
||||
render_mode unshaded;
|
||||
|
||||
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;
|
||||
// --- 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
|
||||
|
||||
void vertex() {
|
||||
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;
|
||||
// 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!
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -2,12 +2,21 @@ class_name EnvironmentConfig
|
||||
extends Resource
|
||||
|
||||
@export_group("Day")
|
||||
@export var start_time: float = 0.0 #start time of the day
|
||||
@export var day_duration: float = 300.0 #Duration of a full day cycle in seconds
|
||||
@export var sunrise: float = 0.25 #day_time 1.0→2.0 (night colors → morning colors)
|
||||
@export var day: float = 0.45 #day_time 2.0→2.0 (stays morning/afternoon)
|
||||
@export var sunset: float = 0.80 #day_time 2.0→3.0 (afternoon colors → night colors)
|
||||
@export var night: float = 1.00 #day_time 3.0→3.0 (stays night)
|
||||
#At wrap 1.0→0.0: day_time stays 3.0, then fades back via sunrise
|
||||
|
||||
@export_group("Debug")
|
||||
@export var show_day_time_debug: bool = true #enable/disable debug on screen (time, normalized time and day_time
|
||||
|
||||
#Ambient light color tinting for each time of day
|
||||
@export_group("Directional Lights and Environment")
|
||||
@export var morning_color: Color = Color(1.0, 0.9, 0.8, 1.0) #Tint for morning
|
||||
@export var afternoon_color: Color = Color(1.0, 0.6, 0.2, 1.0) #Tint for afternoon (sunset)
|
||||
@export var afternoon_color: Color = Color(1.0, 0.663, 0.366, 1.0) #Tint for afternoon (sunset)
|
||||
@export var night_color: Color = Color(0.1, 0.1, 0.3, 1.0) #Tint for night
|
||||
|
||||
#Sun directional light rotation for each time of day
|
||||
@@ -71,9 +80,18 @@ extends Resource
|
||||
|
||||
#Post-process effect toggles (initial values)
|
||||
@export_group("Post Process")
|
||||
@export var enable_dust: bool = true #Floating dust particles overlay
|
||||
@export var enable_dust: bool = false #Floating dust particles overlay
|
||||
@export var enable_blur: bool = true #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")
|
||||
@export var dust_color: Color = Color(1.0, 0.456, 0.125, 0.6) #dust color
|
||||
@export var dust_speed: float = 0.15 #dust speed
|
||||
@export var dust_density: float = 1.0 #dust density
|
||||
@export var dust_size_min: float = 0.02; #dust min size
|
||||
@export var dust_size_max: float = 0.2; #dust max size
|
||||
|
||||
#Shader materials used by weather and sky systems
|
||||
@export_group("Environment Materials")
|
||||
@@ -83,15 +101,16 @@ extends Resource
|
||||
|
||||
#Rain weather settings
|
||||
@export_group("Rain")
|
||||
@export var rain_mode_color: Color = Color(0.5, 0.6, 0.7, 1.0) #Sky/light darkening color during rain
|
||||
@export var rain_mode_color: Color = Color(0.85, 0.89, 0.93, 1.0) #Sky/light darkening color during rain
|
||||
@export var rain_fade_time: float = 5.0 #Seconds for rain particles to fade in/out
|
||||
@export var rain_audio_volume_db: float = -10.0 #Target rain loop volume in decibels
|
||||
@export var puddle_form_time: float = 15.0 #Seconds for puddles to fully form
|
||||
@export var puddle_dry_time: float = 20.0 #Seconds for puddles to fully dry after rain stops
|
||||
|
||||
#Storm settings (applied on top of rain when storm is active)
|
||||
@export_group("Storm")
|
||||
@export var storm_rain_intensity_multiplier: float = 1.5 #Rain intensity target during storm (1.0 = normal rain)
|
||||
@export var storm_mode_color: Color = Color(0.476, 0.531, 0.639, 1.0) #Additional sky darkening color during storm
|
||||
@export var storm_mode_color: Color = Color(0.78, 0.83, 0.89, 1.0) #Additional sky darkening color during storm
|
||||
|
||||
#Lightning and thunder configuration
|
||||
@export_group("Lightning and Thunders")
|
||||
@@ -104,7 +123,7 @@ extends Resource
|
||||
@export var lightning_scale_max: float = 3.0 #Maximum random scale of lightning sprite
|
||||
@export var lightning_texture: String = "res://core/daynight/lighting_albedo.png" # Lightning bolt texture path
|
||||
@export var weather_event_interval: float = 8.0 #Base interval between weather events
|
||||
#thunder sound is configured on daynight node
|
||||
@export var thunder_audio_volume_db: float = 0.0 #Target thunder volume in decibels
|
||||
|
||||
#God rays spawned after rain or at morning
|
||||
@export_group("God Rays")
|
||||
@@ -115,15 +134,27 @@ 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.02 #Accumulation speed: 0.1 -> 10s, 0.05 -> 20s, 0.02 -> 50s, 0.2 -> 5s
|
||||
@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_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
|
||||
@@ -134,14 +165,26 @@ 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.6 #Global wind displacement strength
|
||||
@export var wind_strength: float = 0.3 #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
|
||||
@export_range(0.01, 1.0) var cloud_speed_envshadows_rate: float = 0.5 #Cloud speed multiplier for environment shadows
|
||||
@export var wind_fade_in_out_time: float = 1.2 #fade out to time when wind is turned off or when is turned on
|
||||
|
||||
#Firefly settings (visible only at night)
|
||||
@export_group("Fireflies")
|
||||
@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
|
||||
|
||||
#Random events
|
||||
@export_group("Random Events")
|
||||
@export var random_event_duration: float = 30.0 #Duration time for random event
|
||||
|
||||
27
core/fireworks.gd
Normal file
27
core/fireworks.gd
Normal file
@@ -0,0 +1,27 @@
|
||||
extends Node3D
|
||||
@onready var rocket = $"1_StartRocket"
|
||||
@onready var explosion = $"2_MainExplosion"
|
||||
@onready var trails = $"3_FallingTrails"
|
||||
|
||||
func set_color(target_color: Color) -> void:
|
||||
#set colors
|
||||
set_particles_node_color(rocket, Color(1.5, 1.5, 1.5))
|
||||
set_particles_node_color(explosion, Color(1.2, 1.2, 1.2))
|
||||
set_particles_node_color(trails, target_color)
|
||||
|
||||
func set_particles_node_color(node: GPUParticles3D, new_color: Color) -> void:
|
||||
if node and node.draw_pass_1:
|
||||
var mesh = node.draw_pass_1 as QuadMesh
|
||||
if mesh and mesh.material:
|
||||
var unique_mat = mesh.material.duplicate() as StandardMaterial3D
|
||||
unique_mat.albedo_color = new_color
|
||||
unique_mat.blend_mode = BaseMaterial3D.BLEND_MODE_ADD #Light effect (glow)
|
||||
unique_mat.shading_mode = BaseMaterial3D.SHADING_MODE_UNSHADED
|
||||
mesh.material = unique_mat
|
||||
|
||||
func turn_on() -> void:
|
||||
if rocket:
|
||||
rocket.emitting = true
|
||||
|
||||
await get_tree().create_timer(6.0).timeout
|
||||
queue_free()
|
||||
1
core/fireworks.gd.uid
Normal file
1
core/fireworks.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://crxch6o5ottg7
|
||||
104
core/fireworks.tscn
Normal file
104
core/fireworks.tscn
Normal file
@@ -0,0 +1,104 @@
|
||||
[gd_scene format=3 uid="uid://dn1btv0e0ses7"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://crxch6o5ottg7" path="res://core/fireworks.gd" id="1_cjxyo"]
|
||||
|
||||
[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_dp1bx"]
|
||||
direction = Vector3(0, 1, 0)
|
||||
spread = 0.0
|
||||
initial_velocity_min = 13.0
|
||||
initial_velocity_max = 14.0
|
||||
gravity = Vector3(0, 0, 0)
|
||||
sub_emitter_mode = 2
|
||||
sub_emitter_amount_at_end = 1
|
||||
|
||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_8o1ow"]
|
||||
blend_mode = 1
|
||||
shading_mode = 0
|
||||
albedo_color = Color(1, 0.8901961, 0.24313726, 1)
|
||||
billboard_mode = 3
|
||||
particles_anim_h_frames = 1
|
||||
particles_anim_v_frames = 1
|
||||
particles_anim_loop = false
|
||||
|
||||
[sub_resource type="QuadMesh" id="QuadMesh_p8l00"]
|
||||
material = SubResource("StandardMaterial3D_8o1ow")
|
||||
size = Vector2(0.2, 0.2)
|
||||
|
||||
[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_kbf61"]
|
||||
direction = Vector3(0, 1, 0)
|
||||
spread = 180.0
|
||||
initial_velocity_min = 10.0
|
||||
initial_velocity_max = 10.0
|
||||
gravity = Vector3(0, 0, 0)
|
||||
damping_min = 6.0000005
|
||||
damping_max = 6.0000005
|
||||
sub_emitter_mode = 1
|
||||
sub_emitter_frequency = 30.0
|
||||
|
||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_is2bb"]
|
||||
blend_mode = 1
|
||||
shading_mode = 0
|
||||
billboard_mode = 3
|
||||
particles_anim_h_frames = 1
|
||||
particles_anim_v_frames = 1
|
||||
particles_anim_loop = false
|
||||
|
||||
[sub_resource type="QuadMesh" id="QuadMesh_f60hc"]
|
||||
material = SubResource("StandardMaterial3D_is2bb")
|
||||
size = Vector2(0.2, 0.2)
|
||||
|
||||
[sub_resource type="Gradient" id="Gradient_cjxyo"]
|
||||
colors = PackedColorArray(1, 1, 1, 1, 1, 1, 1, 0)
|
||||
|
||||
[sub_resource type="GradientTexture1D" id="GradientTexture1D_dp1bx"]
|
||||
gradient = SubResource("Gradient_cjxyo")
|
||||
|
||||
[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_tt4r5"]
|
||||
gravity = Vector3(0, -2, 0)
|
||||
scale_min = 0.5
|
||||
scale_max = 0.5
|
||||
color_ramp = SubResource("GradientTexture1D_dp1bx")
|
||||
|
||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_xt2tl"]
|
||||
blend_mode = 1
|
||||
shading_mode = 0
|
||||
albedo_color = Color(0.99999994, 0.89069206, 0.2446233, 1)
|
||||
billboard_mode = 3
|
||||
particles_anim_h_frames = 1
|
||||
particles_anim_v_frames = 1
|
||||
particles_anim_loop = false
|
||||
|
||||
[sub_resource type="QuadMesh" id="QuadMesh_0p1ln"]
|
||||
material = SubResource("StandardMaterial3D_xt2tl")
|
||||
size = Vector2(0.05, 0.05)
|
||||
|
||||
[node name="FuocoD\'artificioRoot" type="Node3D" unique_id=669752765]
|
||||
script = ExtResource("1_cjxyo")
|
||||
|
||||
[node name="1_StartRocket" type="GPUParticles3D" parent="." unique_id=1569398174]
|
||||
emitting = false
|
||||
amount = 15
|
||||
sub_emitter = NodePath("../2_MainExplosion")
|
||||
lifetime = 0.5
|
||||
one_shot = true
|
||||
explosiveness = 1.0
|
||||
trail_enabled = true
|
||||
process_material = SubResource("ParticleProcessMaterial_dp1bx")
|
||||
draw_pass_1 = SubResource("QuadMesh_p8l00")
|
||||
|
||||
[node name="2_MainExplosion" type="GPUParticles3D" parent="." unique_id=863445356]
|
||||
emitting = false
|
||||
amount = 150
|
||||
sub_emitter = NodePath("../3_FallingTrails")
|
||||
lifetime = 1.5
|
||||
one_shot = true
|
||||
explosiveness = 1.0
|
||||
process_material = SubResource("ParticleProcessMaterial_kbf61")
|
||||
draw_pass_1 = SubResource("QuadMesh_f60hc")
|
||||
|
||||
[node name="3_FallingTrails" type="GPUParticles3D" parent="." unique_id=1969872503]
|
||||
emitting = false
|
||||
amount = 500
|
||||
lifetime = 0.5
|
||||
process_material = SubResource("ParticleProcessMaterial_tt4r5")
|
||||
draw_pass_1 = SubResource("QuadMesh_0p1ln")
|
||||
2
core/snow.gdshader
Normal file
2
core/snow.gdshader
Normal file
@@ -0,0 +1,2 @@
|
||||
shader_type spatial;
|
||||
|
||||
1
core/snow.gdshader.uid
Normal file
1
core/snow.gdshader.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://btf3qpe7kwqig
|
||||
@@ -8,6 +8,12 @@ signal toggle_snow(value: bool)
|
||||
@warning_ignore("unused_signal")
|
||||
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)
|
||||
@@ -21,7 +27,19 @@ 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)
|
||||
|
||||
#railway signals
|
||||
@warning_ignore("unused_signal")
|
||||
signal update_rail_chunks()
|
||||
|
||||
#day cycle signals
|
||||
@warning_ignore("unused_signal")
|
||||
signal toggle_pause_daytime(value: bool)
|
||||
@warning_ignore("unused_signal")
|
||||
signal day_time_changed(value: float, time_string: String)
|
||||
@warning_ignore("unused_signal")
|
||||
signal time_option_item_changed(index: int)
|
||||
@warning_ignore("unused_signal")
|
||||
signal day_time_option_changed(index: int)
|
||||
|
||||
6
docs/museums/biome_generator/museum_biome_generator.gd
Normal file
6
docs/museums/biome_generator/museum_biome_generator.gd
Normal file
@@ -0,0 +1,6 @@
|
||||
extends Node3D
|
||||
|
||||
func _input(event):
|
||||
if event is InputEventKey and event.pressed:
|
||||
if event.keycode == KEY_ESCAPE:
|
||||
get_tree().quit()
|
||||
@@ -0,0 +1 @@
|
||||
uid://bw42tcfoee7xl
|
||||
388
docs/museums/biome_generator/museum_biome_generator.tscn
Normal file
388
docs/museums/biome_generator/museum_biome_generator.tscn
Normal file
File diff suppressed because one or more lines are too long
445
docs/museums/biome_generator/museum_map.tscn
Normal file
445
docs/museums/biome_generator/museum_map.tscn
Normal file
File diff suppressed because one or more lines are too long
156
docs/museums/biome_generator/rails.tscn
Normal file
156
docs/museums/biome_generator/rails.tscn
Normal file
@@ -0,0 +1,156 @@
|
||||
[gd_scene format=3 uid="uid://0kgjaqijaqku"]
|
||||
|
||||
[ext_resource type="Shader" uid="uid://d0ch5ofrgf7y6" path="res://core/daynight/trunk_shader.gdshader" id="2_0y2rr"]
|
||||
|
||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_m6haf"]
|
||||
render_priority = 0
|
||||
shader = ExtResource("2_0y2rr")
|
||||
shader_parameter/albedo_color = Color(0.08235294, 0.105882354, 0.10980392, 1)
|
||||
shader_parameter/use_texture = true
|
||||
shader_parameter/uv_scale = Vector2(1, 1)
|
||||
shader_parameter/palette_shift_y = 0.0
|
||||
shader_parameter/gradient_start_y = 0.0
|
||||
shader_parameter/gradient_end_y = 10.0
|
||||
shader_parameter/light_steps = 3.0
|
||||
shader_parameter/step_softness = 0.1
|
||||
shader_parameter/shadow_color = Color(0.4, 0.4, 0.6, 1)
|
||||
shader_parameter/shadow_offset = 0.0
|
||||
shader_parameter/cast_shadow_strength = 0.6
|
||||
shader_parameter/use_ghibli_glint = true
|
||||
shader_parameter/glint_color = Color(1, 0.95, 0.85, 1)
|
||||
shader_parameter/glint_intensity = 1.0
|
||||
shader_parameter/glint_sharpness = 32.0
|
||||
shader_parameter/emission_color = Color(0, 0, 0, 1)
|
||||
shader_parameter/emission_energy = 0.0
|
||||
|
||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_duyun"]
|
||||
|
||||
[sub_resource type="BoxMesh" id="BoxMesh_w0ibq"]
|
||||
size = Vector3(0.2, 0.2, 2)
|
||||
|
||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_fttrp"]
|
||||
render_priority = 0
|
||||
shader = ExtResource("2_0y2rr")
|
||||
shader_parameter/albedo_color = Color(0.08061289, 0.10506997, 0.11154168, 1)
|
||||
shader_parameter/use_texture = true
|
||||
shader_parameter/uv_scale = Vector2(1, 1)
|
||||
shader_parameter/palette_shift_y = 0.0
|
||||
shader_parameter/gradient_start_y = 0.0
|
||||
shader_parameter/gradient_end_y = 10.0
|
||||
shader_parameter/light_steps = 3.0
|
||||
shader_parameter/step_softness = 0.1
|
||||
shader_parameter/shadow_color = Color(0.4, 0.4, 0.6, 1)
|
||||
shader_parameter/shadow_offset = 0.0
|
||||
shader_parameter/cast_shadow_strength = 0.6
|
||||
shader_parameter/use_ghibli_glint = true
|
||||
shader_parameter/glint_color = Color(1, 0.95, 0.85, 1)
|
||||
shader_parameter/glint_intensity = 1.0
|
||||
shader_parameter/glint_sharpness = 32.0
|
||||
shader_parameter/emission_color = Color(0, 0, 0, 1)
|
||||
shader_parameter/emission_energy = 0.0
|
||||
|
||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_hb1ej"]
|
||||
|
||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_pp4r2"]
|
||||
render_priority = 0
|
||||
shader = ExtResource("2_0y2rr")
|
||||
shader_parameter/albedo_color = Color(0.2584173, 0.19781098, 0.10103748, 1)
|
||||
shader_parameter/use_texture = true
|
||||
shader_parameter/uv_scale = Vector2(1, 1)
|
||||
shader_parameter/palette_shift_y = 0.0
|
||||
shader_parameter/gradient_start_y = 0.0
|
||||
shader_parameter/gradient_end_y = 10.0
|
||||
shader_parameter/light_steps = 3.0
|
||||
shader_parameter/step_softness = 0.1
|
||||
shader_parameter/shadow_color = Color(0.4, 0.4, 0.6, 1)
|
||||
shader_parameter/shadow_offset = 0.0
|
||||
shader_parameter/cast_shadow_strength = 0.6
|
||||
shader_parameter/use_ghibli_glint = true
|
||||
shader_parameter/glint_color = Color(1, 0.95, 0.85, 1)
|
||||
shader_parameter/glint_intensity = 1.0
|
||||
shader_parameter/glint_sharpness = 32.0
|
||||
shader_parameter/emission_color = Color(0, 0, 0, 1)
|
||||
shader_parameter/emission_energy = 0.0
|
||||
|
||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_pur2n"]
|
||||
|
||||
[sub_resource type="BoxMesh" id="BoxMesh_ysg1u"]
|
||||
size = Vector3(2.5, 0.15, 0.5)
|
||||
|
||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_x2uev"]
|
||||
render_priority = 0
|
||||
shader = ExtResource("2_0y2rr")
|
||||
shader_parameter/albedo_color = Color(0.25882354, 0.19607843, 0.101960786, 1)
|
||||
shader_parameter/use_texture = true
|
||||
shader_parameter/uv_scale = Vector2(1, 1)
|
||||
shader_parameter/palette_shift_y = 0.0
|
||||
shader_parameter/gradient_start_y = 0.0
|
||||
shader_parameter/gradient_end_y = 10.0
|
||||
shader_parameter/light_steps = 3.0
|
||||
shader_parameter/step_softness = 0.1
|
||||
shader_parameter/shadow_color = Color(0.4, 0.4, 0.6, 1)
|
||||
shader_parameter/shadow_offset = 0.0
|
||||
shader_parameter/cast_shadow_strength = 0.6
|
||||
shader_parameter/use_ghibli_glint = true
|
||||
shader_parameter/glint_color = Color(1, 0.95, 0.85, 1)
|
||||
shader_parameter/glint_intensity = 1.0
|
||||
shader_parameter/glint_sharpness = 32.0
|
||||
shader_parameter/emission_color = Color(0, 0, 0, 1)
|
||||
shader_parameter/emission_energy = 0.0
|
||||
|
||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_qv8m2"]
|
||||
|
||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_5u2u8"]
|
||||
render_priority = 0
|
||||
shader = ExtResource("2_0y2rr")
|
||||
shader_parameter/albedo_color = Color(0.22494644, 0.08867701, 0.01631488, 1)
|
||||
shader_parameter/use_texture = false
|
||||
shader_parameter/uv_scale = Vector2(1, 1)
|
||||
shader_parameter/palette_shift_y = 0.0
|
||||
shader_parameter/gradient_start_y = 0.0
|
||||
shader_parameter/gradient_end_y = 10.0
|
||||
shader_parameter/light_steps = 3.0
|
||||
shader_parameter/step_softness = 0.1
|
||||
shader_parameter/shadow_color = Color(0.4, 0.4, 0.6, 1)
|
||||
shader_parameter/shadow_offset = 0.0
|
||||
shader_parameter/cast_shadow_strength = 0.6
|
||||
shader_parameter/use_ghibli_glint = true
|
||||
shader_parameter/glint_color = Color(1, 0.95, 0.85, 1)
|
||||
shader_parameter/glint_intensity = 1.0
|
||||
shader_parameter/glint_sharpness = 32.0
|
||||
shader_parameter/emission_color = Color(0, 0, 0, 1)
|
||||
shader_parameter/emission_energy = 0.0
|
||||
|
||||
[sub_resource type="BoxMesh" id="BoxMesh_m6haf"]
|
||||
size = Vector3(3.705, 0.2, 1.92)
|
||||
|
||||
[node name="rails" type="Node3D" unique_id=1464572050 groups=["weather_node", "wind_node"]]
|
||||
|
||||
[node name="MeshInstance3D" type="MeshInstance3D" parent="." unique_id=1040579890]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.7, 0.214, 0)
|
||||
material_override = SubResource("ShaderMaterial_m6haf")
|
||||
material_overlay = SubResource("ShaderMaterial_duyun")
|
||||
mesh = SubResource("BoxMesh_w0ibq")
|
||||
|
||||
[node name="MeshInstance3D2" type="MeshInstance3D" parent="." unique_id=1870708237]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.7, 0.214, 0)
|
||||
material_override = SubResource("ShaderMaterial_fttrp")
|
||||
material_overlay = SubResource("ShaderMaterial_hb1ej")
|
||||
mesh = SubResource("BoxMesh_w0ibq")
|
||||
|
||||
[node name="MeshInstance3D3" type="MeshInstance3D" parent="." unique_id=170245195]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.05, 0.5)
|
||||
material_override = SubResource("ShaderMaterial_pp4r2")
|
||||
material_overlay = SubResource("ShaderMaterial_pur2n")
|
||||
mesh = SubResource("BoxMesh_ysg1u")
|
||||
|
||||
[node name="MeshInstance3D4" type="MeshInstance3D" parent="." unique_id=1389288735]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.05, -0.5)
|
||||
material_override = SubResource("ShaderMaterial_x2uev")
|
||||
material_overlay = SubResource("ShaderMaterial_qv8m2")
|
||||
mesh = SubResource("BoxMesh_ysg1u")
|
||||
|
||||
[node name="MeshInstance3D5" type="MeshInstance3D" parent="." unique_id=1376217081]
|
||||
visible = false
|
||||
material_override = SubResource("ShaderMaterial_5u2u8")
|
||||
mesh = SubResource("BoxMesh_m6haf")
|
||||
@@ -1,5 +1,23 @@
|
||||
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
|
||||
@onready var day_time_option: OptionButton = $DayTimeOptions
|
||||
|
||||
var default_random_event_duration: float = 10.0
|
||||
|
||||
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)
|
||||
|
||||
@@ -9,15 +27,39 @@ func _on_snow_toggled(toggled_on: bool) -> void:
|
||||
func _on_wind_toggled(toggled_on: bool) -> void:
|
||||
UIEvents.toggle_wind.emit(toggled_on)
|
||||
|
||||
func _on_wind_slider_value_changed(value: float) -> void:
|
||||
UIEvents.wind_change.emit(value)
|
||||
|
||||
func _on_random_weather_pressed() -> void:
|
||||
var duration: float = default_random_event_duration
|
||||
if day_night != null and day_night.environment_config != null:
|
||||
duration = day_night.environment_config.random_event_duration
|
||||
UIEvents.trigger_random_weather.emit(duration)
|
||||
|
||||
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:
|
||||
UIEvents.set_day_time.emit(value)
|
||||
|
||||
func _on_day_time_changed(value: float, time_string: String) -> void:
|
||||
day_time_slider.set_value_no_signal(value)
|
||||
var label_text: String = "Time %s" % time_string
|
||||
if (
|
||||
day_night != null
|
||||
and day_night.environment_config != null
|
||||
and day_night.environment_config.show_day_time_debug
|
||||
):
|
||||
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)
|
||||
|
||||
@@ -32,3 +74,36 @@ func _on_pause_toggled(toggled_on: bool) -> void:
|
||||
|
||||
func _on_shadows_toggled(toggled_on: bool) -> void:
|
||||
UIEvents.toggle_shadows.emit(toggled_on)
|
||||
|
||||
func _sync_day_time_ui() -> void:
|
||||
if day_night == null:
|
||||
return
|
||||
|
||||
var day_night_controller: DayNightController = (
|
||||
day_night.get_node_or_null("DayNightController") as DayNightController
|
||||
)
|
||||
if day_night_controller == null:
|
||||
call_deferred("_sync_day_time_ui")
|
||||
return
|
||||
|
||||
_on_day_time_changed(
|
||||
day_night_controller.current_time,
|
||||
day_night_controller.get_time_string()
|
||||
)
|
||||
_on_day_time_option_changed(
|
||||
day_night_controller.get_time_option_index(day_night_controller.current_time)
|
||||
)
|
||||
|
||||
func _on_day_time_option_changed(index: int) -> void:
|
||||
if day_time_option == null:
|
||||
return
|
||||
day_time_option.select(index)
|
||||
|
||||
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)
|
||||
|
||||
func _on_update_rails_pressed() -> void:
|
||||
UIEvents.update_rail_chunks.emit()
|
||||
|
||||
6
docs/museums/daynight/museum_daynight.gd
Normal file
6
docs/museums/daynight/museum_daynight.gd
Normal file
@@ -0,0 +1,6 @@
|
||||
extends Node3D
|
||||
|
||||
func _input(event):
|
||||
if event is InputEventKey and event.pressed:
|
||||
if event.keycode == KEY_ESCAPE:
|
||||
get_tree().quit()
|
||||
1
docs/museums/daynight/museum_daynight.gd.uid
Normal file
1
docs/museums/daynight/museum_daynight.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://bs232puek1gwc
|
||||
File diff suppressed because one or more lines are too long
@@ -1,230 +0,0 @@
|
||||
[gd_scene format=4 uid="uid://givg3dyrxsk5"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://d3loscamahf5y" path="res://Assets/Meshes/Chunk/Bioma_C/Chunk_C_E_1.fbx" id="1_jpp2r"]
|
||||
[ext_resource type="Script" uid="uid://byluxssk112ca" path="res://Scripts/info_chunk.gd" id="2_02kkq"]
|
||||
[ext_resource type="Shader" uid="uid://c0dy1aqj1b4q3" path="res://Shaders/trunk_shader.gdshader" id="3_wr3vc"]
|
||||
[ext_resource type="PackedScene" uid="uid://8jtrp8ckqf1a" path="res://Scenes/Chunk_Scene/House/House_muraglione.tscn" id="4_lunjj"]
|
||||
[ext_resource type="PackedScene" uid="uid://5sod22d0vnip" path="res://Scenes/Chunk_Scene/House/House_XL_4.tscn" id="5_tf2ul"]
|
||||
[ext_resource type="PackedScene" uid="uid://birttctl11th8" path="res://Scenes/Chunk_Scene/Chunk/Campagna/chunk_c_l_1.tscn" id="6_4h5ax"]
|
||||
[ext_resource type="Shader" uid="uid://do0tct77dfhef" path="res://Shaders/snow.gdshader" id="7_wr3vc"]
|
||||
[ext_resource type="Material" uid="uid://couj6glsrm6h3" path="res://Materials/Sentiero.tres" id="7_y2p7p"]
|
||||
[ext_resource type="PackedScene" uid="uid://dyolu5m0lgqm2" path="res://Scenes/Test/ToriGate.tscn" id="9_ji5rd"]
|
||||
[ext_resource type="PackedScene" uid="uid://jj15telqu3rp" path="res://Scenes/Test/Grass_Test.tscn" id="9_s470o"]
|
||||
[ext_resource type="PackedScene" uid="uid://d12t04rs47jq3" path="res://Scenes/Test/Tree_V1.tscn" id="10_ji5rd"]
|
||||
[ext_resource type="PackedScene" uid="uid://4iye3qapad4y" path="res://Scenes/Test/Colonnina_Blockout.tscn" id="11_4n1py"]
|
||||
[ext_resource type="PackedScene" uid="uid://bfvtlpkcnbgke" path="res://Scenes/Chunk_Scene/BordiSentiero/Bordi_sentiero_Rettilineo.tscn" id="12_rrcoc"]
|
||||
|
||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_sqcol"]
|
||||
render_priority = 0
|
||||
shader = ExtResource("3_wr3vc")
|
||||
shader_parameter/albedo_color = Color(0.16470589, 0.50980395, 0.21960784, 1)
|
||||
shader_parameter/use_texture = true
|
||||
shader_parameter/uv_scale = Vector2(1, 1)
|
||||
shader_parameter/palette_shift_y = 0.0
|
||||
shader_parameter/gradient_start_y = 0.0
|
||||
shader_parameter/gradient_end_y = 10.0
|
||||
shader_parameter/light_steps = 3.0
|
||||
shader_parameter/step_softness = 0.1
|
||||
shader_parameter/shadow_color = Color(0.4, 0.4, 0.6, 1)
|
||||
shader_parameter/shadow_offset = 0.0
|
||||
shader_parameter/cast_shadow_strength = 0.6
|
||||
shader_parameter/use_ghibli_glint = true
|
||||
shader_parameter/glint_color = Color(1, 0.95, 0.85, 1)
|
||||
shader_parameter/glint_intensity = 1.0
|
||||
shader_parameter/glint_sharpness = 32.0
|
||||
shader_parameter/emission_color = Color(0, 0, 0, 1)
|
||||
shader_parameter/emission_energy = 0.0
|
||||
|
||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_fim7w"]
|
||||
render_priority = 0
|
||||
shader = ExtResource("7_wr3vc")
|
||||
shader_parameter/snow_color = Color(0.95, 0.98, 1, 1)
|
||||
|
||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_jqd13"]
|
||||
render_priority = 0
|
||||
shader = ExtResource("7_wr3vc")
|
||||
shader_parameter/snow_color = Color(0.95, 0.98, 1, 1)
|
||||
|
||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_cvr4e"]
|
||||
render_priority = 0
|
||||
shader = ExtResource("7_wr3vc")
|
||||
shader_parameter/snow_color = Color(0.95, 0.98, 1, 1)
|
||||
|
||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_0uwhb"]
|
||||
resource_name = "Material"
|
||||
vertex_color_use_as_albedo = true
|
||||
albedo_color = Color(0.9063318, 0.9063318, 0.9063318, 1)
|
||||
emission_enabled = true
|
||||
|
||||
[sub_resource type="ArrayMesh" id="ArrayMesh_v3qhc"]
|
||||
_surfaces = [{
|
||||
"aabb": AABB(-0.1, -0.015, -0.00043503524, 0.085, 0.03, 0.0008700705),
|
||||
"format": 34359742465,
|
||||
"index_count": 36,
|
||||
"index_data": PackedByteArray("AAABAAIAAwABAAAAAgAEAAAAAQADAAUABQACAAEABgAEAAIAAgAFAAYABwAAAAQAAAAHAAMABAAGAAcABQADAAcABwAGAAUA"),
|
||||
"name": "Material",
|
||||
"primitive": 3,
|
||||
"uv_scale": Vector4(0, 0, 0, 0),
|
||||
"vertex_count": 8,
|
||||
"vertex_data": PackedByteArray("j8J1vI3CdbxxFeS5j8J1vI/CdTxxFeS5zczMvY3CdTxxFeS5j8J1vI/CdTxxFeQ5zczMvY/CdbxxFeS5zczMvY3CdTxxFeQ5zczMvY/CdbxxFeQ5j8J1vI3CdbxxFeQ5")
|
||||
}]
|
||||
blend_shape_mode = 0
|
||||
|
||||
[sub_resource type="ArrayMesh" id="ArrayMesh_db63l"]
|
||||
resource_name = "Cube_041"
|
||||
_surfaces = [{
|
||||
"aabb": AABB(-0.1, -0.015, -0.00043503524, 0.085, 0.03, 0.0008700705),
|
||||
"attribute_data": PackedByteArray("EI5NP1hyCb/sx0k+7m8Lv+zHST7jt8U/EI5NPxi5xD/sx0k+7m8Lvzo2PD4K+Ri/OjY8PoV8zD/sx0k+47fFPxCOTT9Ycgm/cvJQP/r6FL86Njw+CvkYv+zHST7ubwu/mhRSP298zD+aFFI/3vgYv5atNz4K+Ri/lq03PoV8zD/sx0k+47fFPzo2PD6FfMw/cvJQP2l9yj8Qjk0/GLnEPxCOTT8YucQ/cvJQP2l9yj9y8lA/+voUvxCOTT9Ycgm/"),
|
||||
"format": 34359742487,
|
||||
"index_count": 36,
|
||||
"index_data": PackedByteArray("AAABAAIAAgADAAAABAAFAAYABgAHAAQACAAJAAoACgALAAgADAANAA4ADgAPAAwAEAARABIAEgATABAAFAAVABYAFgAXABQA"),
|
||||
"material": SubResource("StandardMaterial3D_0uwhb"),
|
||||
"name": "Material",
|
||||
"primitive": 3,
|
||||
"uv_scale": Vector4(0, 0, 0, 0),
|
||||
"vertex_count": 24,
|
||||
"vertex_data": PackedByteArray("j8J1vI3CdbxxFeS5j8J1vI/CdTxxFeS5zczMvY3CdTxxFeS5zczMvY/CdbxxFeS5j8J1vI/CdTxxFeS5j8J1vI/CdTxxFeQ5zczMvY3CdTxxFeQ5zczMvY3CdTxxFeS5j8J1vI3CdbxxFeS5j8J1vI3CdbxxFeQ5j8J1vI/CdTxxFeQ5j8J1vI/CdTxxFeS5zczMvY3CdTxxFeQ5j8J1vI/CdTxxFeQ5j8J1vI3CdbxxFeQ5zczMvY/CdbxxFeQ5zczMvY3CdTxxFeS5zczMvY3CdTxxFeQ5zczMvY/CdbxxFeQ5zczMvY/CdbxxFeS5zczMvY/CdbxxFeS5zczMvY/CdbxxFeQ5j8J1vI3CdbxxFeQ5j8J1vI3CdbxxFeS5/////8KAnn//////VYFUf/////86f5x//////6d+U3//f/////+9LP9//////+ks/3///wAAm1L/f///AABuUv///3//f15/////f/9/XH////9//3+4f////3//f7l//3//f/9/AAD/f/9//38AAP9//3//fwAA/3//f/9/AAAAAP9//391fwAA/3//f3R/AAD/f/9/rH8AAP9//3+tf/9/AABx1f8//38AAM7V/z//fwAAXSn/P/9/AAD+KP8/")
|
||||
}]
|
||||
blend_shape_mode = 0
|
||||
shadow_mesh = SubResource("ArrayMesh_v3qhc")
|
||||
|
||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_1sygh"]
|
||||
render_priority = 0
|
||||
shader = ExtResource("7_wr3vc")
|
||||
shader_parameter/snow_color = Color(0.95, 0.98, 1, 1)
|
||||
|
||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_8kcs0"]
|
||||
render_priority = 0
|
||||
shader = ExtResource("7_wr3vc")
|
||||
shader_parameter/snow_color = Color(0.95, 0.98, 1, 1)
|
||||
|
||||
[sub_resource type="ArrayMesh" id="ArrayMesh_7ona5"]
|
||||
_surfaces = [{
|
||||
"aabb": AABB(-0.015000002, -0.1, -0.00043503524, 0.030000005, 0.115, 0.0008700705),
|
||||
"format": 34359742465,
|
||||
"index_count": 36,
|
||||
"index_data": PackedByteArray("AAABAAIAAwABAAAAAgAEAAAAAQADAAUABQACAAEABgAEAAIAAgAFAAYABwAAAAQAAAAHAAMABAAGAAcABQADAAcABwAGAAUA"),
|
||||
"name": "Material",
|
||||
"primitive": 3,
|
||||
"uv_scale": Vector4(0, 0, 0, 0),
|
||||
"vertex_count": 8,
|
||||
"vertex_data": PackedByteArray("isJ1PI/CdTxxFeS5ksJ1vI/CdTxxFeS5isJ1vM3MzL1xFeS5ksJ1vI/CdTxxFeQ5ksJ1PM3MzL1xFeS5isJ1vM3MzL1xFeQ5ksJ1PM3MzL1xFeQ5isJ1PI/CdTxxFeQ5")
|
||||
}]
|
||||
blend_shape_mode = 0
|
||||
|
||||
[sub_resource type="ArrayMesh" id="ArrayMesh_vall4"]
|
||||
resource_name = "Cube_042"
|
||||
_surfaces = [{
|
||||
"aabb": AABB(-0.015000002, -0.1, -0.00043503524, 0.030000005, 0.115, 0.0008700705),
|
||||
"attribute_data": PackedByteArray("EI5NP1hyCb/sx0k+7m8Lv+zHST7jt8U/EI5NPxi5xD/sx0k+7m8Lvzo2PD4K+Ri/OjY8PoV8zD/sx0k+47fFPxCOTT9Ycgm/cvJQP/r6FL86Njw+CvkYv+zHST7ubwu/mhRSP298zD+aFFI/3vgYv5atNz4K+Ri/lq03PoV8zD/sx0k+47fFPzo2PD6FfMw/cvJQP2l9yj8Qjk0/GLnEPxCOTT8YucQ/cvJQP2l9yj9y8lA/+voUvxCOTT9Ycgm/"),
|
||||
"format": 34359742487,
|
||||
"index_count": 36,
|
||||
"index_data": PackedByteArray("AAABAAIAAgADAAAABAAFAAYABgAHAAQACAAJAAoACgALAAgADAANAA4ADgAPAAwAEAARABIAEgATABAAFAAVABYAFgAXABQA"),
|
||||
"material": SubResource("StandardMaterial3D_0uwhb"),
|
||||
"name": "Material",
|
||||
"primitive": 3,
|
||||
"uv_scale": Vector4(0, 0, 0, 0),
|
||||
"vertex_count": 24,
|
||||
"vertex_data": PackedByteArray("isJ1PI/CdTxxFeS5ksJ1vI/CdTxxFeS5isJ1vM3MzL1xFeS5ksJ1PM3MzL1xFeS5ksJ1vI/CdTxxFeS5ksJ1vI/CdTxxFeQ5isJ1vM3MzL1xFeQ5isJ1vM3MzL1xFeS5isJ1PI/CdTxxFeS5isJ1PI/CdTxxFeQ5ksJ1vI/CdTxxFeQ5ksJ1vI/CdTxxFeS5isJ1vM3MzL1xFeQ5ksJ1vI/CdTxxFeQ5isJ1PI/CdTxxFeQ5ksJ1PM3MzL1xFeQ5isJ1vM3MzL1xFeS5isJ1vM3MzL1xFeQ5ksJ1PM3MzL1xFeQ5ksJ1PM3MzL1xFeS5ksJ1PM3MzL1xFeS5ksJ1PM3MzL1xFeQ5isJ1PI/CdTxxFeQ5isJ1PI/CdTxxFeS5/////8b+Yz//////Mv4ZP//////D/p1A/////y7+50AAAP9/LmEAAAAA/39nYQAAAAD/f66d/n8AAP9/dZ3+f/9///+8/v8//3///7n+/z//f///cP//P/9///9z//8//3//fwAA/z//f/9/AAD/P/9//38AAP8//3//fwAA/z//fwAA6/7/P/9/AADp/v8//38AAFn//z//fwAAW///P////3//fy0R////f/9/DhH///9//39Yb////3//f3dv")
|
||||
}]
|
||||
blend_shape_mode = 0
|
||||
shadow_mesh = SubResource("ArrayMesh_7ona5")
|
||||
|
||||
[sub_resource type="BoxShape3D" id="BoxShape3D_lunjj"]
|
||||
size = Vector3(20, 10, 20)
|
||||
|
||||
[node name="Chunk_C_E_1" unique_id=1874739368 instance=ExtResource("1_jpp2r")]
|
||||
script = ExtResource("2_02kkq")
|
||||
nord = true
|
||||
est = true
|
||||
ovest = true
|
||||
|
||||
[node name="Chunk_026" parent="." index="0" unique_id=1014258190]
|
||||
material_override = SubResource("ShaderMaterial_sqcol")
|
||||
|
||||
[node name="House_Muraglione" parent="." index="1" unique_id=1060427946 instance=ExtResource("4_lunjj")]
|
||||
transform = Transform3D(-4.371139e-08, 0, 1, 0, 1, 0, -1, 0, -4.371139e-08, 0, 0, -0.891696)
|
||||
visible = false
|
||||
|
||||
[node name="House_XL_4" parent="." index="2" unique_id=1350238174 instance=ExtResource("5_tf2ul")]
|
||||
transform = Transform3D(-4.371139e-08, 0, 1, 0, 1, 0, -1, 0, -4.371139e-08, 0, 0, 0)
|
||||
visible = false
|
||||
|
||||
[node name="Chunk_C_L_1" parent="." index="3" unique_id=47126446 instance=ExtResource("6_4h5ax")]
|
||||
nord = true
|
||||
est = true
|
||||
sud = false
|
||||
|
||||
[node name="Chunk_005" parent="Chunk_C_L_1" index="0" unique_id=1711954451]
|
||||
visible = false
|
||||
material_overlay = SubResource("ShaderMaterial_fim7w")
|
||||
|
||||
[node name="Chunk_036" parent="Chunk_C_L_1" index="1" unique_id=2006258110]
|
||||
material_overlay = SubResource("ShaderMaterial_jqd13")
|
||||
|
||||
[node name="Chunk_039" type="MeshInstance3D" parent="Chunk_C_L_1" index="2" unique_id=311921996]
|
||||
transform = Transform3D(100, 0, 0, 0, -1.1920929e-05, 99.99999, 0, -99.99999, -1.1920929e-05, 11.507141, 0, 0)
|
||||
material_override = ExtResource("7_y2p7p")
|
||||
material_overlay = SubResource("ShaderMaterial_cvr4e")
|
||||
mesh = SubResource("ArrayMesh_db63l")
|
||||
skeleton = NodePath("")
|
||||
|
||||
[node name="Chunk_037" parent="Chunk_C_L_1" index="3" unique_id=553462979]
|
||||
material_overlay = SubResource("ShaderMaterial_1sygh")
|
||||
|
||||
[node name="Chunk_038" type="MeshInstance3D" parent="Chunk_C_L_1" index="4" unique_id=300529289]
|
||||
transform = Transform3D(100, 0, 0, 0, -1.1920929e-05, 99.99999, 0, -99.99999, -1.1920929e-05, 0, 0, -8.492352)
|
||||
material_override = ExtResource("7_y2p7p")
|
||||
material_overlay = SubResource("ShaderMaterial_8kcs0")
|
||||
mesh = SubResource("ArrayMesh_vall4")
|
||||
skeleton = NodePath("")
|
||||
|
||||
[node name="Cube_030" parent="Chunk_C_L_1" index="5" unique_id=209419507]
|
||||
visible = false
|
||||
|
||||
[node name="Cube_031" parent="Chunk_C_L_1" index="6" unique_id=498063843]
|
||||
visible = false
|
||||
|
||||
[node name="Cube_034" parent="Chunk_C_L_1" index="7" unique_id=2029406114]
|
||||
visible = false
|
||||
|
||||
[node name="StaticBody3D" type="StaticBody3D" parent="." index="4" unique_id=1294838844]
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="StaticBody3D" index="0" unique_id=415467932]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 4, 0)
|
||||
shape = SubResource("BoxShape3D_lunjj")
|
||||
|
||||
[node name="Tori1" parent="." index="5" unique_id=1219093134 instance=ExtResource("9_ji5rd")]
|
||||
transform = Transform3D(0.635, 0, 0, 0, 0.635, 0, 0, 0, 0.635, 0, 0, 6.3459473)
|
||||
|
||||
[node name="Grass" parent="." index="6" unique_id=838519336 instance=ExtResource("9_s470o")]
|
||||
transform = Transform3D(0.625, 0, 0, 0, 0.625, 0, 0, 0, 0.625, -5.715452, 0.2, 5.6062393)
|
||||
|
||||
[node name="Grass2" parent="." index="7" unique_id=897276709 instance=ExtResource("9_s470o")]
|
||||
transform = Transform3D(0.625, 0, 0, 0, 0.625, 0, 0, 0, 0.625, 5.533434, 0.2, 5.6062393)
|
||||
|
||||
[node name="Grass3" parent="." index="8" unique_id=1329989165 instance=ExtResource("9_s470o")]
|
||||
transform = Transform3D(0.625, 0, 0, 0, 0.625, 0, 0, 0, 0.625, 5.533434, 0.2, -5.8610706)
|
||||
|
||||
[node name="Grass4" parent="." index="9" unique_id=1694283661 instance=ExtResource("9_s470o")]
|
||||
transform = Transform3D(0.625, 0, 0, 0, 0.625, 0, 0, 0, 0.625, -5.7882576, 0.2, -5.8610706)
|
||||
|
||||
[node name="TreeTest5" parent="." index="10" unique_id=833565521 instance=ExtResource("10_ji5rd")]
|
||||
transform = Transform3D(1.7, 0, 0, 0, 1.7, 0, 0, 0, 1.7, -7.5582066, -0.050994873, -9.087841)
|
||||
|
||||
[node name="TreeTest6" parent="." index="11" unique_id=722001 instance=ExtResource("10_ji5rd")]
|
||||
transform = Transform3D(2.0272298e-08, 0, -1.7, 0, 1.7, 0, 1.7, 0, 2.0272298e-08, 7.8656454, -0.050994873, -9.087841)
|
||||
|
||||
[node name="ArtTest3" parent="." index="12" unique_id=143340255 instance=ExtResource("11_4n1py")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 3, 0, 9.069)
|
||||
|
||||
[node name="ArtTest4" parent="." index="13" unique_id=193459863 instance=ExtResource("11_4n1py")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -3, 0, 9.069)
|
||||
|
||||
[node name="Test_BordiSentiero" parent="." index="14" unique_id=1395614268 instance=ExtResource("12_rrcoc")]
|
||||
transform = Transform3D(-4.371139e-08, 0, 1, 0, 1, 0, -1, 0, -4.371139e-08, -1.15, 0.2, 5.699)
|
||||
|
||||
[node name="Test_BordiSentiero2" parent="." index="15" unique_id=514399948 instance=ExtResource("12_rrcoc")]
|
||||
transform = Transform3D(-4.371139e-08, 0, 1, 0, 1, 0, -1, 0, -4.371139e-08, 1.15, 0.2, 5.699)
|
||||
|
||||
[editable path="Chunk_C_L_1"]
|
||||
Binary file not shown.
@@ -1,12 +0,0 @@
|
||||
[gd_scene format=3 uid="uid://cahsl77384kf1"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://dllpmxm6ttwg" path="res://docs/museums/daynight/scenes/chunk_c_f_1/house_Muraglione.fbx" id="1_m4ocs"]
|
||||
[ext_resource type="Material" uid="uid://biaudrjlfoflm" path="res://docs/museums/daynight/scenes/chunk_c_f_1/house.tres" id="2_7l0dg"]
|
||||
|
||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_bdf8l"]
|
||||
|
||||
[node name="House_Muraglione" unique_id=1060427946 groups=["weather_node"] instance=ExtResource("1_m4ocs")]
|
||||
|
||||
[node name="House_Muraglione" parent="." index="0" unique_id=517623360]
|
||||
material_overlay = SubResource("ShaderMaterial_bdf8l")
|
||||
surface_material_override/0 = ExtResource("2_7l0dg")
|
||||
Binary file not shown.
@@ -1,46 +0,0 @@
|
||||
[gd_scene format=3 uid="uid://dte4p23pp14pv"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://cl8c5n0nw30u" path="res://docs/museums/daynight/scenes/chunk_c_f_1/house_xl_4.fbx" id="1_r3art"]
|
||||
[ext_resource type="Material" uid="uid://biaudrjlfoflm" path="res://docs/museums/daynight/scenes/chunk_c_f_1/house.tres" id="2_mswf7"]
|
||||
[ext_resource type="Shader" uid="uid://dh3j2jp6defuk" path="res://core/daynight/weather_overlay.gdshader" id="2_wanxj"]
|
||||
[ext_resource type="Material" uid="uid://dbmyfi5t0yfy" path="res://docs/museums/daynight/scenes/chunk_c_f_1/house_emissiv.tres" id="3_n3fsy"]
|
||||
|
||||
[sub_resource type="Gradient" id="Gradient_n4qy2"]
|
||||
offsets = PackedFloat32Array(0.9980237, 1)
|
||||
colors = PackedColorArray(0, 0, 0, 0.5882353, 0, 0, 0, 0)
|
||||
|
||||
[sub_resource type="GradientTexture2D" id="GradientTexture2D_wanxj"]
|
||||
gradient = SubResource("Gradient_n4qy2")
|
||||
fill = 2
|
||||
fill_from = Vector2(0.5, 0.5)
|
||||
fill_to = Vector2(0.9017094, 0.12820514)
|
||||
|
||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_fprka"]
|
||||
render_priority = 0
|
||||
shader = ExtResource("2_wanxj")
|
||||
shader_parameter/snow_noise_scale = 0.15
|
||||
shader_parameter/snow_edge_softness = 0.2
|
||||
shader_parameter/snow_roughness_variation = 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
|
||||
|
||||
[node name="House_XL_4" unique_id=1350238174 groups=["weather_node"] instance=ExtResource("1_r3art")]
|
||||
|
||||
[node name="Shadow" type="Decal" parent="." index="0" unique_id=705347391]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -0.15501308)
|
||||
size = Vector3(9, 0.5, 9)
|
||||
texture_albedo = SubResource("GradientTexture2D_wanxj")
|
||||
|
||||
[node name="House_XL_4" parent="." index="1" unique_id=1851861956]
|
||||
material_overlay = SubResource("ShaderMaterial_fprka")
|
||||
surface_material_override/0 = ExtResource("2_mswf7")
|
||||
surface_material_override/1 = ExtResource("3_n3fsy")
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 133 KiB |
@@ -1,23 +0,0 @@
|
||||
[gd_resource type="ShaderMaterial" format=3 uid="uid://2p8yqqg44ci3"]
|
||||
|
||||
[ext_resource type="Shader" uid="uid://cs0xl7pc6e26h" path="res://core/daynight/tree_leaves.gdshader" id="1_etun4"]
|
||||
[ext_resource type="Texture2D" uid="uid://c0lkmyonx88hc" path="res://docs/museums/daynight/scenes/grain_test/grass_thin.png" id="2_grain"]
|
||||
|
||||
[resource]
|
||||
render_priority = 0
|
||||
shader = ExtResource("1_etun4")
|
||||
shader_parameter/billboard_enabled = false
|
||||
shader_parameter/wind_enabled = true
|
||||
shader_parameter/base_color = Color(0.85, 0.75, 0.25, 1)
|
||||
shader_parameter/alpha_texture = ExtResource("2_grain")
|
||||
shader_parameter/leaves_scale = 1.0
|
||||
shader_parameter/rotation_degrees = 0.0
|
||||
shader_parameter/texture_offset = Vector2(0, 0)
|
||||
shader_parameter/opacity = 1.0
|
||||
shader_parameter/height_min = 0.0
|
||||
shader_parameter/height_max = 5.0
|
||||
shader_parameter/shadow_intensity = 0.5
|
||||
shader_parameter/highlight_intensity = 0.3
|
||||
shader_parameter/light_steps = 4.0
|
||||
shader_parameter/random_mix = 0.3
|
||||
shader_parameter/cast_shadow_strength = 0.6
|
||||
File diff suppressed because one or more lines are too long
Binary file not shown.
|
Before Width: | Height: | Size: 12 KiB |
@@ -1,23 +0,0 @@
|
||||
[gd_resource type="ShaderMaterial" format=3 uid="uid://cudoptcrtgl7u"]
|
||||
|
||||
[ext_resource type="Shader" uid="uid://cs0xl7pc6e26h" path="res://core/daynight/tree_leaves.gdshader" id="1_528a5"]
|
||||
[ext_resource type="Texture2D" uid="uid://ckm50mv8ejlki" path="res://docs/museums/daynight/scenes/grass_test/grass_round.png" id="2_4d6mx"]
|
||||
|
||||
[resource]
|
||||
render_priority = 0
|
||||
shader = ExtResource("1_528a5")
|
||||
shader_parameter/billboard_enabled = true
|
||||
shader_parameter/wind_enabled = true
|
||||
shader_parameter/base_color = Color(0.3882353, 0.52156866, 0.20784314, 1)
|
||||
shader_parameter/alpha_texture = ExtResource("2_4d6mx")
|
||||
shader_parameter/leaves_scale = 0.5
|
||||
shader_parameter/rotation_degrees = 180.0
|
||||
shader_parameter/texture_offset = Vector2(0, 0)
|
||||
shader_parameter/opacity = 1.0
|
||||
shader_parameter/height_min = 0.0
|
||||
shader_parameter/height_max = 5.0
|
||||
shader_parameter/shadow_intensity = 0.5
|
||||
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
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
57
docs/zoos/zoo_countryside.tscn
Normal file
57
docs/zoos/zoo_countryside.tscn
Normal file
@@ -0,0 +1,57 @@
|
||||
[gd_scene format=3 uid="uid://b7rhqxsyv87r1"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://cjv1e8pc6gde1" path="res://tgcc/chunk/countryside/scene/chunk_country_corner_01.tscn" id="1_eexnc"]
|
||||
[ext_resource type="PackedScene" uid="uid://dqoai3665vb0a" path="res://tgcc/chunk/countryside/scene/chunk_country_corner_02.tscn" id="2_jh6kr"]
|
||||
[ext_resource type="PackedScene" uid="uid://crlk31ecl480n" path="res://tgcc/chunk/countryside/scene/chunk_country_corner_03.tscn" id="3_pftht"]
|
||||
[ext_resource type="PackedScene" uid="uid://brpp7fe5noq8v" path="res://tgcc/chunk/countryside/scene/chunk_country_cross_3_01.tscn" id="4_jexg3"]
|
||||
[ext_resource type="PackedScene" uid="uid://qmt8bkiksgj3" path="res://tgcc/chunk/countryside/scene/chunk_country_cross_3_02.tscn" id="5_hieqo"]
|
||||
[ext_resource type="PackedScene" uid="uid://d1tfkhuktwthn" path="res://tgcc/chunk/countryside/scene/chunk_country_cross_3_03.tscn" id="6_re3ik"]
|
||||
[ext_resource type="PackedScene" uid="uid://c73yk6858dmwn" path="res://tgcc/chunk/countryside/scene/chunk_country_cross_4_01.tscn" id="7_v47u4"]
|
||||
[ext_resource type="PackedScene" uid="uid://b8blm6bwintf7" path="res://tgcc/chunk/countryside/scene/chunk_country_empty_01.tscn" id="8_bag0j"]
|
||||
[ext_resource type="PackedScene" uid="uid://b002wu5ltuqi4" path="res://tgcc/chunk/countryside/scene/chunk_country_end_01.tscn" id="9_1vyrv"]
|
||||
[ext_resource type="PackedScene" uid="uid://dtfmvcbninrcu" path="res://tgcc/chunk/countryside/scene/chunk_country_end_02.tscn" id="10_sdnjr"]
|
||||
[ext_resource type="PackedScene" uid="uid://h6xj43vo84uf" path="res://tgcc/chunk/countryside/scene/chunk_country_straight_01.tscn" id="11_arwwt"]
|
||||
[ext_resource type="PackedScene" uid="uid://cu2chsjh8wuvp" path="res://tgcc/chunk/countryside/scene/chunk_country_straight_02.tscn" id="12_l62i2"]
|
||||
[ext_resource type="PackedScene" uid="uid://pxmcy0lhne5d" path="res://tgcc/chunk/countryside/scene/chunk_country_straight_03.tscn" id="13_f3g5s"]
|
||||
|
||||
[node name="ZooCountryside" type="Node3D" unique_id=1742985179]
|
||||
|
||||
[node name="country" type="Node3D" parent="." unique_id=672430814]
|
||||
|
||||
[node name="chunk_country_corner_01" parent="country" unique_id=200417581 instance=ExtResource("1_eexnc")]
|
||||
|
||||
[node name="chunk_country_corner_02" parent="country" unique_id=85657005 instance=ExtResource("2_jh6kr")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 22.5)
|
||||
|
||||
[node name="chunk_country_corner_03" parent="country" unique_id=1046737870 instance=ExtResource("3_pftht")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 45)
|
||||
|
||||
[node name="chunk_country_cross3_01" parent="country" unique_id=319840865 instance=ExtResource("4_jexg3")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -22.5, 0, 0)
|
||||
|
||||
[node name="chunk_country_cross3_02" parent="country" unique_id=1492245999 instance=ExtResource("5_hieqo")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -22.5, 0, 22.5)
|
||||
|
||||
[node name="chunk_country_cross3_03" parent="country" unique_id=643218732 instance=ExtResource("6_re3ik")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -22.5, 0, 45)
|
||||
|
||||
[node name="chunk_country_cross4_01" parent="country" unique_id=680431911 instance=ExtResource("7_v47u4")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -45, 0, 0)
|
||||
|
||||
[node name="chunk_country_empty_01" parent="country" unique_id=385761952 instance=ExtResource("8_bag0j")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -67.5, 0, 0)
|
||||
|
||||
[node name="chunk_country_end_01" parent="country" unique_id=913263516 instance=ExtResource("9_1vyrv")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -90, 0, 0)
|
||||
|
||||
[node name="chunk_country_end_02" parent="country" unique_id=1712924087 instance=ExtResource("10_sdnjr")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -90, 0, 22.5)
|
||||
|
||||
[node name="chunk_country_straight_01" parent="country" unique_id=926368352 instance=ExtResource("11_arwwt")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -113, 0, 0)
|
||||
|
||||
[node name="chunk_country_straight_02" parent="country" unique_id=1847746456 instance=ExtResource("12_l62i2")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -113, 0, 22.5)
|
||||
|
||||
[node name="chunk_country_straight_03" parent="country" unique_id=626808879 instance=ExtResource("13_f3g5s")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -113, 0, 45)
|
||||
36
docs/zoos/zoo_railway.tscn
Normal file
36
docs/zoos/zoo_railway.tscn
Normal file
@@ -0,0 +1,36 @@
|
||||
[gd_scene format=3 uid="uid://bvjiqu363c15p"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://cl2ast2tk7ifw" path="res://tgcc/chunk/railway/scene/chunk_railway_curve.tscn" id="14_ttcft"]
|
||||
[ext_resource type="PackedScene" uid="uid://cewdxvcpqb53f" path="res://tgcc/chunk/railway/scene/chunk_railway_station_doubleside.tscn" id="15_oi62p"]
|
||||
[ext_resource type="PackedScene" uid="uid://bup6gwlxos0w2" path="res://tgcc/chunk/railway/scene/chunk_railway_station_hero.tscn" id="16_birpm"]
|
||||
[ext_resource type="PackedScene" uid="uid://d3pcshw2bioic" path="res://tgcc/chunk/railway/scene/chunk_railway_station_oneside.tscn" id="17_esgqd"]
|
||||
[ext_resource type="PackedScene" uid="uid://bqxpqhla2kogq" path="res://tgcc/chunk/railway/scene/chunk_railway_straight.tscn" id="18_5ivsh"]
|
||||
[ext_resource type="PackedScene" uid="uid://c3ub6rj0tlt6q" path="res://tgcc/chunk/railway/scene/chunk_railway_straight_2.tscn" id="19_yd4l5"]
|
||||
[ext_resource type="PackedScene" uid="uid://f53hfrjaxkwa" path="res://tgcc/chunk/railway/scene/chunk_railway_straight_bridge.tscn" id="20_h1ucl"]
|
||||
|
||||
[node name="ZooCountryside" type="Node3D" unique_id=1742985179]
|
||||
|
||||
[node name="country" type="Node3D" parent="." unique_id=672430814]
|
||||
|
||||
[node name="railway" type="Node3D" parent="." unique_id=1626602327]
|
||||
|
||||
[node name="chunk_railway_curve" parent="railway" unique_id=238887300 instance=ExtResource("14_ttcft")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -14, 0, -20)
|
||||
|
||||
[node name="chunk_railway_station_doubleside" parent="railway" unique_id=1591869611 instance=ExtResource("15_oi62p")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -16, 0, 46)
|
||||
|
||||
[node name="chunk_railway_station_hero" parent="railway" unique_id=1050909298 instance=ExtResource("16_birpm")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 29, 0, 25)
|
||||
|
||||
[node name="chunk_railway_station_oneside" parent="railway" unique_id=310632835 instance=ExtResource("17_esgqd")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -16, 0, 24)
|
||||
|
||||
[node name="chunk_railway_straight" parent="railway" unique_id=1509029322 instance=ExtResource("18_5ivsh")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 29, 0, 0)
|
||||
|
||||
[node name="chunk_railway_straight_2" parent="railway" unique_id=476549215 instance=ExtResource("19_yd4l5")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 29, 0, -23)
|
||||
|
||||
[node name="chunk_railway_straight_bridge" parent="railway" unique_id=1049036234 instance=ExtResource("20_h1ucl")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 29, 0, -46)
|
||||
@@ -2,16 +2,16 @@
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://d2sydag8o7r8f"
|
||||
path="res://.godot/imported/snow.jpg-51a2902860b21a02a582c65a2470860d.ctex"
|
||||
uid="uid://bfar1kk3pgq8f"
|
||||
path="res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://snow.jpg"
|
||||
dest_files=["res://.godot/imported/snow.jpg-51a2902860b21a02a582c65a2470860d.ctex"]
|
||||
source_file="res://icon.png"
|
||||
dest_files=["res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
@@ -11,9 +11,10 @@ config_version=5
|
||||
[application]
|
||||
|
||||
config/name="tgcc"
|
||||
run/main_scene="uid://bjkhawylawqof"
|
||||
run/main_scene="uid://38qpxwbpvd28"
|
||||
config/features=PackedStringArray("4.6", "Forward Plus")
|
||||
config/icon="res://icon.svg"
|
||||
run/max_fps=60
|
||||
config/icon="uid://bfar1kk3pgq8f"
|
||||
|
||||
[autoload]
|
||||
|
||||
@@ -26,6 +27,7 @@ AudioManager="*uid://dcttbbavtwtsg"
|
||||
|
||||
window/size/viewport_width=1920
|
||||
window/size/viewport_height=1080
|
||||
window/size/mode=3
|
||||
window/stretch/mode="canvas_items"
|
||||
window/stretch/aspect="expand"
|
||||
|
||||
@@ -144,3 +146,39 @@ global_rain_puddle_amount={
|
||||
"type": "float",
|
||||
"value": 0.0
|
||||
}
|
||||
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)
|
||||
}
|
||||
|
||||
BIN
tgcc/chunk/countryside/mesh/chunk_country_corner_01.fbx
Normal file
BIN
tgcc/chunk/countryside/mesh/chunk_country_corner_01.fbx
Normal file
Binary file not shown.
@@ -0,0 +1,44 @@
|
||||
[remap]
|
||||
|
||||
importer="scene"
|
||||
importer_version=1
|
||||
type="PackedScene"
|
||||
uid="uid://cdx81ro0lbv30"
|
||||
path="res://.godot/imported/chunk_country_corner_01.fbx-1e3be947b8fce32fb6be4f061435de52.scn"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://tgcc/chunk/countryside/mesh/chunk_country_corner_01.fbx"
|
||||
dest_files=["res://.godot/imported/chunk_country_corner_01.fbx-1e3be947b8fce32fb6be4f061435de52.scn"]
|
||||
|
||||
[params]
|
||||
|
||||
nodes/root_type=""
|
||||
nodes/root_name=""
|
||||
nodes/root_script=null
|
||||
nodes/apply_root_scale=true
|
||||
nodes/root_scale=1.0
|
||||
nodes/import_as_skeleton_bones=false
|
||||
nodes/use_name_suffixes=true
|
||||
nodes/use_node_type_suffixes=true
|
||||
meshes/ensure_tangents=true
|
||||
meshes/generate_lods=true
|
||||
meshes/create_shadow_meshes=true
|
||||
meshes/light_baking=1
|
||||
meshes/lightmap_texel_size=0.2
|
||||
meshes/force_disable_compression=false
|
||||
skins/use_named_skins=true
|
||||
animation/import=true
|
||||
animation/fps=30
|
||||
animation/trimming=true
|
||||
animation/remove_immutable_tracks=true
|
||||
animation/import_rest_as_RESET=false
|
||||
import_script/path=""
|
||||
materials/extract=0
|
||||
materials/extract_format=0
|
||||
materials/extract_path=""
|
||||
_subresources={}
|
||||
fbx/importer=0
|
||||
fbx/allow_geometry_helper_nodes=false
|
||||
fbx/embedded_image_handling=1
|
||||
fbx/naming_version=2
|
||||
BIN
tgcc/chunk/countryside/mesh/chunk_country_corner_02.fbx
Normal file
BIN
tgcc/chunk/countryside/mesh/chunk_country_corner_02.fbx
Normal file
Binary file not shown.
@@ -0,0 +1,44 @@
|
||||
[remap]
|
||||
|
||||
importer="scene"
|
||||
importer_version=1
|
||||
type="PackedScene"
|
||||
uid="uid://b5olmygr601ae"
|
||||
path="res://.godot/imported/chunk_country_corner_02.fbx-7efd402525316858718e1b90e10d2a39.scn"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://tgcc/chunk/countryside/mesh/chunk_country_corner_02.fbx"
|
||||
dest_files=["res://.godot/imported/chunk_country_corner_02.fbx-7efd402525316858718e1b90e10d2a39.scn"]
|
||||
|
||||
[params]
|
||||
|
||||
nodes/root_type=""
|
||||
nodes/root_name=""
|
||||
nodes/root_script=null
|
||||
nodes/apply_root_scale=true
|
||||
nodes/root_scale=1.0
|
||||
nodes/import_as_skeleton_bones=false
|
||||
nodes/use_name_suffixes=true
|
||||
nodes/use_node_type_suffixes=true
|
||||
meshes/ensure_tangents=true
|
||||
meshes/generate_lods=true
|
||||
meshes/create_shadow_meshes=true
|
||||
meshes/light_baking=1
|
||||
meshes/lightmap_texel_size=0.2
|
||||
meshes/force_disable_compression=false
|
||||
skins/use_named_skins=true
|
||||
animation/import=true
|
||||
animation/fps=30
|
||||
animation/trimming=true
|
||||
animation/remove_immutable_tracks=true
|
||||
animation/import_rest_as_RESET=false
|
||||
import_script/path=""
|
||||
materials/extract=0
|
||||
materials/extract_format=0
|
||||
materials/extract_path=""
|
||||
_subresources={}
|
||||
fbx/importer=0
|
||||
fbx/allow_geometry_helper_nodes=false
|
||||
fbx/embedded_image_handling=1
|
||||
fbx/naming_version=2
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user