2 Commits

Author SHA1 Message Date
Matteo Sonaglioni
53646e36f0 map - zoos 2026-04-23 17:24:36 +02:00
Matteo Sonaglioni
88dd7c3ad8 fix railway chunk 2026-04-23 16:48:14 +02:00
574 changed files with 744 additions and 62142 deletions

13
.idea/.gitignore generated vendored
View File

@@ -1,13 +0,0 @@
# Default ignored files
/shelf/
/workspace.xml
# Rider ignored files
/contentModel.xml
/modules.xml
/projectSettingsUpdater.xml
/.idea.tgcc.iml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

4
.idea/encodings.xml generated
View File

@@ -1,4 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding" addBOMForNewFiles="with BOM under Windows, with no BOM otherwise" />
</project>

8
.idea/indexLayout.xml generated
View File

@@ -1,8 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="UserContentModel">
<attachedFolders />
<explicitIncludes />
<explicitExcludes />
</component>
</project>

6
.idea/vcs.xml generated
View File

@@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>

View File

@@ -1,63 +0,0 @@
extends CharacterBody3D
class_name AIBase
@export_group("Settings")
@export var speed: float = 4.0
var _enable_state_machine: bool = true
@export var enable_state_machine: bool:
set(value):
_enable_state_machine = value
toggle_enable_state_machine()
get:
return _enable_state_machine
@export var anim_player: AnimationPlayer
@export_group("Entities")
enum EntityType { HUMANOID, ANIMAL }
@export var entity_type: EntityType = EntityType.HUMANOID
@export var entity_name: String = ""
@export var allowed_biomes: Array[String] = []
@export_range(0.0, 100.0, 0.1) var spawn_uniqueness: float = 1.0
@onready var patrol_radius_shape: CollisionShape3D = $%PatrolRadiusShape
@onready var nav_agent: NavigationAgent3D = $%NavigationAgent3D
@onready var state_machine: StateMachine = $%StateMachine
func _ready() -> void:
randomize()
toggle_enable_state_machine()
func toggle_enable_state_machine() -> void:
state_machine.enable = _enable_state_machine
func _physics_process(delta: float) -> void:
if !_enable_state_machine:
return
state_machine.physics_process(delta)
if nav_agent.is_navigation_finished():
velocity = Vector3.ZERO
move_and_slide()
return
var next_point = nav_agent.get_next_path_position()
var direction = global_position.direction_to(next_point)
velocity.x = direction.x * speed
velocity.z = direction.z * speed
if velocity.length_squared() > 0.1:
var look_dir = Vector3(velocity.x, 0, velocity.z)
var target_transform = global_transform.looking_at(global_position - look_dir, Vector3.UP)
global_transform = global_transform.interpolate_with(target_transform, delta * 10.0)
move_and_slide()
func navigate_to_random_point() -> void:
var nav_map_rid = get_world_3d().get_navigation_map()
var patrol_radius = patrol_radius_shape.shape.radius
var target_point_in_space = global_position + Vector3(randf_range(-1, 1), 0, randf_range(-1, 1)).normalized() * randf_range(0, patrol_radius)
var closest_valid_point = NavigationServer3D.map_get_closest_point(nav_map_rid, target_point_in_space)
nav_agent.target_position = closest_valid_point

View File

@@ -1 +0,0 @@
uid://b30p1yqojbbbk

View File

@@ -1,24 +0,0 @@
[gd_scene format=3 uid="uid://clx701xdwelgx"]
[ext_resource type="Script" uid="uid://b30p1yqojbbbk" path="res://core/ai/agents/base/ai_base.gd" id="1_4d1nn"]
[ext_resource type="Script" uid="uid://ps3vlu2qvmop" path="res://core/ai/framework/state_machine.gd" id="2_q1hg3"]
[sub_resource type="SphereShape3D" id="SphereShape3D_lim44"]
radius = 20.0
[node name="AiBase" type="CharacterBody3D" unique_id=1228675528]
script = ExtResource("1_4d1nn")
entity_name = "Humanoid"
[node name="NavigationAgent3D" type="NavigationAgent3D" parent="." unique_id=1370024449]
unique_name_in_owner = true
[node name="StateMachine" type="Node" parent="." unique_id=1286404264]
unique_name_in_owner = true
script = ExtResource("2_q1hg3")
[node name="PatrolRadiusShape" type="CollisionShape3D" parent="." unique_id=1379515938]
unique_name_in_owner = true
shape = SubResource("SphereShape3D_lim44")
disabled = true
debug_color = Color(1, 1, 0, 1)

View File

@@ -1,30 +0,0 @@
[gd_scene format=3 uid="uid://dd8wn62anbts8"]
[ext_resource type="PackedScene" uid="uid://clx701xdwelgx" path="res://core/ai/agents/base/ai_base.tscn" id="1_p2hpa"]
[ext_resource type="PackedScene" uid="uid://bjp8wbrtfl4v2" path="res://core/ai/agents/cow/cow_mannequin.tscn" id="2_6gadt"]
[ext_resource type="Script" uid="uid://d3hy70ec8vqo5" path="res://core/ai/framework/run_animation_state.gd" id="2_vlvvc"]
[ext_resource type="Script" uid="uid://bngfthvt04ivv" path="res://core/ai/framework/patrol_state.gd" id="3_su7en"]
[node name="AiCow" unique_id=1228675528 node_paths=PackedStringArray("anim_player") instance=ExtResource("1_p2hpa")]
anim_player = NodePath("CowMannequin/AnimationPlayer")
[node name="StateMachine" parent="." index="1" unique_id=1286404264 node_paths=PackedStringArray("initial_state")]
initial_state = NodePath("IdleState")
[node name="IdleState" type="Node" parent="StateMachine" index="0" unique_id=2033863310]
script = ExtResource("2_vlvvc")
state_id = &"idle"
next_state_id = &"patrol"
animation_name = "custom/idle"
[node name="PatrolState" type="Node" parent="StateMachine" index="1" unique_id=2076820654]
script = ExtResource("3_su7en")
state_id = &"patrol"
next_state_id = &"idle"
animation_name = "custom/walking"
exit_on_action_finished = true
[node name="CowMannequin" parent="." index="3" unique_id=1390675137 instance=ExtResource("2_6gadt")]
transform = Transform3D(0.25, 0, 0, 0, 0.25, 0, 0, 0, 0.25, 0, -0.9, 0)
[editable path="CowMannequin"]

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@@ -1,81 +0,0 @@
[gd_scene format=3 uid="uid://bjp8wbrtfl4v2"]
[ext_resource type="PackedScene" uid="uid://b7d57tyxi41r1" path="res://core/ai/agents/cow/cow.fbx" id="1_60f5q"]
[ext_resource type="Animation" uid="uid://bsuoywknbbnm0" path="res://core/ai/agents/cow/idle.res" id="2_5ukcj"]
[ext_resource type="Animation" uid="uid://ckmybsnuf4stp" path="res://core/ai/agents/cow/walking.res" id="3_0mu5m"]
[sub_resource type="AnimationLibrary" id="AnimationLibrary_lowte"]
_data = {
&"idle": ExtResource("2_5ukcj"),
&"walking": ExtResource("3_0mu5m")
}
[node name="CowMannequin" unique_id=786985233 instance=ExtResource("1_60f5q")]
[node name="Skeleton3D" parent="Armature" parent_id_path=PackedInt32Array(792301245) index="0" unique_id=1950086664]
bones/1/rotation = Quaternion(0.7071068, -6.209646e-07, -6.209645e-07, 0.7071067)
bones/1/scale = Vector3(1, 1, 1)
bones/4/rotation = Quaternion(0.0015316998, -0.0015319793, 0.70710516, 0.70710516)
bones/5/position = Vector3(1.3183898e-16, 0.006025583, -6.675722e-10)
bones/5/rotation = Quaternion(0.703962, -0.69745475, -0.08083715, 0.10705068)
bones/5/scale = Vector3(1, 0.99999976, 1)
bones/6/position = Vector3(-1.403955e-10, 0.009248152, 3.7406075e-11)
bones/6/rotation = Quaternion(0.18324056, -0.018661192, 0.0034790868, 0.98288476)
bones/6/scale = Vector3(1, 1, 1)
bones/8/scale = Vector3(0.99999994, 0.99999994, 1)
bones/9/position = Vector3(-3.8163916e-17, 0.0046958304, 1.907358e-10)
bones/9/rotation = Quaternion(0.6754388, -0.68119305, 0.18401879, -0.21423234)
bones/9/scale = Vector3(1, 0.99999994, 1.0000001)
bones/10/position = Vector3(7.2902e-10, 0.011755081, -3.0995417e-10)
bones/10/rotation = Quaternion(-0.35146433, 0.018116632, 0.0068026204, 0.9360013)
bones/10/scale = Vector3(0.9999999, 1, 1.0000001)
bones/12/rotation = Quaternion(0.707105, 0.70710486, 0.0016303749, -0.0016306548)
bones/12/scale = Vector3(1, 1, 1)
bones/13/position = Vector3(-1.5265567e-16, 0.0060255853, 6.6757205e-10)
bones/13/rotation = Quaternion(-0.057434652, -0.13032891, 0.70625645, 0.69348216)
bones/13/scale = Vector3(0.99999994, 1, 0.9999999)
bones/14/position = Vector3(-4.5945833e-10, 0.009248151, -5.7053273e-09)
bones/14/rotation = Quaternion(0.18302466, 0.051401887, -0.0095829815, 0.9817169)
bones/14/scale = Vector3(1, 1.0000001, 0.99999994)
bones/16/rotation = Quaternion(0.7071062, 0.7071063, 0.0008663558, -0.0008670737)
bones/16/scale = Vector3(1, 1, 1)
bones/17/position = Vector3(1.7347235e-17, 0.0046958304, -1.9073432e-10)
bones/17/rotation = Quaternion(0.1907959, 0.2076444, 0.67355627, 0.6832297)
bones/17/scale = Vector3(1, 1, 1.0000001)
bones/18/position = Vector3(1.834215e-10, 0.011755081, -1.7500804e-09)
bones/18/rotation = Quaternion(-0.35151497, -0.0088962475, -0.003340601, 0.93613404)
bones/18/scale = Vector3(1, 1.0000001, 0.99999994)
bones/20/rotation = Quaternion(0.60080343, -0.03016121, 0.03526711, 0.7980488)
bones/21/position = Vector3(0.00011168665, 0.0039693406, -0.013754063)
bones/21/rotation = Quaternion(0.98885596, 3.1474094e-08, 2.23642e-07, -0.14887528)
bones/21/scale = Vector3(1, 1.0000001, 1.0000001)
bones/22/position = Vector3(-2.5714557e-11, 0.00836347, -9.433328e-09)
bones/22/rotation = Quaternion(-0.6231534, 9.0575064e-08, -7.589477e-08, 0.78209966)
bones/22/scale = Vector3(1, 0.9999999, 0.99999994)
bones/23/position = Vector3(-2.1545942e-12, 0.0072733457, -2.594807e-09)
bones/23/rotation = Quaternion(-1.8223004e-08, 0.98608583, -0.16623694, 2.7314604e-07)
bones/23/scale = Vector3(1, 0.9999997, 0.9999997)
bones/24/position = Vector3(3.3663968e-13, 0.006993335, -2.8376712e-09)
bones/24/rotation = Quaternion(-0.048028953, 2.6759114e-08, 4.5447155e-08, 0.998846)
bones/24/scale = Vector3(1, 0.99999994, 1.0000001)
bones/26/rotation = Quaternion(0.0054439656, 0.86556005, 0.50029516, -0.021930087)
bones/26/scale = Vector3(1, 1.0000002, 1)
bones/27/position = Vector3(1.8971762e-10, 0.013189232, -5.7312505e-10)
bones/27/rotation = Quaternion(0.15129425, -0.018451845, -0.013046658, 0.9882304)
bones/27/scale = Vector3(0.99999994, 0.99999994, 1.0000001)
bones/28/position = Vector3(-2.1601461e-10, 0.013573305, 4.8459786e-10)
bones/28/rotation = Quaternion(-0.6245376, -0.19781438, 0.16660775, 0.7369289)
bones/28/scale = Vector3(1, 0.9999999, 1.0000001)
bones/30/rotation = Quaternion(3.5765906e-06, 0.67050743, 0.7419029, 3.2289404e-06)
bones/31/position = Vector3(-1.2499713e-14, 0.01925819, -1.2902629e-09)
bones/31/rotation = Quaternion(0.086390205, 0.0012038474, -0.013495129, 0.99616927)
bones/31/scale = Vector3(0.9999999, 0.99999994, 1)
bones/33/rotation = Quaternion(0.7071068, -6.209646e-07, -6.209645e-07, 0.7071067)
bones/33/scale = Vector3(1, 1, 1)
bones/35/rotation = Quaternion(0.7071068, -9.581396e-07, -9.581394e-07, 0.7071067)
bones/35/scale = Vector3(1, 1, 1)
bones/37/rotation = Quaternion(0.7071068, -9.581396e-07, -9.581394e-07, 0.7071067)
bones/37/scale = Vector3(1, 1, 1)
[node name="AnimationPlayer" parent="." index="1" unique_id=1401028430]
libraries/custom = SubResource("AnimationLibrary_lowte")

Binary file not shown.

Binary file not shown.

View File

@@ -1,69 +0,0 @@
[gd_scene format=3 uid="uid://cayakdk7gmlyg"]
[ext_resource type="PackedScene" uid="uid://clx701xdwelgx" path="res://core/ai/agents/base/ai_base.tscn" id="1_e5v3h"]
[ext_resource type="PackedScene" uid="uid://dqhueybnlrrqx" path="res://core/ai/agents/horse/horse_mannequin.tscn" id="2_4t6jw"]
[ext_resource type="Script" uid="uid://d3hy70ec8vqo5" path="res://core/ai/framework/run_animation_state.gd" id="2_or6xs"]
[ext_resource type="Script" uid="uid://bngfthvt04ivv" path="res://core/ai/framework/patrol_state.gd" id="3_n63jb"]
[ext_resource type="Animation" uid="uid://doyi6etqvy4n2" path="res://core/ai/agents/horse/idle.res" id="3_qe4rt"]
[ext_resource type="Animation" uid="uid://hotr7r3fd1sq" path="res://core/ai/agents/horse/walking.res" id="4_q8m0v"]
[sub_resource type="AnimationLibrary" id="AnimationLibrary_or6xs"]
_data = {
&"idle": ExtResource("3_qe4rt"),
&"walking": ExtResource("4_q8m0v")
}
[node name="AiHorse" unique_id=1228675528 node_paths=PackedStringArray("anim_player") instance=ExtResource("1_e5v3h")]
anim_player = NodePath("HorseMannequin/AnimationPlayer")
[node name="StateMachine" parent="." index="1" unique_id=1286404264 node_paths=PackedStringArray("initial_state")]
initial_state = NodePath("IdleState")
[node name="IdleState" type="Node" parent="StateMachine" index="0" unique_id=734754793]
script = ExtResource("2_or6xs")
state_id = &"idle"
next_state_id = &"patrol"
animation_name = "custom/idle"
[node name="PatrolState" type="Node" parent="StateMachine" index="1" unique_id=1748382252]
script = ExtResource("3_n63jb")
state_id = &"patrol"
next_state_id = &"idle"
animation_name = "custom/walking"
exit_on_action_finished = true
[node name="HorseMannequin" parent="." index="3" unique_id=1289880358 instance=ExtResource("2_4t6jw")]
transform = Transform3D(0.2, 0, 0, 0, 0.2, 0, 0, 0, 0.2, 0, -0.9, 0)
[node name="Skeleton3D" parent="HorseMannequin/Armature" parent_id_path=PackedInt32Array(1289880358, 245823720) index="0" unique_id=494955820]
bones/1/rotation = Quaternion(0.7071068, -6.209646e-07, -6.209645e-07, 0.7071067)
bones/4/rotation = Quaternion(0.0012952884, -0.0012955684, 0.7071056, 0.7071057)
bones/5/rotation = Quaternion(0.70685357, -0.70227593, -0.04508998, 0.07164877)
bones/6/rotation = Quaternion(0.13314606, -0.018813655, 0.0025279524, 0.9909147)
bones/8/rotation = Quaternion(0.00078355736, -0.00078427553, 0.70710635, 0.70710635)
bones/9/rotation = Quaternion(0.6711558, -0.6744515, 0.20213859, -0.23195927)
bones/10/rotation = Quaternion(-0.3574636, 0.018072592, 0.006918765, 0.9337266)
bones/12/rotation = Quaternion(0.7071054, 0.7071055, 0.0013743625, -0.0013746425)
bones/13/rotation = Quaternion(-0.02159133, -0.09508795, 0.70796114, 0.69948786)
bones/14/rotation = Quaternion(0.13298893, 0.051821847, -0.0069631753, 0.9897374)
bones/16/rotation = Quaternion(0.7071064, 0.70710653, 0.00066260004, -0.00066331815)
bones/17/rotation = Quaternion(0.20885532, 0.22542001, 0.6690968, 0.6766645)
bones/18/rotation = Quaternion(-0.3575147, -0.008874607, -0.003397635, 0.9338592)
bones/20/rotation = Quaternion(0.6010642, -0.021428203, 0.02848876, 0.79840535)
bones/21/rotation = Quaternion(0.99267024, 2.482745e-08, 2.2239277e-07, -0.12085533)
bones/22/rotation = Quaternion(-0.6165577, 9.507701e-08, -7.2693986e-08, 0.7873097)
bones/23/rotation = Quaternion(-1.5614631e-08, 0.9891947, -0.14660779, 2.7153942e-07)
bones/24/rotation = Quaternion(0.03904001, 3.5621138e-08, 1.47960275e-08, 0.99923766)
bones/26/rotation = Quaternion(0.008421451, 0.95973384, 0.27944198, -0.027427308)
bones/27/rotation = Quaternion(-0.08868468, -0.022488868, -0.01781765, 0.9956465)
bones/28/rotation = Quaternion(-0.62453747, -0.1978144, 0.1666077, 0.736929)
bones/30/rotation = Quaternion(3.4527793e-06, 0.6944211, 0.71956885, 3.3297817e-06)
bones/31/rotation = Quaternion(0.053752482, 0.0007617086, -0.013526975, 0.9984624)
bones/33/rotation = Quaternion(0.7071068, -6.209646e-07, -6.209645e-07, 0.7071067)
bones/35/rotation = Quaternion(0.7071068, -9.581396e-07, -9.581394e-07, 0.7071067)
bones/37/rotation = Quaternion(0.7071068, -9.581396e-07, -9.581394e-07, 0.7071067)
[node name="AnimationPlayer" parent="HorseMannequin" index="1" unique_id=272680130]
libraries/custom = SubResource("AnimationLibrary_or6xs")
[editable path="HorseMannequin"]

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@@ -1,5 +0,0 @@
[gd_scene format=3 uid="uid://dqhueybnlrrqx"]
[ext_resource type="PackedScene" uid="uid://be1ql8okme4n7" path="res://core/ai/agents/horse/horse.fbx" id="1_fbqil"]
[node name="HorseMannequin" unique_id=1289880358 instance=ExtResource("1_fbqil")]

Binary file not shown.

Binary file not shown.

View File

@@ -1,10 +0,0 @@
[gd_scene format=3 uid="uid://bdqeshcwwnyc4"]
[ext_resource type="PackedScene" uid="uid://mvh2v6v72stt" path="res://core/ai/agents/human/ai_human.tscn" id="1_awhwq"]
[node name="AiCitizen" unique_id=1228675528 instance=ExtResource("1_awhwq")]
[node name="StateMachine" parent="." index="3" unique_id=1286404264 node_paths=PackedStringArray("initial_state")]
initial_state = NodePath("")
[editable path="HumanMannequin"]

View File

@@ -1,53 +0,0 @@
[gd_scene format=3 uid="uid://bbseno7clbepx"]
[ext_resource type="PackedScene" uid="uid://bdqeshcwwnyc4" path="res://core/ai/agents/human/ai_citizen.tscn" id="1_cduuu"]
[node name="AiCitizenSitter" unique_id=1228675528 instance=ExtResource("1_cduuu")]
[node name="SK_Mannequin" parent="HumanMannequin" parent_id_path=PackedInt32Array(333236377) index="0" unique_id=377304892]
transform = Transform3D(0.99906886, 0.025971904, -0.03444738, 0.038254507, -0.16420224, 0.98568463, 0.019943757, -0.98608464, -0.1650429, 0.034450583, -0.44864154, 0.18535595)
[node name="Skeleton3D" parent="HumanMannequin/SK_Mannequin" index="0" unique_id=427572412]
bones/2/rotation = Quaternion(-0.007029906, 0.032859802, -0.23654123, 0.97104025)
bones/3/rotation = Quaternion(-0.000884556, 0.0033522977, 0.10280211, 0.99469584)
bones/4/rotation = Quaternion(-0.00040807336, 0.0034836144, 0.0045103733, 0.9999837)
bones/5/rotation = Quaternion(0.13797933, 0.74176145, 0.017092831, 0.6560942)
bones/6/rotation = Quaternion(0.049281683, 0.43982458, -0.36467218, 0.81923133)
bones/7/rotation = Quaternion(-0.049351897, 0.03842162, -0.476375, 0.87701494)
bones/8/rotation = Quaternion(-0.41694272, -0.05554785, -0.18030654, 0.889136)
bones/9/rotation = Quaternion(0.094457716, 0.050416686, 0.50820345, 0.85455555)
bones/10/rotation = Quaternion(0.011606372, 0.08610083, 0.2719557, 0.95838)
bones/12/rotation = Quaternion(-0.00016985182, 0.0032503307, 0.42722064, 0.90414155)
bones/13/rotation = Quaternion(-0.018024907, 0.015150134, 0.27278355, 0.9617873)
bones/15/rotation = Quaternion(-0.13467012, -0.10029431, 0.2853874, 0.94358844)
bones/16/rotation = Quaternion(0.010311794, -0.034373257, 0.13259757, 0.9905202)
bones/18/rotation = Quaternion(-0.09865642, -0.08747626, 0.37470394, 0.917721)
bones/19/rotation = Quaternion(0.0042531197, -0.033760007, 0.1860149, 0.98195755)
bones/21/rotation = Quaternion(0.70078146, 0.36200625, -0.001720201, 0.61469823)
bones/22/rotation = Quaternion(-0.001820262, 0.12128391, 0.22490783, 0.9668006)
bones/26/rotation = Quaternion(0.76902086, -0.13267346, -0.62528044, -0.005393706)
bones/27/rotation = Quaternion(0.034201004, 0.38763282, -0.48749813, 0.7816117)
bones/28/rotation = Quaternion(-0.053170834, 0.025972798, -0.32202634, 0.9448796)
bones/29/rotation = Quaternion(-0.43919632, 0.049489442, -0.098192796, 0.89163643)
bones/30/rotation = Quaternion(0.103668794, 0.04579189, 0.46590617, 0.8775462)
bones/31/rotation = Quaternion(0.011519267, 0.09922818, 0.29214594, 0.95114243)
bones/33/rotation = Quaternion(9.437185e-05, 0.009016322, 0.44048977, 0.89771235)
bones/34/rotation = Quaternion(-0.018226523, 0.017689873, 0.23132406, 0.97254515)
bones/36/rotation = Quaternion(-0.13272016, -0.101737194, 0.26830983, 0.9487069)
bones/37/rotation = Quaternion(0.010193698, -0.046628788, 0.19672133, 0.97929704)
bones/39/rotation = Quaternion(-0.110196866, -0.05036995, 0.35450295, 0.9271716)
bones/40/rotation = Quaternion(0.0042593707, -0.028552007, 0.17841409, 0.983532)
bones/42/rotation = Quaternion(0.7297342, 0.26573184, -0.09265223, 0.6231294)
bones/43/rotation = Quaternion(0.06426929, 0.22943345, 0.1991351, 0.95056564)
bones/47/rotation = Quaternion(0.00421817, -0.00037953872, -0.21590644, 0.9764049)
bones/49/rotation = Quaternion(0.14012733, -0.038448263, 0.6819175, 0.7168505)
bones/50/rotation = Quaternion(-0.05631607, 0.020481886, -0.74316776, 0.6664162)
bones/52/rotation = Quaternion(-0.0004946971, -0.048858073, -0.0074254284, 0.998778)
bones/55/rotation = Quaternion(0.0132777635, 0.10731075, 0.71409845, -0.6916441)
bones/56/rotation = Quaternion(0.03920827, -0.09832406, -0.75485575, 0.64729285)
bones/58/rotation = Quaternion(0.01656407, -0.06386153, 0.030505493, 0.9973549)
[node name="AnimationPlayer" parent="HumanMannequin" parent_id_path=PackedInt32Array(333236377) index="1" unique_id=233699491]
autoplay = &"custom/sit"
[editable path="HumanMannequin"]

View File

@@ -1,25 +0,0 @@
[gd_scene format=3 uid="uid://bnnuke5e7e1yr"]
[ext_resource type="PackedScene" uid="uid://bdqeshcwwnyc4" path="res://core/ai/agents/human/ai_citizen.tscn" id="1_dms8s"]
[ext_resource type="Script" uid="uid://d3hy70ec8vqo5" path="res://core/ai/framework/run_animation_state.gd" id="2_awhwq"]
[ext_resource type="Script" uid="uid://bngfthvt04ivv" path="res://core/ai/framework/patrol_state.gd" id="3_8d0tj"]
[node name="AiCitizenWalker" unique_id=1228675528 instance=ExtResource("1_dms8s")]
[node name="StateMachine" parent="." index="3" unique_id=1286404264 node_paths=PackedStringArray("initial_state")]
initial_state = NodePath("IdleState")
[node name="IdleState" type="Node" parent="StateMachine" index="0" unique_id=42226979]
script = ExtResource("2_awhwq")
state_id = &"idle"
next_state_id = &"patrol"
animation_name = "custom/idle"
[node name="PatrolState" type="Node" parent="StateMachine" index="1" unique_id=1357892786]
script = ExtResource("3_8d0tj")
state_id = &"patrol"
next_state_id = &"idle"
animation_name = "custom/walking"
exit_on_action_finished = true
[editable path="HumanMannequin"]

View File

@@ -1,26 +0,0 @@
[gd_scene format=3 uid="uid://ceqxsqfiotm5j"]
[ext_resource type="PackedScene" uid="uid://mvh2v6v72stt" path="res://core/ai/agents/human/ai_human.tscn" id="1_l2y7m"]
[ext_resource type="Script" uid="uid://bngfthvt04ivv" path="res://core/ai/framework/patrol_state.gd" id="3_2oda6"]
[ext_resource type="Script" uid="uid://d3hy70ec8vqo5" path="res://core/ai/framework/run_animation_state.gd" id="4_2oda6"]
[node name="AiFarmer" unique_id=1228675528 instance=ExtResource("1_l2y7m")]
[node name="StateMachine" parent="." index="3" unique_id=1286404264 node_paths=PackedStringArray("initial_state")]
initial_state = NodePath("GatherState")
[node name="PatrolState" type="Node" parent="StateMachine" index="0" unique_id=930272128]
script = ExtResource("3_2oda6")
state_id = &"patrol"
next_state_id = &"gather"
animation_name = "custom/walking"
exit_on_action_finished = true
[node name="GatherState" type="Node" parent="StateMachine" index="1" unique_id=48091671]
script = ExtResource("4_2oda6")
state_id = &"gather"
next_state_id = &"patrol"
animation_name = "custom/gather"
exit_on_animation_finished = true
[editable path="HumanMannequin"]

View File

@@ -1,55 +0,0 @@
[gd_scene format=3 uid="uid://mvh2v6v72stt"]
[ext_resource type="PackedScene" uid="uid://clx701xdwelgx" path="res://core/ai/agents/base/ai_base.tscn" id="1_hko2w"]
[ext_resource type="PackedScene" uid="uid://legcajdd0jsy" path="res://core/ai/agents/human/human_mannequin.tscn" id="2_cnrgi"]
[node name="AiHuman" unique_id=1228675528 node_paths=PackedStringArray("anim_player") instance=ExtResource("1_hko2w")]
anim_player = NodePath("HumanMannequin/AnimationPlayer")
[node name="HumanMannequin" parent="." index="3" unique_id=333236377 instance=ExtResource("2_cnrgi")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.9, 0)
[node name="SK_Mannequin" parent="HumanMannequin" index="0" unique_id=2096894453]
transform = Transform3D(0.99999994, 0, 0, 0, -4.371139e-08, 1, 0, -1, -4.371139e-08, 0, 0, 0)
[node name="Skeleton3D" parent="HumanMannequin/SK_Mannequin" index="0" unique_id=1402189960]
bones/2/rotation = Quaternion(-2.1971985e-24, 0, -0.062388558, 0.99805194)
bones/3/rotation = Quaternion(4.135903e-25, 1.6543612e-24, 0.12241964, 0.99247843)
bones/4/rotation = Quaternion(2.2850868e-23, 0, 0.024252614, 0.9997059)
bones/5/rotation = Quaternion(0.20891805, 0.7294167, 0.12304399, 0.6396598)
bones/6/rotation = Quaternion(0.11299576, 0.33062968, -0.16141911, 0.92296255)
bones/7/rotation = Quaternion(-0.05401651, -0.079182714, -0.26340967, 0.9599103)
bones/8/rotation = Quaternion(-0.61789525, 0.019371983, 0.010653294, 0.7859496)
bones/9/rotation = Quaternion(0.1333045, -0.0031801206, 0.22317973, 0.96561414)
bones/10/rotation = Quaternion(0.012043531, -0.0029058352, 0.10444825, 0.9944532)
bones/12/rotation = Quaternion(0.028522171, -0.05687394, 0.19848494, 0.9780366)
bones/13/rotation = Quaternion(-0.018628873, 0.007972199, 0.10711657, 0.99404)
bones/15/rotation = Quaternion(-0.1295377, -0.18789689, 0.14421311, 0.9628693)
bones/16/rotation = Quaternion(0.010359715, -0.010519396, 0.09774818, 0.9951017)
bones/18/rotation = Quaternion(-0.095480494, -0.116765715, 0.18851167, 0.9704188)
bones/19/rotation = Quaternion(0.00430111, -0.0141675975, 0.11596311, 0.9931432)
bones/21/rotation = Quaternion(0.6303091, 0.37152508, -0.07729015, 0.6772783)
bones/22/rotation = Quaternion(0.0026046867, 0.086798474, 0.13014112, 0.98768544)
bones/26/rotation = Quaternion(0.7294168, -0.20891781, -0.6396598, 0.12304417)
bones/27/rotation = Quaternion(0.11299576, 0.33062968, -0.16141911, 0.92296255)
bones/28/rotation = Quaternion(-0.05401651, -0.079182714, -0.26340967, 0.9599103)
bones/29/rotation = Quaternion(-0.61789525, 0.019371983, 0.010653294, 0.7859496)
bones/30/rotation = Quaternion(0.1333045, -0.0031801206, 0.22317973, 0.96561414)
bones/31/rotation = Quaternion(0.012043531, -0.0029058352, 0.10444825, 0.9944532)
bones/33/rotation = Quaternion(0.028522171, -0.05687394, 0.19848494, 0.9780366)
bones/34/rotation = Quaternion(-0.018628873, 0.007972199, 0.10711657, 0.99404)
bones/36/rotation = Quaternion(-0.1295377, -0.18789689, 0.14421311, 0.9628693)
bones/37/rotation = Quaternion(0.010359715, -0.010519396, 0.09774818, 0.9951017)
bones/39/rotation = Quaternion(-0.095480494, -0.116765715, 0.18851167, 0.9704188)
bones/40/rotation = Quaternion(0.00430111, -0.0141675975, 0.11596311, 0.9931432)
bones/42/rotation = Quaternion(0.6303091, 0.37152508, -0.07729015, 0.6772783)
bones/43/rotation = Quaternion(0.0026047025, 0.08679848, 0.13014114, 0.98768544)
bones/47/rotation = Quaternion(-1.5923227e-23, 0, -0.20371072, 0.97903115)
bones/49/rotation = Quaternion(0.07370486, -0.062138822, -0.008584324, 0.9953053)
bones/50/rotation = Quaternion(-0.048884246, 0.018863896, -0.06552225, 0.99647444)
bones/52/rotation = Quaternion(-0.0058857696, 0.03199128, 0.07035475, 0.9969916)
bones/55/rotation = Quaternion(0.062138822, 0.07370486, 0.9953054, 0.008584333)
bones/56/rotation = Quaternion(-0.048884246, 0.018863896, -0.06552225, 0.99647444)
bones/58/rotation = Quaternion(-0.0058857696, 0.03199128, 0.07035475, 0.9969916)
[editable path="HumanMannequin"]

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@@ -1,94 +0,0 @@
[gd_scene format=3 uid="uid://legcajdd0jsy"]
[ext_resource type="PackedScene" uid="uid://ys8pesrqeyv2" path="res://core/ai/agents/human/human_mannequin_mixamo.fbx" id="1_561x5"]
[ext_resource type="Animation" uid="uid://bod5wup7tap24" path="res://core/ai/agents/human/gather.res" id="2_3r4wv"]
[ext_resource type="Animation" uid="uid://cp4pl635iv3g7" path="res://core/ai/agents/human/idle.res" id="2_b4vfe"]
[ext_resource type="Animation" uid="uid://ckkmrph86jlsd" path="res://core/ai/agents/human/walking.res" id="3_jl3mr"]
[ext_resource type="Animation" uid="uid://byksuipm2bly7" path="res://core/ai/agents/human/sit.res" id="4_xaokg"]
[sub_resource type="AnimationLibrary" id="AnimationLibrary_3r4wv"]
_data = {
&"gather": ExtResource("2_3r4wv"),
&"idle": ExtResource("2_b4vfe"),
&"sit": ExtResource("4_xaokg"),
&"walking": ExtResource("3_jl3mr")
}
[node name="HumanMannequin" unique_id=1583776159 instance=ExtResource("1_561x5")]
[node name="SK_Mannequin" parent="." index="0" unique_id=2096894453]
transform = Transform3D(0.9990688, 0.025971903, -0.034447376, 0.038254507, -0.16420223, 0.9856846, 0.019943757, -0.9860846, -0.16504289, 0.034450583, -0.44864154, 0.18535595)
[node name="Skeleton3D" parent="SK_Mannequin" index="0" unique_id=1402189960]
bones/2/rotation = Quaternion(-0.007029906, 0.032859802, -0.23654123, 0.97104025)
bones/3/rotation = Quaternion(-0.000884556, 0.0033522977, 0.10280211, 0.99469584)
bones/4/position = Vector3(0.13407329, 0.004204774, -5.584202e-15)
bones/4/rotation = Quaternion(-0.00040807336, 0.0034836144, 0.0045103733, 0.9999837)
bones/5/rotation = Quaternion(0.13797933, 0.74176145, 0.017092831, 0.6560942)
bones/6/position = Vector3(0.15784872, 1.4317955e-11, 6.3591354e-11)
bones/6/rotation = Quaternion(0.049281683, 0.43982458, -0.36467218, 0.81923133)
bones/7/position = Vector3(0.3033993, 8.407472e-11, 3.197531e-11)
bones/7/rotation = Quaternion(-0.049351897, 0.03842162, -0.476375, 0.87701494)
bones/8/position = Vector3(0.26975143, 1.572964e-11, -9.6207486e-11)
bones/8/rotation = Quaternion(-0.41694272, -0.05554785, -0.18030654, 0.889136)
bones/9/rotation = Quaternion(0.094457716, 0.050416686, 0.50820345, 0.85455555)
bones/10/position = Vector3(0.04287498, -2.9850333e-10, 5.048406e-11)
bones/10/rotation = Quaternion(0.011606372, 0.08610083, 0.2719557, 0.95838)
bones/11/position = Vector3(0.0339379, 1.1695445e-10, -2.349232e-11)
bones/12/rotation = Quaternion(-0.00016985182, 0.0032503307, 0.42722064, 0.90414155)
bones/13/position = Vector3(0.046403743, -3.648193e-11, 1.830866e-11)
bones/13/rotation = Quaternion(-0.018024907, 0.015150134, 0.27278355, 0.9617873)
bones/14/position = Vector3(0.036488436, -1.9989443e-10, 1.6076356e-11)
bones/15/rotation = Quaternion(-0.13467012, -0.10029431, 0.2853874, 0.94358844)
bones/16/position = Vector3(0.03570981, 1.8669866e-10, 3.9181436e-12)
bones/16/rotation = Quaternion(0.010311794, -0.034373257, 0.13259757, 0.9905202)
bones/17/position = Vector3(0.029856307, -3.005879e-10, -4.0375425e-11)
bones/18/rotation = Quaternion(-0.09865642, -0.08747626, 0.37470394, 0.917721)
bones/19/position = Vector3(0.04430177, 4.6665116e-11, -9.4033115e-12)
bones/19/rotation = Quaternion(0.0042531197, -0.033760007, 0.1860149, 0.98195755)
bones/20/position = Vector3(0.034766525, -1.6786372e-10, 2.768652e-11)
bones/21/rotation = Quaternion(0.70078146, 0.36200625, -0.001720201, 0.61469823)
bones/22/position = Vector3(0.038696717, 5.0118687e-11, 9.9849684e-11)
bones/22/rotation = Quaternion(-0.001820262, 0.12128391, 0.22490783, 0.9668006)
bones/23/position = Vector3(0.040621713, 1.0721979e-11, -5.127232e-12)
bones/24/position = Vector3(0.14, 1.110223e-16, 2.220446e-16)
bones/24/rotation = Quaternion(-2.7755576e-17, -6.938894e-17, -6.938894e-18, 1)
bones/25/position = Vector3(0.005, -2.7755576e-17, 0)
bones/25/rotation = Quaternion(-9.540979e-18, -2.7755576e-17, 9.540979e-18, 1)
bones/26/rotation = Quaternion(0.76902086, -0.13267346, -0.62528044, -0.005393706)
bones/27/rotation = Quaternion(0.034201004, 0.38763282, -0.48749813, 0.7816117)
bones/28/rotation = Quaternion(-0.053170834, 0.025972798, -0.32202634, 0.9448796)
bones/29/position = Vector3(-0.26975244, 2.563412e-07, -1.1905385e-08)
bones/29/rotation = Quaternion(-0.43919632, 0.049489442, -0.098192796, 0.89163643)
bones/30/rotation = Quaternion(0.103668794, 0.04579189, 0.46590617, 0.8775462)
bones/31/rotation = Quaternion(0.011519267, 0.09922818, 0.29214594, 0.95114243)
bones/33/rotation = Quaternion(9.437185e-05, 0.009016322, 0.44048977, 0.89771235)
bones/34/rotation = Quaternion(-0.018226523, 0.017689873, 0.23132406, 0.97254515)
bones/36/rotation = Quaternion(-0.13272016, -0.101737194, 0.26830983, 0.9487069)
bones/37/rotation = Quaternion(0.010193698, -0.046628788, 0.19672133, 0.97929704)
bones/39/rotation = Quaternion(-0.110196866, -0.05036995, 0.35450295, 0.9271716)
bones/40/rotation = Quaternion(0.0042593707, -0.028552007, 0.17841409, 0.983532)
bones/42/rotation = Quaternion(0.7297342, 0.26573184, -0.09265223, 0.6231294)
bones/43/rotation = Quaternion(0.06426929, 0.22943345, 0.1991351, 0.95056564)
bones/45/rotation = Quaternion(-0.1176271, 1.3974802e-16, -6.288661e-17, 0.99305785)
bones/46/rotation = Quaternion(-0.17323487, -2.099698e-25, 1.9374898e-17, 0.9848805)
bones/47/rotation = Quaternion(0.00421817, -0.00037953872, -0.21590644, 0.9764049)
bones/48/position = Vector3(0.092836134, 0.0036415688, 2.7747754e-17)
bones/48/rotation = Quaternion(1.2661336e-17, 9.989056e-18, 0.13354194, 0.99104315)
bones/49/rotation = Quaternion(0.14012733, -0.038448263, 0.6819175, 0.7168505)
bones/50/position = Vector3(-0.42572036, 1.7074263e-12, -4.667877e-12)
bones/50/rotation = Quaternion(-0.05631607, 0.020481886, -0.74316776, 0.6664162)
bones/51/position = Vector3(-0.20476776, -1.3877788e-17, 0)
bones/52/position = Vector3(-0.4019669, -3.933849e-11, 1.899425e-12)
bones/52/rotation = Quaternion(-0.0004946971, -0.048858073, -0.0074254284, 0.998778)
bones/54/position = Vector3(-0.22094238, 4.7704896e-18, 0)
bones/55/rotation = Quaternion(0.0132777635, 0.10731075, 0.71409845, -0.6916441)
bones/56/rotation = Quaternion(0.03920827, -0.09832406, -0.75485575, 0.64729285)
bones/57/position = Vector3(0.20476907, 0, -5.551115e-17)
bones/58/rotation = Quaternion(0.01656407, -0.06386153, 0.030505493, 0.9973549)
bones/60/position = Vector3(0.22094241, 3.035766e-18, -2.7755576e-17)
bones/67/position = Vector3(-4.440892e-16, 0, 7.632783e-17)
bones/67/rotation = Quaternion(-2.8449465e-16, 8.326673e-17, 2.7755576e-17, 1)
[node name="AnimationPlayer" parent="." index="1" unique_id=1304782348]
libraries/custom = SubResource("AnimationLibrary_3r4wv")

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

View File

@@ -1,76 +0,0 @@
[gd_scene format=3 uid="uid://c2hg6hu2y5srb"]
[ext_resource type="PackedScene" uid="uid://clx701xdwelgx" path="res://core/ai/agents/base/ai_base.tscn" id="1_j8spt"]
[ext_resource type="Script" uid="uid://d3hy70ec8vqo5" path="res://core/ai/framework/run_animation_state.gd" id="2_acc6o"]
[ext_resource type="PackedScene" uid="uid://b0xb7kl4rjd66" path="res://core/ai/agents/pig/pig_mannequin.tscn" id="2_qmc2e"]
[ext_resource type="Script" uid="uid://bngfthvt04ivv" path="res://core/ai/framework/patrol_state.gd" id="3_3n8ak"]
[ext_resource type="Animation" uid="uid://c4ingpw0co8v2" path="res://core/ai/agents/pig/idle.res" id="3_lvpc5"]
[ext_resource type="Animation" uid="uid://0563r715lmw1" path="res://core/ai/agents/pig/walking.res" id="4_3f3hl"]
[sub_resource type="AnimationLibrary" id="AnimationLibrary_lvpc5"]
_data = {
&"idle": ExtResource("3_lvpc5"),
&"walking": ExtResource("4_3f3hl")
}
[node name="AiPig" unique_id=1228675528 node_paths=PackedStringArray("anim_player") instance=ExtResource("1_j8spt")]
anim_player = NodePath("PigMannequin/AnimationPlayer")
[node name="StateMachine" parent="." index="1" unique_id=1286404264 node_paths=PackedStringArray("initial_state")]
initial_state = NodePath("IdleState")
[node name="IdleState" type="Node" parent="StateMachine" index="0" unique_id=403305255]
script = ExtResource("2_acc6o")
state_id = &"idle"
next_state_id = &"patrol"
animation_name = "custom/idle"
[node name="PatrolState" type="Node" parent="StateMachine" index="1" unique_id=1237150984]
script = ExtResource("3_3n8ak")
state_id = &"patrol"
next_state_id = &"idle"
animation_name = "custom/walking"
exit_on_action_finished = true
[node name="PigMannequin" parent="." index="3" unique_id=926755470 instance=ExtResource("2_qmc2e")]
transform = Transform3D(0.2, 0, 0, 0, 0.2, 0, 0, 0, 0.2, 0, -0.9, 0)
[node name="Skeleton3D" parent="PigMannequin/Armature" parent_id_path=PackedInt32Array(926755470, 695496535) index="0" unique_id=725647261]
bones/1/rotation = Quaternion(0.7071068, -7.052583e-07, -7.052583e-07, 0.7071067)
bones/3/position = Vector3(5.37765e-05, 0.017809996, -0.007695386)
bones/3/rotation = Quaternion(-0.027121998, 0, 0, 0.99963224)
bones/4/position = Vector3(-0.004269575, -0.0009057691, 0.018837402)
bones/4/rotation = Quaternion(-0.20850496, 0.20850474, 0.675667, 0.6756669)
bones/5/rotation = Quaternion(0.70767504, -0.7007484, -0.04928623, 0.07562217)
bones/6/rotation = Quaternion(0.5074964, -0.016355418, 0.009635334, 0.86144483)
bones/8/position = Vector3(-0.004269574, 0.0008725248, -0.02819033)
bones/8/rotation = Quaternion(-0.021000031, 0.020999499, 0.7067949, 0.7067949)
bones/9/rotation = Quaternion(0.6762797, -0.7030302, 0.13760945, -0.17163305)
bones/10/rotation = Quaternion(-0.76131815, 0.012544005, 0.014735432, 0.64808965)
bones/12/position = Vector3(0.0036532492, -0.0009057691, 0.018837402)
bones/12/rotation = Quaternion(0.67572093, 0.6757209, -0.20832984, 0.20832963)
bones/13/rotation = Quaternion(-0.025831472, -0.099082425, 0.70891863, 0.6978179)
bones/14/rotation = Quaternion(0.50689334, 0.045050938, -0.026540417, 0.8604216)
bones/16/position = Vector3(0.0036521717, 0.0008013838, -0.028183708)
bones/16/rotation = Quaternion(0.7068031, 0.7068031, -0.020723455, 0.020722982)
bones/17/rotation = Quaternion(0.1443776, 0.16487122, 0.6747477, 0.7047611)
bones/18/rotation = Quaternion(-0.7649948, -0.0061196624, -0.0072699804, 0.64396644)
bones/20/position = Vector3(-0.00042349403, 0.0063493187, -0.030968314)
bones/20/rotation = Quaternion(0.60138106, 0.012805484, 0.0019118772, 0.79885745)
bones/22/position = Vector3(-0.0002038494, 0.0041766805, 0.0044565103)
bones/22/rotation = Quaternion(0.0076635648, 0.7548352, 0.6556045, -0.018651871)
bones/23/rotation = Quaternion(0.065689825, -0.010677165, -0.019551655, 0.99759144)
bones/24/rotation = Quaternion(-0.24106143, -0.2388839, 0.03569213, 0.9399734)
bones/26/position = Vector3(-0.00032282702, 0.010153349, -0.021613695)
bones/26/rotation = Quaternion(3.6196245e-06, 0.6452338, 0.7639852, 3.2175833e-06)
bones/27/rotation = Quaternion(0.0455184, 0.00040800165, -0.025042463, 0.99864954)
bones/29/position = Vector3(-0.01117923, 0.0010000349, -0.03163386)
bones/29/rotation = Quaternion(0.7071068, -6.178108e-07, -6.178107e-07, 0.7071067)
bones/31/rotation = Quaternion(0.7071068, -1.0424332e-06, -1.0424329e-06, 0.7071067)
bones/33/position = Vector3(0.010670463, 0.0010000349, -0.03166372)
bones/33/rotation = Quaternion(0.70755845, -7.1388774e-07, -1.0355643e-06, 0.7066547)
[node name="AnimationPlayer" parent="PigMannequin" index="1" unique_id=904091745]
libraries/custom = SubResource("AnimationLibrary_lvpc5")
[editable path="PigMannequin"]

Binary file not shown.

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@@ -1,5 +0,0 @@
[gd_scene format=3 uid="uid://b0xb7kl4rjd66"]
[ext_resource type="PackedScene" uid="uid://bi5f24frndw7j" path="res://core/ai/agents/pig/pig.fbx" id="1_ptg6h"]
[node name="PigMannequin" unique_id=926755470 instance=ExtResource("1_ptg6h")]

Binary file not shown.

View File

@@ -1,55 +0,0 @@
[gd_scene format=3 uid="uid://2md4l83fy8kr"]
[ext_resource type="PackedScene" uid="uid://clx701xdwelgx" path="res://core/ai/agents/base/ai_base.tscn" id="1_0bu1i"]
[ext_resource type="Script" uid="uid://d3hy70ec8vqo5" path="res://core/ai/framework/run_animation_state.gd" id="2_iapui"]
[ext_resource type="PackedScene" uid="uid://c16j3umhplew4" path="res://core/ai/agents/pug/pug_mannequin.tscn" id="2_n0mit"]
[ext_resource type="Animation" uid="uid://c8hy2tftqb7su" path="res://core/ai/agents/pug/idle.res" id="3_hv1px"]
[ext_resource type="Script" uid="uid://bngfthvt04ivv" path="res://core/ai/framework/patrol_state.gd" id="3_xc1yq"]
[ext_resource type="Animation" uid="uid://bqrhidcnublea" path="res://core/ai/agents/pug/walking.res" id="4_cjq2y"]
[sub_resource type="AnimationLibrary" id="AnimationLibrary_iapui"]
_data = {
&"idle": ExtResource("3_hv1px"),
&"walking": ExtResource("4_cjq2y")
}
[node name="AiPug" unique_id=1228675528 node_paths=PackedStringArray("anim_player") instance=ExtResource("1_0bu1i")]
anim_player = NodePath("PugMannequin/AnimationPlayer")
[node name="StateMachine" parent="." index="1" unique_id=1286404264 node_paths=PackedStringArray("initial_state")]
initial_state = NodePath("IdleState")
[node name="IdleState" type="Node" parent="StateMachine" index="0" unique_id=1079848975]
script = ExtResource("2_iapui")
state_id = &"idle"
next_state_id = &"patrol"
animation_name = "custom/idle"
[node name="PatrolState" type="Node" parent="StateMachine" index="1" unique_id=1573670396]
script = ExtResource("3_xc1yq")
state_id = &"patrol"
next_state_id = &"idle"
animation_name = "custom/walking"
exit_on_action_finished = true
[node name="PugMannequin" parent="." index="3" unique_id=1732134047 instance=ExtResource("2_n0mit")]
transform = Transform3D(0.2, 0, 0, 0, 0.2, 0, 0, 0, 0.2, 0, -0.9, 0)
[node name="Skeleton3D" parent="PugMannequin/Armature" parent_id_path=PackedInt32Array(1732134047, 199608791) index="0" unique_id=33809722]
bones/8/position = Vector3(-0.0054483665, 0.008346455, -0.020266803)
bones/8/rotation = Quaternion(-0.007561639, 0.007561228, 0.70706636, 0.70706636)
bones/9/rotation = Quaternion(0.6665347, -0.6790185, 0.20055033, -0.23333457)
bones/10/rotation = Quaternion(-0.37439552, 0.017943675, 0.007246467, 0.92706716)
bones/14/rotation = Quaternion(0.13296904, 0.051822018, -0.0069621373, 0.9897401)
bones/16/position = Vector3(0.0048320387, 0.008252437, -0.02027757)
bones/16/rotation = Quaternion(0.7070978, 0.7070978, -0.0035577225, 0.0035573125)
bones/17/rotation = Quaternion(0.20727697, 0.22687204, 0.66435784, 0.68131787)
bones/18/rotation = Quaternion(-0.38250104, -0.0087800585, -0.0036350952, 0.9239062)
bones/20/rotation = Quaternion(0.6013276, -0.007656022, 0.017799761, 0.79876757)
bones/24/rotation = Quaternion(-0.45064288, -0.22904137, 0.090387635, 0.858074)
bones/27/rotation = Quaternion(0.05229574, 5.703821e-05, -0.025155801, 0.99831474)
[node name="AnimationPlayer" parent="PugMannequin" index="1" unique_id=1653203922]
libraries/custom = SubResource("AnimationLibrary_iapui")
[editable path="PugMannequin"]

Binary file not shown.

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@@ -1,29 +0,0 @@
[gd_scene format=3 uid="uid://c16j3umhplew4"]
[ext_resource type="PackedScene" uid="uid://buqmw5lbfom07" path="res://core/ai/agents/pug/pug.fbx" id="1_3c2yk"]
[node name="PugMannequin" unique_id=1732134047 instance=ExtResource("1_3c2yk")]
[node name="Skeleton3D" parent="Armature" parent_id_path=PackedInt32Array(251322627) index="0" unique_id=1067550931]
bones/1/rotation = Quaternion(0.7071068, -8.7384586e-07, -8.7384575e-07, 0.7071067)
bones/3/position = Vector3(5.37765e-05, 0.023020823, -0.0001735416)
bones/4/rotation = Quaternion(0.0013124894, -0.0013127187, 0.7071056, 0.7071056)
bones/5/rotation = Quaternion(0.7071125, -0.70201516, -0.045116592, 0.07163183)
bones/6/rotation = Quaternion(0.13312602, -0.018813718, 0.0025276097, 0.9909174)
bones/8/rotation = Quaternion(0.0006567046, -0.0006571151, 0.7071065, 0.7071065)
bones/9/rotation = Quaternion(0.66675293, -0.67880416, 0.20062506, -0.23327015)
bones/10/rotation = Quaternion(-0.35678986, 0.01807761, 0.006905738, 0.9339843)
bones/12/rotation = Quaternion(0.70710534, 0.70710546, 0.0014091316, -0.0014093613)
bones/13/rotation = Quaternion(-0.021626502, -0.09508007, 0.7082199, 0.6992257)
bones/14/rotation = Quaternion(0.13296904, 0.051822014, -0.0069621364, 0.98974)
bones/16/rotation = Quaternion(0.7071066, 0.7071067, 0.00044525132, -0.00044566192)
bones/17/rotation = Quaternion(0.20738536, 0.2267729, 0.6646832, 0.6810004)
bones/18/rotation = Quaternion(-0.35684106, -0.008877046, -0.003391197, 0.93411684)
bones/20/rotation = Quaternion(0.6013276, -0.007656024, 0.017799761, 0.79876757)
bones/22/rotation = Quaternion(0.0076703057, 0.9327372, 0.3595561, -0.025732514)
bones/23/rotation = Quaternion(-0.089636706, -0.019697238, -0.01825219, 0.99561244)
bones/24/rotation = Quaternion(-0.44343108, -0.23039742, 0.11800072, 0.85811526)
bones/26/rotation = Quaternion(5.170388e-06, 0.6954638, 0.7185612, 5.0026606e-06)
bones/27/rotation = Quaternion(0.052304644, 0.00074447604, -0.01352817, 0.99853927)
bones/29/rotation = Quaternion(0.7071068, -9.581396e-07, -9.581394e-07, 0.7071067)
bones/31/rotation = Quaternion(0.7071068, -1.2110207e-06, -1.2110205e-06, 0.7071067)

Binary file not shown.

View File

@@ -1,44 +0,0 @@
[gd_scene format=3 uid="uid://bs1bdtm7jdtgb"]
[ext_resource type="PackedScene" uid="uid://clx701xdwelgx" path="res://core/ai/agents/base/ai_base.tscn" id="1_smbiq"]
[ext_resource type="PackedScene" uid="uid://58u6viv3qd63" path="res://core/ai/agents/sheep/sheep_mannequin.tscn" id="2_hnenk"]
[ext_resource type="Script" uid="uid://d3hy70ec8vqo5" path="res://core/ai/framework/run_animation_state.gd" id="2_vlyix"]
[ext_resource type="Animation" uid="uid://bjvoxmyf4vdy8" path="res://core/ai/agents/sheep/idle.res" id="3_i3d22"]
[ext_resource type="Script" uid="uid://bngfthvt04ivv" path="res://core/ai/framework/patrol_state.gd" id="3_uqv5v"]
[ext_resource type="Animation" uid="uid://8r05h8e7nmic" path="res://core/ai/agents/sheep/walking.res" id="4_hxh1r"]
[sub_resource type="AnimationLibrary" id="AnimationLibrary_vlyix"]
_data = {
&"idle": ExtResource("3_i3d22"),
&"walking": ExtResource("4_hxh1r")
}
[node name="AiSheep" unique_id=1228675528 node_paths=PackedStringArray("anim_player") instance=ExtResource("1_smbiq")]
anim_player = NodePath("SheepMannequin/AnimationPlayer")
[node name="StateMachine" parent="." index="1" unique_id=1286404264 node_paths=PackedStringArray("initial_state")]
initial_state = NodePath("IdleState")
[node name="IdleState" type="Node" parent="StateMachine" index="0" unique_id=190711451]
script = ExtResource("2_vlyix")
state_id = &"idle"
next_state_id = &"patrol"
animation_name = "custom/idle"
[node name="PatrolState" type="Node" parent="StateMachine" index="1" unique_id=431976868]
script = ExtResource("3_uqv5v")
state_id = &"patrol"
next_state_id = &"idle"
animation_name = "custom/walking"
exit_on_action_finished = true
[node name="SheepMannequin" parent="." index="3" unique_id=1153770042 instance=ExtResource("2_hnenk")]
transform = Transform3D(0.2, 0, 0, 0, 0.2, 0, 0, 0, 0.2, 0, -0.9, 0)
[node name="Armature" parent="SheepMannequin" index="0" unique_id=62421163]
transform = Transform3D(100, 0, 0, 0, -4.3711384e-06, 99.99999, 0, -99.99999, -4.3711384e-06, 0, 0, 0)
[node name="AnimationPlayer" parent="SheepMannequin" index="1" unique_id=676833932]
libraries/custom = SubResource("AnimationLibrary_vlyix")
[editable path="SheepMannequin"]

Binary file not shown.

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@@ -1,29 +0,0 @@
[gd_scene format=3 uid="uid://58u6viv3qd63"]
[ext_resource type="PackedScene" uid="uid://oog8biov508a" path="res://core/ai/agents/sheep/sheep.fbx" id="1_pnkxh"]
[node name="SheepMannequin" unique_id=1153770042 instance=ExtResource("1_pnkxh")]
[node name="Skeleton3D" parent="Armature" parent_id_path=PackedInt32Array(1644576745) index="0" unique_id=811031257]
bones/1/rotation = Quaternion(0.7071068, -7.052583e-07, -7.052583e-07, 0.7071067)
bones/4/rotation = Quaternion(0.0017592248, -0.0017595046, 0.7071046, 0.7071046)
bones/5/rotation = Quaternion(0.706397, -0.7005701, -0.057003256, 0.08339989)
bones/6/rotation = Quaternion(0.17354831, -0.018694565, 0.003295098, 0.98464245)
bones/8/rotation = Quaternion(0.0011415672, -0.0011422854, 0.7071059, 0.7071059)
bones/9/rotation = Quaternion(0.66940695, -0.67618734, 0.20153745, -0.23248184)
bones/10/rotation = Quaternion(-0.38440856, 0.017864142, 0.0074402345, 0.92296034)
bones/12/rotation = Quaternion(0.70710427, 0.7071044, 0.001866237, -0.0018665171)
bones/13/rotation = Quaternion(-0.033540055, -0.106803544, 0.7078988, 0.6973861)
bones/14/rotation = Quaternion(0.17334078, 0.051493812, -0.009075931, 0.9834729)
bones/16/rotation = Quaternion(0.70710605, 0.7071062, 0.0009843343, -0.0009850523)
bones/17/rotation = Quaternion(0.2082713, 0.22595985, 0.6673435, 0.67839366)
bones/18/rotation = Quaternion(-0.384463, -0.008772296, -0.0036537221, 0.92309153)
bones/20/rotation = Quaternion(0.6012591, 0.022893472, -0.005923484, 0.7987042)
bones/22/rotation = Quaternion(0.006586622, 0.9146406, 0.40345904, -0.02469813)
bones/23/rotation = Quaternion(0.07927493, -0.021147288, -0.014362239, 0.996525)
bones/24/rotation = Quaternion(-0.6495659, -0.19198355, 0.17329836, 0.71496445)
bones/26/rotation = Quaternion(3.4527793e-06, 0.6944211, 0.71956885, 3.3297817e-06)
bones/27/rotation = Quaternion(0.0651835, 0.0008379451, -0.017830681, 0.9977136)
bones/29/rotation = Quaternion(0.7071068, -7.052583e-07, -7.052583e-07, 0.7071067)
bones/31/rotation = Quaternion(0.7071068, -1.0424332e-06, -1.0424329e-06, 0.7071067)
bones/33/rotation = Quaternion(0.7071068, -1.0424332e-06, -1.0424329e-06, 0.7071067)

Binary file not shown.

View File

@@ -1,10 +0,0 @@
extends State
func enter() -> void:
super.enter()
run_animation()
agent.navigate_to_random_point()
func physics_update(_delta) -> void:
if agent.nav_agent.is_navigation_finished():
transitioned.emit(self, next_state_id)

View File

@@ -1 +0,0 @@
uid://bngfthvt04ivv

View File

@@ -1,6 +0,0 @@
extends State
func enter() -> void:
super.enter()
run_animation()

View File

@@ -1 +0,0 @@
uid://d3hy70ec8vqo5

View File

@@ -1,63 +0,0 @@
extends Node
class_name State
@export var state_id: StringName = &""
@export var next_state_id: StringName
@export var animation_name: String
@export var exit_on_action_finished: bool
@export var exit_on_animation_finished: bool
@export var min_wait_time: float = 3.0
@export var max_wait_time: float = 10
var runtime_timer: Timer
@onready var agent: AIBase = owner
signal transitioned(state: State, new_state_id: StringName)
func _ready() -> void:
if min_wait_time > 0 and !exit_on_action_finished:
runtime_timer = Timer.new()
runtime_timer.name = "IdleTimer"
runtime_timer.one_shot = true
add_child(runtime_timer)
runtime_timer.timeout.connect(_on_timer_timeout)
func enter() -> void:
if exit_on_animation_finished:
if not agent.anim_player.animation_finished.is_connected(_on_animation_finished):
agent.anim_player.animation_finished.connect(_on_animation_finished)
elif min_wait_time > 0 and !exit_on_action_finished:
var wait_time:= randf_range(min_wait_time, max_wait_time)
runtime_timer.start(wait_time)
func exit() -> void:
if exit_on_animation_finished and agent.anim_player.animation_finished.is_connected(_on_animation_finished):
agent.anim_player.animation_finished.disconnect(_on_animation_finished)
if runtime_timer and not runtime_timer.is_stopped():
runtime_timer.stop()
func update(_delta: float) -> void:
pass
func physics_update(_delta: float) -> void:
pass
func run_animation() -> void:
if agent.anim_player and agent.anim_player.has_animation(animation_name):
agent.anim_player.play(animation_name)
func _on_animation_finished(anim_name: StringName) -> void:
if animation_name == anim_name:
if exit_on_action_finished:
return
elif min_wait_time > 0:
var wait_time := randf_range(min_wait_time, max_wait_time)
runtime_timer.start(wait_time)
else:
transitioned.emit(self, next_state_id)
func _on_timer_timeout() -> void:
transitioned.emit(self, next_state_id)

View File

@@ -1 +0,0 @@
uid://dpso7abi5ftyw

View File

@@ -1,61 +0,0 @@
extends Node
class_name StateMachine
@export var initial_state: State
var current_state: State
var states: Dictionary[StringName, State] = {}
var is_initialized: bool = false
var _enabled: bool = true
var enable: bool:
set(value):
_enabled = value
_set_enabled(value)
get:
return _enabled
func _ready() -> void:
_initialize_states()
_set_enabled(enable)
func _initialize_states() -> void:
if is_initialized:
return
for state in get_children():
if state is State:
states[state.state_id] = state
state.transitioned.connect(_on_state_transition)
is_initialized = true
func _set_enabled(value: bool) -> void:
_enabled = value
if not _enabled:
return
_initialize_states()
if initial_state and current_state == null:
current_state = initial_state
current_state.enter()
func physics_process(delta) -> void:
if current_state and _enabled:
current_state.physics_update(delta)
func _on_state_transition(state: State, new_state_id: StringName) -> void:
if state != current_state:
return
var new_state = states.get(new_state_id)
if not new_state:
return
if current_state:
current_state.exit()
current_state = new_state
current_state.enter()

View File

@@ -1 +0,0 @@
uid://ps3vlu2qvmop

View File

@@ -1,34 +0,0 @@
extends Node
signal volume_changed(bus_name: StringName, linear_value: float)
const MIN_VOLUME: float = 0.0
const MAX_VOLUME: float = 1.0
func _ready() -> void:
load_save_data()
func load_save_data() -> void:
for bus_name in GameState.save_data.audio_bus_volumes:
_apply_audio_bus_volume(bus_name, GameState.save_data.audio_bus_volumes[bus_name])
func set_audio_bus_volume(bus_name: StringName, linear_value: float) -> void:
var normalized_bus_name := str(bus_name)
var clamped_value := clampf(linear_value, MIN_VOLUME, MAX_VOLUME)
GameState.save_data.audio_bus_volumes[normalized_bus_name] = clamped_value
_apply_audio_bus_volume(normalized_bus_name, clamped_value)
GameState.save_game()
volume_changed.emit(bus_name, clamped_value)
func get_audio_bus_volume(bus_name: StringName, default_value: float = 1.0) -> float:
return float(GameState.save_data.audio_bus_volumes.get(str(bus_name), default_value))
func _apply_audio_bus_volume(bus_name: String, linear_value: float) -> void:
var bus_index := AudioServer.get_bus_index(bus_name)
if bus_index == -1:
return
var clamped_value := clampf(linear_value, MIN_VOLUME, MAX_VOLUME)
AudioServer.set_bus_volume_db(bus_index, linear_to_db(clamped_value))
AudioServer.set_bus_mute(bus_index, is_zero_approx(clamped_value))

View File

@@ -1 +0,0 @@
uid://dcttbbavtwtsg

File diff suppressed because it is too large Load Diff

View File

@@ -2,9 +2,7 @@
[ext_resource type="Script" uid="uid://ct2k25kslaxe5" path="res://core/biome_generator/biome_generator.gd" id="1_c7ilo"] [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"] [ext_resource type="Material" uid="uid://b8p1sjxisi522" path="res://core/biome_generator/wires.tres" id="2_w42pm"]
[ext_resource type="Resource" path="res://core/biome_generator/railway_pool.tres" id="3_railway_pool"]
[node name="biome_generator" type="Node3D" unique_id=1861369341] [node name="biome_generator" type="Node3D" unique_id=1861369341]
script = ExtResource("1_c7ilo") script = ExtResource("1_c7ilo")
railway_pool = ExtResource("3_railway_pool")
lamppost_wire_material = ExtResource("2_w42pm") lamppost_wire_material = ExtResource("2_w42pm")

View File

@@ -5,7 +5,6 @@ class_name ChunkInfo
@export_group("Set Piece Rules (Unique pieces)") @export_group("Set Piece Rules (Unique pieces)")
@export var exclusive_biome: String = "" # Es: "Forest" @export var exclusive_biome: String = "" # Es: "Forest"
@export_range(0, 5, 1) var uniqueness: int = 0 #0=common; 5=unique
@export_group("Base exit") @export_group("Base exit")
@export var north: bool = false @export var north: bool = false
@@ -13,12 +12,6 @@ class_name ChunkInfo
@export var south: bool = false @export var south: bool = false
@export var west: 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_group("Margin heights (level 0, 1, 2)")
@export_range(0, 2, 1) var height_north: int = 0 @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_est: int = 0
@@ -36,17 +29,14 @@ func _ready() -> void:
func get_rotated_data(steps_90: int) -> Dictionary: func get_rotated_data(steps_90: int) -> Dictionary:
var original_exit = [north, est, south, west] 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 original_height = [height_north, height_est, height_south, height_west]
var calculated_exit = [] var calculated_exit = []
var calculated_river_exit = []
var calculated_height = [] var calculated_height = []
for i in range(4): for i in range(4):
var index = (i - steps_90 + 4) % 4 var index = (i - steps_90 + 4) % 4
calculated_exit.append(original_exit[index]) calculated_exit.append(original_exit[index])
calculated_river_exit.append(original_river_exit[index])
calculated_height.append(original_height[index]) calculated_height.append(original_height[index])
return { return {
@@ -54,10 +44,6 @@ func get_rotated_data(steps_90: int) -> Dictionary:
"north": calculated_exit[0], "est": calculated_exit[1], "north": calculated_exit[0], "est": calculated_exit[1],
"south": calculated_exit[2], "west": calculated_exit[3] "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": { "heights": {
"north": calculated_height[0], "est": calculated_height[1], "north": calculated_height[0], "est": calculated_height[1],
"south": calculated_height[2], "west": calculated_height[3] "south": calculated_height[2], "west": calculated_height[3]

View File

@@ -1,9 +0,0 @@
[gd_resource type="Resource" script_class="EntityPool" format=3 uid="uid://cmd6s6thq4f7r"]
[ext_resource type="PackedScene" uid="uid://clx701xdwelgx" path="res://core/ai/agents/base/ai_base.tscn" id="1_0kfj8"]
[ext_resource type="Script" uid="uid://53ryr0fsqiq7" path="res://core/biome_generator/entity_pool.gd" id="1_vccp2"]
[resource]
script = ExtResource("1_vccp2")
name = "Entity Pool"
available_entities = Array[PackedScene]([ExtResource("1_0kfj8")])

View File

@@ -1,5 +0,0 @@
extends Resource
class_name EntityPool
@export var name: String = "New Entity Pool"
@export var available_entities: Array[PackedScene] = []

View File

@@ -1 +0,0 @@
uid://53ryr0fsqiq7

View File

@@ -1,8 +0,0 @@
extends Marker3D
class_name EntitySpawnPoint
enum AllowedType { ANY, HUMANOID_ONLY, ANIMAL_ONLY }
@export var allowed_type: AllowedType = AllowedType.ANY
@export_range(0.0, 1.0, 0.01) var spawn_chance: float = 1.0
@export var random_y_rotation: bool = true

View File

@@ -1 +0,0 @@
uid://c5ercbqy7srx3

View File

@@ -1,5 +0,0 @@
extends Marker3D
class_name PropInfo
@export var available_props: Array[PackedScene]
@export_range(0, 5, 1) var uniqueness: int = 0 #0=common; 5=unique

View File

@@ -1 +0,0 @@
uid://dg6ngy4pmtsyc

View File

@@ -1,60 +1,31 @@
extends Path3D extends Path3D
@export_group("Train") @export_group("Train")
##train speed
@export var train_speed: float = 6.0 @export var train_speed: float = 6.0
##if true the train is in motion
@export var is_inmotion: bool = true @export var is_inmotion: bool = true
##the model for the locomotive
@export var train_model: PackedScene @export var train_model: PackedScene
##array of wagon scenes
@export var wagon_pool: Resource
##if true the number of wagons is random from 1 to wagon_count
@export var wagon_random_number: bool = true
##if wagon_random_number = true is used as max wagons
@export_range(0, 32, 1, "or_greater") var wagon_count: int = 3
##the distance between two wagons
@export var wagon_gap: float = 0.4
##the scale to calculate the distance of the bounds
@export_range(0.1, 2.0, 0.05, "or_greater") var wagon_spacing_scale: float = 0.5
##override spacing using this value
@export var wagon_spacing_override: float = 0.0
##distance of the rail axes
@export var axes_distance: float = 3.0 @export var axes_distance: float = 3.0
##discance between rails
@export var rail_distance: float = 1.2 @export var rail_distance: float = 1.2
##current camera
@export var cameras: Node3D @export var cameras: Node3D
##swing of the train during the ran
@export_range(0.0, 1.0) var basic_swing: float = 0.1 @export_range(0.0, 1.0) var basic_swing: float = 0.1
@export_group("Rails Bulding") @export_group("Rails Bulding")
##distance between sleepers of the rails
@export var sleepers_distance: float = 1.0 @export var sleepers_distance: float = 1.0
##nodel for the sleeper of the rail
@export var sleepers_model: PackedScene @export var sleepers_model: PackedScene
@export_group("Manual Controls") @export_group("Manual Controls")
##max speed
@export var speed_max: float = 15.0 @export var speed_max: float = 15.0
##min speed
@export var speed_min: float = -5.0 @export var speed_min: float = -5.0
##acceleration
@export var manual_acceleration: float = 5.0 @export var manual_acceleration: float = 5.0
@export_group("Train Stops") @export_group("Train Stops")
##if true the train stop the ran on stops
@export var enable_stops: bool = true @export var enable_stops: bool = true
##time of stop
@export var stop_time: float = 4.0 @export var stop_time: float = 4.0
##distance when the train start to brake
@export var brake_distance: float = 15.0 @export var brake_distance: float = 15.0
##restart time
@export var restart_time: float = 3.0 @export var restart_time: float = 3.0
##scene for fireworks
@export var fireworks_scene: PackedScene @export var fireworks_scene: PackedScene
##array of colors for fireworks
@export var fireworks_colors: Array[Color] = [ var fireworks_colors: Array[Color] = [
Color(1.0, 0.2, 0.2), # Rosso vivo Color(1.0, 0.2, 0.2), # Rosso vivo
Color(0.2, 1.0, 0.2), # Verde lime Color(0.2, 1.0, 0.2), # Verde lime
Color(0.3, 0.5, 1.0), # Blu cielo Color(0.3, 0.5, 1.0), # Blu cielo
@@ -76,119 +47,15 @@ var next_stop_index: int = 0
var stop_multiply: float = 1.0 var stop_multiply: float = 1.0
var is_restarting: bool = false var is_restarting: bool = false
var tween_restart: Tween var tween_restart: Tween
var environment_config: EnvironmentConfig
var wagon_instances: Array[Node3D] = []
var wagon_progress_offsets: Array[float] = []
func _ready() -> void: func _ready() -> void:
randomize()
_cache_environment_config()
if curve != null and curve.get_baked_length() > 0: if curve != null and curve.get_baked_length() > 0:
build_rails() build_rails()
build_train() build_train()
_plan_stops() _plan_stops()
_apply_initial_train_start()
else: else:
print("WARNING: Draw Path3D for rails!") 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
_snap_wagons_to_progress(total_length)
func build_rails() -> void: func build_rails() -> void:
var mat_wood = StandardMaterial3D.new() var mat_wood = StandardMaterial3D.new()
mat_wood.albedo_color = Color(0.35, 0.2, 0.1) mat_wood.albedo_color = Color(0.35, 0.2, 0.1)
@@ -360,8 +227,6 @@ func train_move(delta: float) -> void:
cameras.global_position = center_position cameras.global_position = center_position
cameras.global_basis = train_instance.global_basis cameras.global_basis = train_instance.global_basis
_snap_wagons_to_progress(total_length)
var real_speed = abs(train_speed * stop_multiply) var real_speed = abs(train_speed * stop_multiply)
var speed_factor = clamp(real_speed / max(speed_max, 0.001), 0.0, 1.0) 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_prev = (center_position - back_position).normalized()
@@ -439,34 +304,6 @@ func build_train() -> void:
else: else:
build_default_train() build_default_train()
var wagons = wagon_count
if wagon_random_number:
wagons = randi_range(1, wagon_count)
build_train_wagons(wagons)
func build_train_wagons(wagon_number: int) -> void:
_clear_train_wagons()
if wagon_number <= 0 or wagon_pool == null or not "available_wagons" in wagon_pool:
return
if wagon_pool.available_wagons.is_empty():
return
for i in range(wagon_number):
var wagon_scene: PackedScene = wagon_pool.available_wagons.pick_random()
if wagon_scene == null:
continue
var wagon: Node3D = wagon_scene.instantiate() as Node3D
if wagon == null:
push_warning("Wagon scene root must be a Node3D.")
continue
add_child(wagon)
wagon_instances.append(wagon)
_update_wagon_progress_offsets()
_snap_wagons_to_progress()
func build_default_train() -> void: func build_default_train() -> void:
train_instance = Node3D.new() train_instance = Node3D.new()
add_child(train_instance) add_child(train_instance)
@@ -501,118 +338,3 @@ func build_default_train() -> void:
stack.material_override = mat_body stack.material_override = mat_body
stack.position = Vector3(0, 1.2, 1.0) stack.position = Vector3(0, 1.2, 1.0)
train_instance.add_child(stack) train_instance.add_child(stack)
func _clear_train_wagons() -> void:
for wagon in wagon_instances:
if is_instance_valid(wagon):
wagon.queue_free()
wagon_instances.clear()
wagon_progress_offsets.clear()
func _update_wagon_progress_offsets() -> void:
wagon_progress_offsets.clear()
if train_instance == null or wagon_instances.is_empty():
return
var train_length: float = _get_vehicle_length(train_instance)
var previous_length: float = train_length
var accumulated_distance: float = 0.0
for wagon in wagon_instances:
var wagon_length: float = _get_vehicle_length(wagon)
accumulated_distance += _get_wagon_spacing(previous_length, wagon_length)
wagon_progress_offsets.append(accumulated_distance)
previous_length = wagon_length
func _get_wagon_spacing(previous_length: float, wagon_length: float) -> float:
if wagon_spacing_override > 0.0:
return wagon_spacing_override + wagon_gap
var detected_spacing: float = previous_length * 0.5 + wagon_length * 0.5
return detected_spacing * wagon_spacing_scale + wagon_gap
func _snap_wagons_to_progress(total_length: float = 0.0) -> void:
if curve == null or wagon_instances.is_empty():
return
if total_length <= 0.0:
total_length = curve.get_baked_length()
if total_length <= 0.0:
return
var direction: float = 1.0
if train_speed < 0.0:
direction = -1.0
for i in range(wagon_instances.size()):
var wagon: Node3D = wagon_instances[i]
if not is_instance_valid(wagon):
continue
var wagon_offset: float = float(i + 1) * 7.0
if i < wagon_progress_offsets.size():
wagon_offset = wagon_progress_offsets[i]
var wagon_progress: float = train_progress - direction * wagon_offset
_snap_vehicle_to_progress(wagon, wagon_progress, total_length)
func _snap_vehicle_to_progress(vehicle: Node3D, progress: float, total_length: float) -> void:
var vehicle_progress: float = wrapf(progress, 0.0, total_length)
var center_position: Vector3 = to_global(curve.sample_baked(vehicle_progress, true))
var prog_forward: float = wrapf(vehicle_progress + 2.0, 0.0, total_length)
var forward_position: Vector3 = to_global(curve.sample_baked(prog_forward, true))
vehicle.global_position = center_position
if center_position.distance_to(forward_position) > 0.01:
vehicle.look_at(forward_position, Vector3.UP)
vehicle.rotate_y(PI)
func _get_vehicle_length(vehicle: Node3D) -> float:
var bounds: AABB = _get_node_local_bounds(vehicle, vehicle)
if bounds.size == Vector3.ZERO:
return 7.0
return maxf(bounds.size.z, 0.1)
func _get_node_local_bounds(root: Node3D, node: Node) -> AABB:
var result: AABB = AABB()
var has_bounds: bool = false
var mesh_instance := node as MeshInstance3D
if mesh_instance != null and mesh_instance.mesh != null:
var mesh_bounds: AABB = mesh_instance.get_aabb()
var mesh_transform: Transform3D = root.global_transform.affine_inverse() * mesh_instance.global_transform
for corner in _get_aabb_corners(mesh_bounds):
var local_point: Vector3 = mesh_transform * corner
if has_bounds:
result = result.expand(local_point)
else:
result = AABB(local_point, Vector3.ZERO)
has_bounds = true
for child in node.get_children():
var child_bounds: AABB = _get_node_local_bounds(root, child)
if child_bounds.size == Vector3.ZERO:
continue
if has_bounds:
result = result.merge(child_bounds)
else:
result = child_bounds
has_bounds = true
return result
func _get_aabb_corners(bounds: AABB) -> Array[Vector3]:
var start: Vector3 = bounds.position
var end: Vector3 = bounds.end
return [
Vector3(start.x, start.y, start.z),
Vector3(end.x, start.y, start.z),
Vector3(start.x, end.y, start.z),
Vector3(end.x, end.y, start.z),
Vector3(start.x, start.y, end.z),
Vector3(end.x, start.y, end.z),
Vector3(start.x, end.y, end.z),
Vector3(end.x, end.y, end.z),
]

View File

@@ -1,5 +0,0 @@
extends Resource
class_name RailwayPool
@export var name: String = "New Railway Pool"
@export var available_railways: Array[PackedScene] = []

View File

@@ -1 +0,0 @@
uid://c374rv220mvh1

View File

@@ -1,16 +0,0 @@
[gd_resource type="Resource" script_class="RailwayPool" format=3 uid="uid://nrm040srfjwo"]
[ext_resource type="PackedScene" uid="uid://cl2ast2tk7ifw" path="res://tgcc/chunk/railway/scene/chunk_railway_curve.tscn" id="1_86h1y"]
[ext_resource type="PackedScene" uid="uid://85l80b6jcdhr" path="res://tgcc/chunk/railway/scene/chunk_railway_curve_2.tscn" id="2_r0882"]
[ext_resource type="PackedScene" uid="uid://cewdxvcpqb53f" path="res://tgcc/chunk/railway/scene/chunk_railway_station_doubleside.tscn" id="3_3auto"]
[ext_resource type="PackedScene" uid="uid://d3pcshw2bioic" path="res://tgcc/chunk/railway/scene/chunk_railway_station_oneside.tscn" id="4_i1umq"]
[ext_resource type="PackedScene" uid="uid://bqxpqhla2kogq" path="res://tgcc/chunk/railway/scene/chunk_railway_straight.tscn" id="5_x44at"]
[ext_resource type="PackedScene" uid="uid://c3ub6rj0tlt6q" path="res://tgcc/chunk/railway/scene/chunk_railway_straight_2.tscn" id="6_vrrkw"]
[ext_resource type="PackedScene" uid="uid://cqevecsd1cm1v" path="res://tgcc/chunk/railway/scene/chunk_railway_straight_3.tscn" id="7_l17bw"]
[ext_resource type="PackedScene" uid="uid://f53hfrjaxkwa" path="res://tgcc/chunk/railway/scene/chunk_railway_straight_bridge.tscn" id="8_qcl5o"]
[ext_resource type="Script" uid="uid://c374rv220mvh1" path="res://core/biome_generator/railway_pool.gd" id="9_8tdc7"]
[resource]
script = ExtResource("9_8tdc7")
name = "Railway Pool"
available_railways = Array[PackedScene]([ExtResource("1_86h1y"), ExtResource("2_r0882"), ExtResource("3_3auto"), ExtResource("4_i1umq"), ExtResource("5_x44at"), ExtResource("6_vrrkw"), ExtResource("7_l17bw"), ExtResource("8_qcl5o")])

View File

@@ -1,6 +0,0 @@
## Resource that lists the wagon scenes available for train composition.
class_name WagonPool
extends Resource
@export var name: String = "New Wagon Pool"
@export var available_wagons: Array[PackedScene] = []

View File

@@ -1,9 +0,0 @@
[gd_resource type="Resource" script_class="WagonPool" format=3 uid="uid://bjnytgwt8tmf4"]
[ext_resource type="PackedScene" uid="uid://dvk3bytqn3m5s" path="res://tgcc/train/main_train.tscn" id="1_t6q5r"]
[ext_resource type="Script" uid="uid://b6xk0gtn2pwa" path="res://core/biome_generator/wagon_pool.gd" id="2_x6bmc"]
[resource]
script = ExtResource("2_x6bmc")
name = "Wagon Pool"
available_wagons = Array[PackedScene]([ExtResource("1_t6q5r")])

View File

@@ -1,7 +0,0 @@
[gd_resource type="NoiseTexture2D" format=3 uid="uid://b2xcpt2y8v32x"]
[sub_resource type="FastNoiseLite" id="FastNoiseLite_oqwsk"]
[resource]
noise = SubResource("FastNoiseLite_oqwsk")
seamless = true

View File

@@ -1,17 +1,9 @@
shader_type canvas_item; shader_type canvas_item;
// Cattura tutto quello che c'è sotto questo nodo
uniform sampler2D screen_texture : hint_screen_texture, filter_linear_mipmap; uniform sampler2D screen_texture : hint_screen_texture, filter_linear_mipmap;
uniform float blur_amount : hint_range(0.0, 5.0) = 2.5; uniform float blur_amount : hint_range(0.0, 5.0) = 2.5;
uniform float focus_size : hint_range(0.0, 1.0) = 0.4;
uniform float transition_softness : hint_range(0.01, 1.0) = 0.3;
void fragment() { void fragment() {
float dist_from_center = abs(SCREEN_UV.y - 0.5); COLOR = textureLod(screen_texture, SCREEN_UV, blur_amount);
float mask = smoothstep(focus_size / 2.0, (focus_size / 2.0) + transition_softness, dist_from_center);
// Applica il blur
vec4 blurred_screen = textureLod(screen_texture, SCREEN_UV, blur_amount * mask);
COLOR = blurred_screen;
} }

View File

@@ -9,7 +9,6 @@
[ext_resource type="Material" uid="uid://codq5gx71rj4o" path="res://core/daynight/environment_dust_material.tres" id="8_amaf0"] [ext_resource type="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://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="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"] [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"] [sub_resource type="ShaderMaterial" id="ShaderMaterial_ruhh7"]
@@ -32,7 +31,6 @@ render_priority = 0
shader = ExtResource("2_r4tfj") shader = ExtResource("2_r4tfj")
shader_parameter/use_red_as_alpha = true shader_parameter/use_red_as_alpha = true
shader_parameter/fog_color = Color(0.8, 0.85, 0.9, 0.5) shader_parameter/fog_color = Color(0.8, 0.85, 0.9, 0.5)
shader_parameter/fog_density = 0.25
shader_parameter/scroll_speed = Vector2(0.05, 0.01) shader_parameter/scroll_speed = Vector2(0.05, 0.01)
shader_parameter/texture_scale = Vector2(1, 1) shader_parameter/texture_scale = Vector2(1, 1)
shader_parameter/edge_softness_y = 0.2 shader_parameter/edge_softness_y = 0.2
@@ -42,58 +40,9 @@ shader_parameter/sun_color = Color(0.2841828, 0.2023238, 0.27953526, 1)
[sub_resource type="Resource" id="Resource_r4tfj"] [sub_resource type="Resource" id="Resource_r4tfj"]
script = ExtResource("2_h6hjk") 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.9823975, 0.8034449, 0.8778439, 1)
fog_color_night = Color(0.38409987, 0.28720453, 0.5907528, 1)
fog_density_morning = 0.01
fog_density_afternoon = 0.02
glow_morning = 0.4
glow_night = 0.8
material_fog = SubResource("ShaderMaterial_b5atu") material_fog = SubResource("ShaderMaterial_b5atu")
material_drops = SubResource("StandardMaterial3D_r4tfj") material_drops = SubResource("StandardMaterial3D_r4tfj")
material_clouds = SubResource("ShaderMaterial_ruhh7") 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 = 30
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" metadata/_custom_type_script = "uid://butda6k2tli3o"
[sub_resource type="Gradient" id="Gradient_i3hjl"] [sub_resource type="Gradient" id="Gradient_i3hjl"]
@@ -136,7 +85,7 @@ gradient = SubResource("Gradient_djqkg")
lifetime_randomness = 0.5 lifetime_randomness = 0.5
emission_shape_scale = Vector3(5, 5, 5) emission_shape_scale = Vector3(5, 5, 5)
emission_shape = 3 emission_shape = 3
emission_box_extents = Vector3(1, 1, 1) emission_box_extents = Vector3(25, 5, 25)
direction = Vector3(0, 1, 0) direction = Vector3(0, 1, 0)
initial_velocity_min = 6.0 initial_velocity_min = 6.0
initial_velocity_max = 6.0 initial_velocity_max = 6.0
@@ -150,9 +99,10 @@ point_count = 3
[sub_resource type="ShaderMaterial" id="ShaderMaterial_cer0u"] [sub_resource type="ShaderMaterial" id="ShaderMaterial_cer0u"]
render_priority = 0 render_priority = 0
shader = ExtResource("5_djqkg") shader = ExtResource("5_djqkg")
shader_parameter/time_scale = 3.065 shader_parameter/wave_frequency = 1.0
shader_parameter/wave_amplitude = 0.3 shader_parameter/base_amplitude = 0.5
shader_parameter/wave_frequency = 0.25 shader_parameter/secondary_ratio = 0.6
shader_parameter/time_scale_base = 3.0
[sub_resource type="TubeTrailMesh" id="TubeTrailMesh_vo82p"] [sub_resource type="TubeTrailMesh" id="TubeTrailMesh_vo82p"]
material = SubResource("ShaderMaterial_cer0u") material = SubResource("ShaderMaterial_cer0u")
@@ -224,9 +174,7 @@ size = Vector2(0.05, 0.8)
[sub_resource type="ShaderMaterial" id="ShaderMaterial_kavln"] [sub_resource type="ShaderMaterial" id="ShaderMaterial_kavln"]
shader = ExtResource("9_amaf0") shader = ExtResource("9_amaf0")
shader_parameter/blur_amount = 0.50000002375 shader_parameter/blur_amount = 0.6000000285
shader_parameter/focus_size = 0.54400002584
shader_parameter/transition_softness = 0.00999999977648
[sub_resource type="QuadMesh" id="QuadMesh_sxgg7"] [sub_resource type="QuadMesh" id="QuadMesh_sxgg7"]
size = Vector2(2, 2) size = Vector2(2, 2)
@@ -236,12 +184,12 @@ noise = ExtResource("11_yn8v8")
seamless = true seamless = true
[sub_resource type="ShaderMaterial" id="ShaderMaterial_oqt1s"] [sub_resource type="ShaderMaterial" id="ShaderMaterial_oqt1s"]
render_priority = -1 render_priority = 0
shader = ExtResource("10_tuauy") shader = ExtResource("10_tuauy")
shader_parameter/noise_texture = SubResource("NoiseTexture2D_0fcg4") shader_parameter/noise_texture = SubResource("NoiseTexture2D_0fcg4")
shader_parameter/cloud_scale = 0.0070000003325 shader_parameter/cloud_scale = 0.0070000003325
shader_parameter/cloud_speed = 0.0030000001425 shader_parameter/cloud_speed = 0.0030000001425
shader_parameter/direction = Vector2(0.1, 0.025) shader_parameter/direction = Vector2(0.5, 0.2)
shader_parameter/sun_angle = Vector2(0.5, 0.5) shader_parameter/sun_angle = Vector2(0.5, 0.5)
shader_parameter/cloud_density = 0.400000019 shader_parameter/cloud_density = 0.400000019
shader_parameter/center_sharpness = 0.138000006555 shader_parameter/center_sharpness = 0.138000006555
@@ -253,24 +201,7 @@ shader_parameter/fade_end = 800.000035625
shader_parameter/height_fade_start = 10.0 shader_parameter/height_fade_start = 10.0
shader_parameter/height_fade_end = 50.0 shader_parameter/height_fade_end = 50.0
[sub_resource type="QuadMesh" id="QuadMesh_yn8v8"] [node name="EnvironmentManager" type="Node3D" unique_id=1611939731 node_paths=PackedStringArray("particles_wind", "particles_snow", "particles_fireflies", "particles_rain", "environment_dust", "blur", "environment_shadows")]
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/fog_density = 0.25
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") script = ExtResource("1_wecen")
environment_config = SubResource("Resource_r4tfj") environment_config = SubResource("Resource_r4tfj")
particles_wind = NodePath("Particles_Wind") particles_wind = NodePath("Particles_Wind")
@@ -281,7 +212,6 @@ godray = ExtResource("5_411rw")
environment_dust = NodePath("EnvironmentDust") environment_dust = NodePath("EnvironmentDust")
blur = NodePath("Blur") blur = NodePath("Blur")
environment_shadows = NodePath("EnvironmentCloudsShadows") environment_shadows = NodePath("EnvironmentCloudsShadows")
fog = NodePath("Fog")
[node name="Particles_Fireflies" type="GPUParticles3D" parent="." unique_id=947538133] [node name="Particles_Fireflies" type="GPUParticles3D" parent="." unique_id=947538133]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2, 0) transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2, 0)
@@ -292,10 +222,9 @@ process_material = SubResource("ParticleProcessMaterial_i3hjl")
draw_pass_1 = SubResource("QuadMesh_b5atu") draw_pass_1 = SubResource("QuadMesh_b5atu")
[node name="Particles_Wind" type="GPUParticles3D" parent="." unique_id=1238214694] [node name="Particles_Wind" type="GPUParticles3D" parent="." unique_id=1238214694]
transform = Transform3D(1, 0, 0, 0, -4.371139e-08, -1, 0, 1, -4.371139e-08, 0, 50, 0) transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 50, 0)
cast_shadow = 0
emitting = false emitting = false
amount = 25 amount = 100
lifetime = 3.0 lifetime = 3.0
fixed_fps = 60 fixed_fps = 60
process_material = SubResource("ParticleProcessMaterial_ruhh7") process_material = SubResource("ParticleProcessMaterial_ruhh7")
@@ -342,15 +271,3 @@ mouse_filter = 2
extra_cull_margin = 16384.0 extra_cull_margin = 16384.0
mesh = SubResource("QuadMesh_sxgg7") mesh = SubResource("QuadMesh_sxgg7")
surface_material_override/0 = SubResource("ShaderMaterial_oqt1s") surface_material_override/0 = SubResource("ShaderMaterial_oqt1s")
[node name="Fog" type="Node3D" parent="." unique_id=1626352238]
[node name="MeshInstance3D" type="MeshInstance3D" parent="Fog" unique_id=96635311]
transform = Transform3D(-42.075005, 7.553328e-06, 1.7196172e-13, 0, -3.7766642e-06, 45, 3.6783138e-06, 86.4, 1.9670128e-06, -41.926987, 14, 0)
mesh = SubResource("QuadMesh_yn8v8")
surface_material_override/0 = SubResource("ShaderMaterial_sxgg7")
[node name="MeshInstance3D2" type="MeshInstance3D" parent="Fog" unique_id=10121049]
transform = Transform3D(-42.075005, 7.553328e-06, 1.7196172e-13, 0, -3.7766642e-06, 45, 3.6783138e-06, 86.4, 1.9670128e-06, 59.320038, 14, 0)
mesh = SubResource("QuadMesh_yn8v8")
surface_material_override/0 = SubResource("ShaderMaterial_sxgg7")

View File

@@ -1,10 +1,6 @@
class_name EnvironmentManagerRoot class_name EnvironmentManagerRoot
extends Node3D extends Node3D
const NOISE_TEXTURE: Texture2D = preload("res://core/daynight/noise.tres")
const WEATHER_SHADER: Material = preload("res://core/daynight/weather_overlay.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 var environment_config: EnvironmentConfig
@export_group("Camera") @export_group("Camera")
@@ -20,7 +16,6 @@ const DYNAMIC_ENVIRONMENT_UPDATES_PER_FRAME: int = 2 #how many update of the env
@export var environment_dust: ColorRect @export var environment_dust: ColorRect
@export var blur: ColorRect @export var blur: ColorRect
@export var environment_shadows: MeshInstance3D @export var environment_shadows: MeshInstance3D
@export var fog: Node3D
@export_group("Sound") @export_group("Sound")
@export var thunder_sounds: Array[AudioStream] @export var thunder_sounds: Array[AudioStream]
@@ -35,13 +30,9 @@ var weather_controller: WeatherController
var day_tween: Tween var day_tween: Tween
var day_time: float = 0.0 var day_time: float = 0.0
var pending_environment_nodes: Dictionary = {}
func _ready() -> void: 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 #set noise texture 2d to materials in special group
ApplyWindNoiseToMaterials() ApplyWindNoiseToMaterials()
#set weather overlay (snow + rain) to materials in special group #set weather overlay (snow + rain) to materials in special group
@@ -64,7 +55,6 @@ func _ready() -> void:
godray, godray,
environment_dust, environment_dust,
blur, blur,
fog,
environment_shadows, environment_shadows,
sun, sun,
environment, environment,
@@ -77,67 +67,10 @@ func _ready() -> void:
weather_controller.name = "WeatherController" weather_controller.name = "WeatherController"
add_child(weather_controller) add_child(weather_controller)
func _process(_delta: float) -> void:
_process_pending_environment_nodes()
func _on_tree_node_added(node: Node) -> void:
if node.is_in_group("wind_node") or node.is_in_group("weather_node") or node.is_in_group("weather_vegetables_node"):
_queue_dynamic_environment_node(node)
func _queue_dynamic_environment_node(node: Node) -> void:
if not is_instance_valid(node):
return
var ancestor = node.get_parent()
while ancestor != null:
if pending_environment_nodes.has(ancestor.get_instance_id()):
return
ancestor = ancestor.get_parent()
var stale_ids: Array[int] = []
for node_id in pending_environment_nodes.keys():
var pending_node = pending_environment_nodes[node_id]
if not is_instance_valid(pending_node):
stale_ids.append(node_id)
continue
if node.is_ancestor_of(pending_node):
stale_ids.append(node_id)
for node_id in stale_ids:
pending_environment_nodes.erase(node_id)
pending_environment_nodes[node.get_instance_id()] = node
func _process_pending_environment_nodes() -> void:
var processed = 0
for node_id in pending_environment_nodes.keys():
if processed >= DYNAMIC_ENVIRONMENT_UPDATES_PER_FRAME:
break
var node = pending_environment_nodes[node_id]
pending_environment_nodes.erase(node_id)
if not is_instance_valid(node):
continue
_apply_dynamic_environment_materials(node)
processed += 1
func _apply_dynamic_environment_materials(node: Node) -> void:
if not is_instance_valid(node):
return
if node.is_in_group("wind_node"):
_apply_wind_noise_to_node(node, NOISE_TEXTURE)
if node.is_in_group("weather_node"):
_apply_weather_overlay_to_node(node, WEATHER_SHADER)
if node.is_in_group("weather_vegetables_node"):
_clear_weather_overlay_from_node(node)
func ApplyWindNoiseToMaterials(): func ApplyWindNoiseToMaterials():
var noise_tex = preload("res://core/daynight/noise.tres")
for node in get_tree().get_nodes_in_group("wind_node"): for node in get_tree().get_nodes_in_group("wind_node"):
_apply_wind_noise_to_node(node, NOISE_TEXTURE) _apply_wind_noise_to_node(node, noise_tex)
func _apply_wind_noise_to_node(node: Node, noise_tex: Texture2D) -> void: func _apply_wind_noise_to_node(node: Node, noise_tex: Texture2D) -> void:
if node is GeometryInstance3D: if node is GeometryInstance3D:
@@ -155,57 +88,25 @@ func _apply_wind_noise_to_node(node: Node, noise_tex: Texture2D) -> void:
_apply_wind_noise_to_node(child, noise_tex) _apply_wind_noise_to_node(child, noise_tex)
func ApplyWeatherShaderToMaterials(): func ApplyWeatherShaderToMaterials():
var weather_shader = preload("res://core/daynight/weather_overlay.tres")
for node in get_tree().get_nodes_in_group("weather_node"): for node in get_tree().get_nodes_in_group("weather_node"):
_apply_weather_overlay_to_node(node, WEATHER_SHADER)
for node in get_tree().get_nodes_in_group("weather_vegetables_node"):
_clear_weather_overlay_from_node(node)
func _apply_weather_overlay_to_node(node: Node, material: Material) -> void:
if node.is_in_group("weather_vegetables_node"):
_clear_weather_overlay_from_node(node)
return
if node is GeometryInstance3D: if node is GeometryInstance3D:
if _geometry_uses_alpha_texture(node): node.material_overlay = weather_shader
node.material_overlay = null
else: else:
node.material_overlay = material
for child in node.get_children(): for child in node.get_children():
_apply_weather_overlay_to_node(child, material) if child is GeometryInstance3D:
child.material_overlay = weather_shader
break
func _clear_weather_overlay_from_node(node: Node) -> void: var weather_plain_shader = preload("res://core/daynight/weather_plain_shader.tres")
for node in get_tree().get_nodes_in_group("weather_vegetables_node"):
if node is GeometryInstance3D: if node is GeometryInstance3D:
node.material_overlay = null node.material_overlay = weather_plain_shader
else:
for child in node.get_children(): for child in node.get_children():
_clear_weather_overlay_from_node(child) if child is GeometryInstance3D:
child.material_overlay = weather_plain_shader
func _geometry_uses_alpha_texture(node: GeometryInstance3D) -> bool: break
var material_override := node.material_override as ShaderMaterial
if _shader_material_uses_alpha_texture(material_override):
return true
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 _shader_material_uses_alpha_texture(surface_material):
return true
if node.mesh:
for surface_index in node.mesh.get_surface_count():
var mesh_material := node.mesh.surface_get_material(surface_index) as ShaderMaterial
if _shader_material_uses_alpha_texture(mesh_material):
return true
return false
func _shader_material_uses_alpha_texture(material: ShaderMaterial) -> bool:
if material == null or material.shader == null:
return false
return material.shader.code.find("alpha_texture") != -1
func select_day_time(normalized_time: float) -> void: func select_day_time(normalized_time: float) -> void:
#set show_day_time_debug = true to show debug on screen #set show_day_time_debug = true to show debug on screen

View File

@@ -67,6 +67,7 @@ void fragment() {
float is_center = step(center_sharpness, internal_n); float is_center = step(center_sharpness, internal_n);
ALBEDO = shadow_color; ALBEDO = shadow_color;
ALPHA = mix(opacity_edge, opacity_center, is_center) * final_fade; ALPHA = mix(opacity_edge, opacity_center, is_center) * final_fade;
} }
} }

View File

@@ -7,7 +7,6 @@ uniform bool use_red_as_alpha = true;
group_uniforms Settings; group_uniforms Settings;
uniform vec4 fog_color : source_color = vec4(0.8, 0.85, 0.9, 0.5); uniform vec4 fog_color : source_color = vec4(0.8, 0.85, 0.9, 0.5);
uniform float fog_density : hint_range(0.0, 1.0) = 0.25;
uniform vec2 scroll_speed = vec2(0.05, 0.01); uniform vec2 scroll_speed = vec2(0.05, 0.01);
uniform vec2 texture_scale = vec2(1.0, 1.0); uniform vec2 texture_scale = vec2(1.0, 1.0);
@@ -37,5 +36,5 @@ void fragment() {
vec3 dark_fog = tinted_fog * 0.5; vec3 dark_fog = tinted_fog * 0.5;
ALBEDO = mix(tinted_fog, dark_fog, night_intensity); ALBEDO = mix(tinted_fog, dark_fog, night_intensity);
ALPHA = fog_color.a * fog_density * noise_alpha * edge_mask; ALPHA = fog_color.a * noise_alpha * edge_mask;
} }

View File

@@ -8,12 +8,10 @@ global uniform float global_wind_speed;
global uniform float global_wind_strength; global uniform float global_wind_strength;
global uniform vec2 global_wind_direction; global uniform vec2 global_wind_direction;
//global uniform sampler2D global_wind_noise : filter_linear_mipmap; //global uniform sampler2D global_wind_noise : filter_linear_mipmap;
global uniform float global_snow_start_time = -1.0; global uniform float global_snow_start_time;
global uniform float global_snow_accumulation_speed = 0.005; global uniform float global_snow_accumulation_speed;
global uniform float global_snow_melt_time = -1.0; global uniform float global_snow_melt_time;
global uniform float global_snow_melt_speed = 0.1; global uniform float global_snow_melt_speed;
global uniform float global_snow_amount = 0.0;
global uniform float global_rain_intensity;
// --- PARAMETRI ESTETICI --- // --- PARAMETRI ESTETICI ---
uniform bool billboard_enabled = true; uniform bool billboard_enabled = true;
@@ -33,7 +31,6 @@ uniform vec4 variance_color : source_color = vec4(0.3, 0.5, 0.2, 1.0); // Colore
uniform float variance_intensity : hint_range(0.0, 1.0) = 0.4; // Quanto si vedono le chiazze 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); uniform vec4 snow_color : source_color = vec4(0.85, 0.9, 0.95, 1.0);
uniform float snow_visibility : hint_range(0.0, 1.0) = 1.0;
// --- CONTROLLO GRADIENTE E RANDOM --- // --- CONTROLLO GRADIENTE E RANDOM ---
uniform float height_min = 0.0; uniform float height_min = 0.0;
@@ -44,7 +41,6 @@ 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 random_mix : hint_range(0.0, 1.0) = 0.3;
uniform float cast_shadow_strength : hint_range(0.0, 1.0) = 0.6; uniform float cast_shadow_strength : hint_range(0.0, 1.0) = 0.6;
uniform float wetness_darkening : hint_range(0.0, 0.5) = 0.25;
varying vec3 v_final_color; varying vec3 v_final_color;
varying float v_shade_factor; varying float v_shade_factor;
@@ -56,21 +52,6 @@ float hash(vec3 p) {
return fract((p.x + p.y) * p.z); return fract((p.x + p.y) * p.z);
} }
float get_snow_progress() {
float snow_progress = clamp(global_snow_amount, 0.0, 1.0);
if (global_snow_start_time >= 0.0) {
float timed_progress = clamp((TIME - global_snow_start_time) * global_snow_accumulation_speed, 0.0, 1.0);
snow_progress = max(snow_progress, timed_progress);
}
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 = min(snow_progress, 1.0 - melt);
}
return snow_progress;
}
void vertex() { void vertex() {
vec3 instance_pos = MODEL_MATRIX[3].xyz; vec3 instance_pos = MODEL_MATRIX[3].xyz;
v_world_pos = instance_pos; // Salviamo la posizione dell'istanza v_world_pos = instance_pos; // Salviamo la posizione dell'istanza
@@ -132,10 +113,17 @@ void fragment() {
// Applichiamo la variazione al colore finale dell'erba // Applichiamo la variazione al colore finale dell'erba
vec3 varied_grass_color = mix(v_final_color, variance_color.rgb, noise_sample * variance_intensity); vec3 varied_grass_color = mix(v_final_color, variance_color.rgb, noise_sample * variance_intensity);
float snow_amount = smoothstep(0.0, 1.0, get_snow_progress()); 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 top_mask = 1.0 - shifted_uv.y;
float snow_mask = smoothstep(0.65, 1.0, top_mask) * snow_amount * snow_visibility; float snow_mask = smoothstep(1.0 - snow_amount, 1.2 - snow_amount, top_mask);
snow_mask *= step(0.01, snow_amount); snow_mask *= step(0.01, snow_amount);
vec3 dark_snow = snow_color.rgb * (1.0 - shadow_intensity); vec3 dark_snow = snow_color.rgb * (1.0 - shadow_intensity);
@@ -143,15 +131,12 @@ void fragment() {
// Mescoliamo il colore variato con la neve // Mescoliamo il colore variato con la neve
vec3 final_albedo = mix(varied_grass_color, shaded_snow, snow_mask); vec3 final_albedo = mix(varied_grass_color, shaded_snow, snow_mask);
float rain_int = clamp(global_rain_intensity, 0.0, 1.0);
final_albedo *= mix(1.0, 1.0 - wetness_darkening, rain_int);
float final_roughness = mix(0.02, 0.005, rain_int);
ALBEDO = final_albedo; ALBEDO = final_albedo;
ALPHA = tex.r * opacity; ALPHA = tex.r * opacity;
ALPHA_SCISSOR_THRESHOLD = 0.5; ALPHA_SCISSOR_THRESHOLD = 0.5;
ROUGHNESS = final_roughness; ROUGHNESS = 0.02;
} }
void light() { void light() {

View File

@@ -1,107 +0,0 @@
## Procedural snow cap geometry for flat roofs and vehicles.
extends Node3D
enum PlacementMode {
AUTO_TARGET_AABB,
MANUAL_SURFACE,
}
const SNOW_CAP_SHADER: Shader = preload("res://core/daynight/snow_cap.gdshader")
@export var placement_mode: PlacementMode = PlacementMode.AUTO_TARGET_AABB
@export var target_path: NodePath
@export var size_inset: Vector2 = Vector2(0.25, 1.0)
@export var position_offset: Vector3 = Vector3(0.0, -0.08, 0.0)
@export var max_snow_height: float = 0.2
@export_range(1, 24) var subdivide_width: int = 6
@export_range(1, 24) var subdivide_depth: int = 18
@export var manual_surface_center: Vector3 = Vector3.ZERO
@export var manual_surface_size: Vector2 = Vector2(2.0, 6.0)
var _mesh_instance: MeshInstance3D
func _ready() -> void:
add_to_group("weather_overlay_ignore")
_ensure_mesh_instance()
_rebuild()
func rebuild() -> void:
_rebuild()
func _ensure_mesh_instance() -> void:
_mesh_instance = get_node_or_null("SnowCapMesh") as MeshInstance3D
if _mesh_instance != null:
return
_mesh_instance = MeshInstance3D.new()
_mesh_instance.name = "SnowCapMesh"
_mesh_instance.add_to_group("weather_overlay_ignore")
add_child(_mesh_instance)
func _rebuild() -> void:
var cap_width: float = 0.0
var cap_depth: float = 0.0
var cap_surface_center := Vector3.ZERO
if placement_mode == PlacementMode.MANUAL_SURFACE:
cap_width = manual_surface_size.x
cap_depth = manual_surface_size.y
cap_surface_center = manual_surface_center
else:
var target_mesh: MeshInstance3D = get_node_or_null(target_path) as MeshInstance3D
if target_mesh == null:
if _mesh_instance:
_mesh_instance.visible = false
return
var target_aabb: AABB = _get_target_aabb(target_mesh)
cap_width = max(target_aabb.size.x - size_inset.x, 0.1)
cap_depth = max(target_aabb.size.z - size_inset.y, 0.1)
cap_surface_center = Vector3(
target_aabb.position.x + target_aabb.size.x * 0.5,
target_aabb.position.y + target_aabb.size.y,
target_aabb.position.z + target_aabb.size.z * 0.5
)
var cap_center := cap_surface_center + Vector3(0.0, max_snow_height * 0.5, 0.0)
var box_mesh := BoxMesh.new()
box_mesh.size = Vector3(cap_width, max_snow_height, cap_depth)
box_mesh.subdivide_width = subdivide_width
box_mesh.subdivide_depth = subdivide_depth
_mesh_instance.mesh = box_mesh
_mesh_instance.position = cap_center + position_offset
_mesh_instance.material_override = _build_material(cap_width, cap_depth)
_mesh_instance.visible = true
func _build_material(cap_width: float, cap_depth: float) -> ShaderMaterial:
var material := ShaderMaterial.new()
material.shader = SNOW_CAP_SHADER
material.set_shader_parameter("max_height", max_snow_height)
material.set_shader_parameter("half_width", cap_width * 0.5)
material.set_shader_parameter("half_depth", cap_depth * 0.5)
return material
func _get_target_aabb(target_mesh: MeshInstance3D) -> AABB:
var points: Array[Vector3] = []
for point in _get_aabb_points(target_mesh.get_aabb()):
points.append(target_mesh.transform * point)
var merged := AABB(points[0], Vector3.ZERO)
for point in points:
merged = merged.expand(point)
return merged
func _get_aabb_points(aabb: AABB) -> Array[Vector3]:
var p: Vector3 = aabb.position
var s: Vector3 = aabb.size
return [
p,
p + Vector3(s.x, 0.0, 0.0),
p + Vector3(0.0, s.y, 0.0),
p + Vector3(0.0, 0.0, s.z),
p + Vector3(s.x, s.y, 0.0),
p + Vector3(s.x, 0.0, s.z),
p + Vector3(0.0, s.y, s.z),
p + s,
]

View File

@@ -1 +0,0 @@
uid://bxc6ketfgedxw

View File

@@ -1,116 +0,0 @@
shader_type spatial;
render_mode blend_mix, cull_back, depth_draw_opaque;
global uniform float global_snow_start_time = -1.0;
global uniform float global_snow_accumulation_speed = 0.005;
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 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 = clamp(global_snow_amount, 0.0, 1.0);
if (global_snow_start_time >= 0.0) {
float timed_amount = clamp(
(TIME - global_snow_start_time) * global_snow_accumulation_speed,
0.0,
1.0
);
snow_amount = max(snow_amount, timed_amount);
}
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 = min(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);
}
}

View File

@@ -1 +0,0 @@
uid://c7js7ytvewmab

View File

@@ -6,12 +6,12 @@ global uniform vec2 global_wind_direction;
global uniform float global_wind_scale; global uniform float global_wind_scale;
global uniform float global_wind_strength; global uniform float global_wind_strength;
global uniform float global_wind_fade; global uniform float global_wind_fade;
global uniform float global_snow_start_time = -1.0; /*
global uniform float global_snow_accumulation_speed = 0.005; global uniform float global_snow_start_time;
global uniform float global_snow_melt_time = -1.0; global uniform float global_snow_accumulation_speed;
global uniform float global_snow_melt_speed = 0.1; global uniform float global_snow_melt_time;
global uniform float global_snow_amount = 0.0; 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; global uniform float global_rain_intensity;
uniform sampler2D wind_noise : filter_linear_mipmap; uniform sampler2D wind_noise : filter_linear_mipmap;
@@ -31,7 +31,6 @@ 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 random_mix : hint_range(0.0, 1.0) = 0.3;
uniform float cast_shadow_strength : hint_range(0.0, 1.0) = 0.6; uniform float cast_shadow_strength : hint_range(0.0, 1.0) = 0.6;
uniform float wetness_darkening : hint_range(0.0, 0.5) = 0.25; uniform float wetness_darkening : hint_range(0.0, 0.5) = 0.25;
uniform float snow_visibility : hint_range(0.0, 1.0) = 1.0;
varying vec3 v_final_color; varying vec3 v_final_color;
varying float v_shade_factor; varying float v_shade_factor;
@@ -42,21 +41,6 @@ float hash(vec3 p) {
return fract((p.x + p.y) * p.z); return fract((p.x + p.y) * p.z);
} }
float get_snow_progress() {
float snow_progress = clamp(global_snow_amount, 0.0, 1.0);
if (global_snow_start_time >= 0.0) {
float timed_progress = clamp((TIME - global_snow_start_time) * global_snow_accumulation_speed, 0.0, 1.0);
snow_progress = max(snow_progress, timed_progress);
}
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 = min(snow_progress, 1.0 - melt);
}
return snow_progress;
}
void vertex() { void vertex() {
vec3 instance_pos = MODEL_MATRIX[3].xyz; vec3 instance_pos = MODEL_MATRIX[3].xyz;
@@ -104,16 +88,24 @@ void fragment() {
vec2 shifted_uv = UV + texture_offset; vec2 shifted_uv = UV + texture_offset;
vec4 tex = texture(alpha_texture, shifted_uv); vec4 tex = texture(alpha_texture, shifted_uv);
// Snow accumulation //// Snow accumulation
float snow_amount = pow(get_snow_progress(), 0.55); //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);
float top_mask = 1.0 - shifted_uv.y; //vec3 dark_snow = global_snow_color.rgb * (1.0 - shadow_intensity);
float snow_mask = smoothstep(1.0 - snow_amount * 1.35, 1.08 - snow_amount * 1.35, top_mask) * snow_visibility; //vec3 shaded_snow = mix(dark_snow, global_snow_color.rgb, v_shade_factor);
snow_mask *= step(0.01, snow_amount); //vec3 final_albedo = mix(v_final_color, shaded_snow, snow_mask);
vec3 final_albedo = v_final_color;
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);
// Rain wetness: darken and make shinier // Rain wetness: darken and make shinier
float rain_int = clamp(global_rain_intensity, 0.0, 1.0); float rain_int = clamp(global_rain_intensity, 0.0, 1.0);

View File

@@ -2,13 +2,6 @@ shader_type spatial;
render_mode blend_mix, depth_draw_always; render_mode blend_mix, depth_draw_always;
global uniform float global_rain_intensity; global uniform float global_rain_intensity;
global uniform vec4 global_water_color = vec4(0.285, 0.534, 0.487, 1.0);
global uniform float global_snow_start_time = -1.0;
global uniform float global_snow_accumulation_speed = 0.005;
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 vec4 global_snow_color = vec4(0.92, 0.96, 1.0, 1.0);
//Water color //Water color
uniform vec4 deep_water_color : source_color = vec4(0.0, 0.1, 0.2, 1.0); uniform vec4 deep_water_color : source_color = vec4(0.0, 0.1, 0.2, 1.0);
@@ -35,21 +28,6 @@ uniform sampler2D depth_texture : hint_depth_texture, filter_linear_mipmap;
varying vec2 world_pos_xz; varying vec2 world_pos_xz;
varying vec2 local_uv; varying vec2 local_uv;
float get_snow_progress() {
float snow_progress = clamp(global_snow_amount, 0.0, 1.0);
if (global_snow_start_time >= 0.0) {
float timed_progress = clamp((TIME - global_snow_start_time) * global_snow_accumulation_speed, 0.0, 1.0);
snow_progress = max(snow_progress, timed_progress);
}
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 = min(snow_progress, 1.0 - melt);
}
return snow_progress;
}
void vertex() { void vertex() {
world_pos_xz = (MODEL_MATRIX * vec4(VERTEX, 1.0)).xz; world_pos_xz = (MODEL_MATRIX * vec4(VERTEX, 1.0)).xz;
local_uv = UV; local_uv = UV;
@@ -66,14 +44,12 @@ void fragment() {
float water_depth_gradient = exp(-depth_difference * beer_law_factor); float water_depth_gradient = exp(-depth_difference * beer_law_factor);
vec4 base_water = mix(deep_water_color, shallow_water_color, water_depth_gradient); vec4 base_water = mix(deep_water_color, shallow_water_color, water_depth_gradient);
float rain_intensity = clamp(global_rain_intensity, 0.0, 1.0); 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 pos = world_pos_xz * ripple_scale;
vec2 cell = floor(pos); vec2 cell = floor(pos);
vec2 local_pos = fract(pos) - 0.5; vec2 local_pos = fract(pos) - 0.5;
float random_val = fract(sin(dot(cell, vec2(12.9898, 78.233))) * 43758.5453); 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 - ripple_density, random_val);
float is_active_cell = step(1.0 - active_ripple_density, random_val);
float ring = 0.0; float ring = 0.0;
if (is_active_cell > 0.0) { if (is_active_cell > 0.0) {
@@ -103,15 +79,8 @@ void fragment() {
float is_sky = step(ref_depth_raw, 0.00001); // Protezione anti-cielo float is_sky = step(ref_depth_raw, 0.00001); // Protezione anti-cielo
reflection_mask *= (1.0 - is_sky); reflection_mask *= (1.0 - is_sky);
float snow_progress = get_snow_progress(); vec3 final_rgb = mix(base_water.rgb, screen_ref, reflection_strength * reflection_mask);
float active_snowfall = step(0.0, global_snow_start_time) * (1.0 - step(0.0, global_snow_melt_time));
float reflection_snow_damping = max(smoothstep(0.0, 0.08, snow_progress), active_snowfall * 0.75);
float effective_reflection_strength = reflection_strength * (1.0 - reflection_snow_damping * 0.85);
vec3 final_rgb = mix(base_water.rgb, screen_ref, effective_reflection_strength * reflection_mask);
final_rgb = mix(final_rgb, ripple_color.rgb, ring * ripple_color.a); final_rgb = mix(final_rgb, ripple_color.rgb, ring * ripple_color.a);
float water_snow_amount = smoothstep(0.15, 1.0, snow_progress) * 0.18;
final_rgb = mix(final_rgb, global_snow_color.rgb, water_snow_amount);
ALBEDO = final_rgb; ALBEDO = final_rgb;

View File

@@ -1,241 +0,0 @@
#define USE_CAUSTICS 1
#define USE_REFRACTION 1
#define USE_DISPLACEMENT 1
#define USE_STYLIZED_LIGHTING 0
#define USE_UNSHADED 0
shader_type spatial;
#if USE_UNSHADED
render_mode unshaded, depth_draw_never;
#else
render_mode depth_draw_never;
#endif
uniform sampler2D DEPTH_TEXTURE: hint_depth_texture;
group_uniforms Color;
uniform vec4 surface_color : source_color = vec4(0.2,1.0,0.8,1.0);
uniform vec4 depth_color : source_color = vec4(0.08,0.2,0.4,1.0);
uniform vec4 foam_color : source_color = vec4(1.0);
uniform float depth_size = 12.0;
group_uniforms Roughness;
uniform float surface_roughness : hint_range(0.0, 1.0, 0.01) = 0.05;
uniform float foam_roughness : hint_range(0.0, 1.0, 0.01) = 0.05;
#if USE_CAUSTICS
group_uniforms Caustics;
uniform sampler2D caustics_texture;
uniform float caustics_strength = 2.0;
uniform vec2 caustics_scale = vec2(0.5);
#endif
group_uniforms Wave;
uniform sampler2D wave_texture;
uniform float wave_softness : hint_range(0.0, 10.0, 0.1) = 3.0;
uniform vec2 wave_scale = vec2(0.2);
uniform vec2 wave_layer_scale = vec2(1.5);
uniform float wave_highlight : hint_range(0.0, 1.0, 0.05) = 0.5;
group_uniforms Wave.Motion;
uniform vec2 wave_velocity = vec2(0.02);
instance uniform vec2 river_flow_direction = vec2(0.0, 0.0);
group_uniforms Foam;
uniform sampler2D foam_texture;
uniform float edge_foam_depth_size = 1.0;
uniform float wave_foam_amount : hint_range(0.0, 1.0, 0.01) = 0.8;
uniform float foam_start : hint_range(0.0, 1.0, 0.05) = 0.15;
uniform float foam_end : hint_range(0.0, 1.0, 0.05) = 0.3;
uniform float foam_exponent = 2.0;
#if USE_REFRACTION
group_uniforms Refraction;
uniform float refraction_amount = 0.5;
uniform float refraction_exponent = 0.5;
#endif
#if USE_DISPLACEMENT
group_uniforms Displacement;
uniform float displacement_amount = 0.3;
#endif
#if USE_STYLIZED_LIGHTING && !USE_UNSHADED
group_uniforms Lighting;
uniform float diffuse_steps = 12.0;
uniform float diffuse_smoothness : hint_range(0.0, 1.0, 0.01) = 0.2;
uniform float specular_steps = 12.0;
uniform float specular_smoothness : hint_range(0.0, 1.0, 0.01) = 0.2;
#endif
uniform sampler2D screen_texture : hint_screen_texture;
varying vec3 world_pos;
varying vec2 world_wave_velocity;
#if USE_CAUSTICS
vec3 sample_caustics(vec2 uv){
vec2 caustics_uv = uv * caustics_scale;
return vec3(
texture(caustics_texture, caustics_uv).r,
texture(caustics_texture, caustics_uv+vec2(0.02,0.02)).r,
texture(caustics_texture, caustics_uv+vec2(0.03,0.01)).r
);
}
#endif
vec4 sample_world_dpos(vec2 screen_uv, mat4 inv_proj_mat, mat4 inv_view_mat){
vec4 clip_pos = vec4(screen_uv * 2.0 - 1.0, texture(DEPTH_TEXTURE, screen_uv).r, 1.0);
vec4 view_pos = inv_proj_mat * clip_pos;
view_pos /= view_pos.w;
vec4 world_dpos = inv_view_mat * view_pos;
return world_dpos;
}
vec4 sample_wave(sampler2D tex, vec2 uv, vec2 velocity, float lod){
vec2 base_uv = uv * wave_scale;
vec2 wave_uv1 = (base_uv * wave_layer_scale) + (TIME * -velocity);
float wave1 = textureLod(tex, wave_uv1, lod).r;
vec2 wave_uv2 = base_uv + (TIME * velocity);
vec4 wave2 = textureLod(tex, wave_uv2 - (wave1 * 0.1), lod);
return wave2;
}
vec3 sample_wave_normal(vec2 uv, vec2 velocity, float center_wave) {
vec2 normal_offset = vec2(0.25, 0.0);
float wave_x = sample_wave(wave_texture, uv + normal_offset.xy, velocity, wave_softness).r;
float wave_z = sample_wave(wave_texture, uv + normal_offset.yx, velocity, wave_softness).r;
vec2 slope = vec2(center_wave - wave_x, center_wave - wave_z) * 0.35;
return normalize(vec3(slope, 1.0)) * 0.5 + 0.5;
}
vec2 get_world_wave_velocity(mat4 model_matrix) {
float velocity_length = length(wave_velocity);
if (velocity_length <= 0.0001) {
return vec2(0.0);
}
float flow_direction_length = length(river_flow_direction);
if (flow_direction_length > 0.0001) {
return (river_flow_direction / flow_direction_length) * velocity_length;
}
vec3 world_direction_3d = (model_matrix * vec4(0.0, 1.0, 0.0, 0.0)).xyz;
vec2 world_direction = world_direction_3d.xz;
float world_direction_length = length(world_direction);
if (world_direction_length <= 0.0001) {
return wave_velocity;
}
return (world_direction / world_direction_length) * velocity_length;
}
void vertex(){
world_pos = (MODEL_MATRIX * vec4(VERTEX, 1.0)).xyz;
world_wave_velocity = get_world_wave_velocity(MODEL_MATRIX);
#if USE_DISPLACEMENT
float wave = sample_wave(wave_texture, world_pos.xz, world_wave_velocity, wave_softness).r;
VERTEX.y += wave*displacement_amount;
#endif
}
void fragment() {
float wave = sample_wave(wave_texture, world_pos.xz, world_wave_velocity, wave_softness).r;
wave = smoothstep(0.0,1.0,wave);
vec2 screen_uv = SCREEN_UV;
// Refraction
#if USE_REFRACTION
screen_uv += ((pow(wave, refraction_exponent)*2.0 - 0.5) * 0.01 * refraction_amount);
vec4 world_dpos = sample_world_dpos(screen_uv, INV_PROJECTION_MATRIX, INV_VIEW_MATRIX);
float pre_depth = pow(clamp((world_dpos.y - world_pos.y + depth_size)/depth_size, 0.0, 1.0), 4.0);
screen_uv = mix(screen_uv, SCREEN_UV, pre_depth);
if(world_dpos.y - world_pos.y > 0.0){
screen_uv = SCREEN_UV;
}
#else
vec4 world_dpos = sample_world_dpos(screen_uv, INV_PROJECTION_MATRIX, INV_VIEW_MATRIX);
#endif
world_dpos = sample_world_dpos(screen_uv, INV_PROJECTION_MATRIX, INV_VIEW_MATRIX);
vec2 surface_uv = world_dpos.xz * 0.2;
float depth = pow(clamp((world_dpos.y - world_pos.y + depth_size)/depth_size, 0.0, 1.0), 4.0);
// Caustics
#if USE_CAUSTICS
vec3 caustics1 = sample_caustics(surface_uv + (TIME * -world_wave_velocity));
vec3 caustics2 = sample_caustics((surface_uv + (caustics1.r*0.05)) + (TIME * (world_wave_velocity*0.5)));
vec3 caustics = caustics2 * (1.0 - depth);
#endif
// Edge Foam
float edge_foam_depth = clamp((world_dpos.y - world_pos.y + edge_foam_depth_size)/edge_foam_depth_size, 0.0, 1.0);
// Wave Foam
float wave_foam = wave;
float foam = max(edge_foam_depth, wave_foam * wave_foam_amount);
float foam_shape = 1.0 - texture(foam_texture, world_pos.xz* 0.5).r;
foam = clamp((foam - foam_start) / (foam_end - foam_start), 0.0, 1.0);
foam = clamp((foam - foam_shape) / (1.0 - foam_shape), 0.0, 1.0);
foam = pow(foam, foam_exponent);
vec3 flat_color = mix(depth_color, surface_color, depth).rgb;
vec4 screen = texture(screen_texture, screen_uv);
vec3 color = screen.rgb;
#if USE_CAUSTICS
color += vec3(pow(caustics * caustics_strength, vec3(2.0)));
#endif
color = mix(flat_color, color, 0.4 * depth);
color = mix(color, surface_color.rgb, wave * wave_highlight);
color = mix(color, foam_color.rgb, foam);
#if !USE_UNSHADED
vec3 wave_normal_map = sample_wave_normal(world_pos.xz, world_wave_velocity, wave);
NORMAL_MAP = wave_normal_map;
#endif
ROUGHNESS = mix(surface_roughness, foam_roughness, foam);
ALBEDO = color;
}
#if USE_STYLIZED_LIGHTING && !USE_UNSHADED
void light(){
float ndotl = dot(NORMAL, LIGHT) * ATTENUATION;
//ndotl = smoothstep(0.0,1.0-ROUGHNESS,ndotl);
float light = ndotl;
float light_mult = light * diffuse_steps;
float light_step_base = floor(light_mult);
float light_factor = light_mult - light_step_base;
light_factor = smoothstep(0.5 - diffuse_smoothness * 0.5, 0.5 + diffuse_smoothness * 0.5, light_factor);
light = (light_step_base + light_factor) / diffuse_steps;
DIFFUSE_LIGHT += (LIGHT_COLOR+ALBEDO) * light / PI;
float roughness = mix(0.01, 0.99, ROUGHNESS);
vec3 h = normalize(VIEW + LIGHT);
float ndoth = clamp(dot(NORMAL, h), 0.0, 1.0) * ATTENUATION;
float specular = clamp(pow(ndoth, 16.0/(roughness)), 0.1, 0.99);
specular = mix(pow(specular, 2.0-roughness),0.00,pow(roughness, 0.1));
float specular_mult = specular * specular_steps;
float specular_step_base = floor(specular_mult);
float specular_factor = specular_mult - specular_step_base;
specular_factor = smoothstep(0.5 - specular_smoothness * 0.5, 0.5 + specular_smoothness * 0.5, specular_factor);
specular = (specular_step_base + specular_factor) / specular_steps;
SPECULAR_LIGHT += (LIGHT_COLOR + ALBEDO) * specular;
}
#endif

View File

@@ -1 +0,0 @@
uid://cb12c2j8rfu6a

View File

@@ -14,7 +14,6 @@ var godray: PackedScene
var environment_dust: ColorRect var environment_dust: ColorRect
var blur: ColorRect var blur: ColorRect
var environment_shadows: MeshInstance3D var environment_shadows: MeshInstance3D
var fog: Node3D
var sun: DirectionalLight3D var sun: DirectionalLight3D
var environment: WorldEnvironment var environment: WorldEnvironment
@@ -34,15 +33,12 @@ var rain_tween: Tween
var rain_audio_tween: Tween var rain_audio_tween: Tween
var puddle_tween: Tween var puddle_tween: Tween
var puddle_amount: float = 0.0 var puddle_amount: float = 0.0
var clouds_tween: Tween
var snow_tween: Tween var snow_tween: Tween
var snow_weather_tween: Tween
var snow_particles_tween: Tween var snow_particles_tween: Tween
var is_snowing: bool = false var is_snowing: bool = false
var is_snow_accumulated: bool = false var is_snow_accumulated: bool = false
var actual_snow_amount: float = 0.0 var actual_snow_amount: float = 0.0
var snow_weather_amount: float = 0.0
var is_storm: bool = false var is_storm: bool = false
var cold_tween: Tween var cold_tween: Tween
@@ -53,13 +49,10 @@ var current_wind_speed: float = 0.0
var current_wind_strength: float = 0.0 var current_wind_strength: float = 0.0
var current_wind_fade: float = 0.0 var current_wind_fade: float = 0.0
var max_wind_amount: int = 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, func _init(wind: GPUParticles3D, snow: GPUParticles3D,
fireflies: GPUParticles3D, rain: GPUParticles3D, ray: PackedScene, fireflies: GPUParticles3D, rain: GPUParticles3D, ray: PackedScene,
dust: ColorRect, blurr: ColorRect, thefog: Node3D, envshadows: MeshInstance3D, dust: ColorRect, blurr: ColorRect, envshadows: MeshInstance3D,
thesun: DirectionalLight3D, theenvironment: WorldEnvironment, environmentconfig: EnvironmentConfig, thesun: DirectionalLight3D, theenvironment: WorldEnvironment, environmentconfig: EnvironmentConfig,
thecamera: Camera3D, thecamerapivot: Node3D, thundersounds: Array[AudioStream], rainsounds: Array[AudioStream]) -> void: thecamera: Camera3D, thecamerapivot: Node3D, thundersounds: Array[AudioStream], rainsounds: Array[AudioStream]) -> void:
particles_wind = wind particles_wind = wind
@@ -70,7 +63,6 @@ func _init(wind: GPUParticles3D, snow: GPUParticles3D,
sun = thesun sun = thesun
environment_dust = dust environment_dust = dust
blur = blurr blur = blurr
fog = thefog
environment_shadows = envshadows environment_shadows = envshadows
environment = theenvironment environment = theenvironment
environment_config = environmentconfig environment_config = environmentconfig
@@ -94,7 +86,6 @@ func _init(wind: GPUParticles3D, snow: GPUParticles3D,
toggle_dust(environment_config.enable_dust) toggle_dust(environment_config.enable_dust)
toggle_blur(environment_config.enable_blur) toggle_blur(environment_config.enable_blur)
toggle_fog(environment_config.enable_fog)
#set camera pivot if available #set camera pivot if available
if camera_pivot: if camera_pivot:
@@ -107,17 +98,13 @@ func _ready() -> void:
UIEvents.toggle_snow.connect(toggle_snow) UIEvents.toggle_snow.connect(toggle_snow)
UIEvents.toggle_wind.connect(toggle_wind) UIEvents.toggle_wind.connect(toggle_wind)
UIEvents.wind_change.connect(change_wind_strength) UIEvents.wind_change.connect(change_wind_strength)
UIEvents.trigger_random_weather.connect(trigger_random_weather_event)
UIEvents.toggle_fireflies.connect(toggle_fireflies) UIEvents.toggle_fireflies.connect(toggle_fireflies)
UIEvents.toggle_storm.connect(toggle_storm) UIEvents.toggle_storm.connect(toggle_storm)
UIEvents.toggle_dust.connect(toggle_dust) UIEvents.toggle_dust.connect(toggle_dust)
UIEvents.toggle_blur.connect(toggle_blur) UIEvents.toggle_blur.connect(toggle_blur)
UIEvents.toggle_fog.connect(toggle_fog)
UIEvents.toggle_shadows.connect(toggle_shadows) UIEvents.toggle_shadows.connect(toggle_shadows)
_emit_weather_event_label()
func _process(delta: float) -> void: func _process(delta: float) -> void:
_update_random_event_label(delta)
_follow_camera() _follow_camera()
@@ -135,7 +122,6 @@ func _process(delta: float) -> void:
var base_grad_top: Color var base_grad_top: Color
var base_grad_bot: Color var base_grad_bot: Color
var base_grad_intensity: float var base_grad_intensity: float
var base_water_color: Color
var base_rotation_sun: Vector3 var base_rotation_sun: Vector3
if is_raining: if is_raining:
@@ -163,7 +149,6 @@ func _process(delta: float) -> void:
base_grad_top = environment_config.grad_top_morning.lerp(environment_config.grad_top_afternoon, t) base_grad_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_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_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) base_rotation_sun = environment_config.sun_rotation_morning.lerp(environment_config.sun_rotation_afternoon, t)
else: else:
var t = day_time - 2.0 var t = day_time - 2.0
@@ -177,7 +162,6 @@ func _process(delta: float) -> void:
base_grad_top = environment_config.grad_top_afternoon.lerp(environment_config.grad_top_night, t) base_grad_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_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_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) base_rotation_sun = environment_config.sun_rotation_afternoon.lerp(environment_config.sun_rotation_night, t)
var weather_color = environment_config.rain_mode_color var weather_color = environment_config.rain_mode_color
@@ -189,12 +173,11 @@ 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_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_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_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, snow_weather_amount) 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, snow_weather_amount) final_sky_top = final_sky_top.lerp(final_sky_top * environment_config.snow_mode_color, actual_snow_amount)
final_sky_horizon = final_sky_horizon.lerp(final_sky_horizon * environment_config.snow_mode_color, snow_weather_amount) final_sky_horizon = final_sky_horizon.lerp(final_sky_horizon * environment_config.snow_mode_color, actual_snow_amount)
final_fog_color = final_fog_color.lerp(final_fog_color * environment_config.snow_mode_color, snow_weather_amount) final_fog_color = final_fog_color.lerp(final_fog_color * environment_config.snow_mode_color, actual_snow_amount)
#Shader parameters for global trunk_shader #Shader parameters for global trunk_shader
var final_grad_top = base_grad_top.lerp(base_grad_top * weather_color, clamp(rain_intensity, 0.0, 1.0)) var final_grad_top = base_grad_top.lerp(base_grad_top * weather_color, clamp(rain_intensity, 0.0, 1.0))
@@ -203,13 +186,12 @@ 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_top", final_grad_top)
RenderingServer.global_shader_parameter_set("global_gradient_color_bot", final_grad_bot) 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_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) var night_val = clamp(day_time - 2.0, 0.0, 1.0)
#Snow exposure compensation #Snow exposure compensation
var snow_light_attenuation = lerp(1.0, 0.55, snow_weather_amount * (1.0 - night_val)) 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, snow_weather_amount) 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 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 # We calculate the final exposure by applying snow damping directly to the camera exposure
@@ -250,37 +232,16 @@ func _process(delta: float) -> void:
sky_mat.set_shader_parameter("sun_color", final_tint) sky_mat.set_shader_parameter("sun_color", final_tint)
sky_mat.set_shader_parameter("night_intensity", night_val) sky_mat.set_shader_parameter("night_intensity", night_val)
var cloud_density_amount: float = maxf(clamp(rain_intensity, 0.0, 1.0), clamp(snow_weather_amount, 0.0, 1.0))
var current_cloud_density: float = lerp(environment_config.base_cloud_density, environment_config.rain_cloud_density, cloud_density_amount)
if environment_config.material_clouds: if environment_config.material_clouds:
environment_config.material_clouds.set_shader_parameter("cloud_density", current_cloud_density) var current_density = lerp(0.4, 1.0, rain_intensity)
var current_sharpness = lerp(0.14, 0.0, cloud_density_amount) environment_config.material_clouds.set_shader_parameter("cloud_density", current_density)
var current_sharpness = lerp(0.14, 0.0, rain_intensity)
environment_config.material_clouds.set_shader_parameter("center_sharpness", current_sharpness) environment_config.material_clouds.set_shader_parameter("center_sharpness", current_sharpness)
var env_shadow_mat = environment_shadows.get_surface_override_material(0) if environment_shadows else null
if env_shadow_mat:
env_shadow_mat.set_shader_parameter("cloud_density", current_cloud_density)
if environment_config.material_fog: if environment_config.material_fog:
environment_config.material_fog.set_shader_parameter("fog_color", final_fog_color)
environment_config.material_fog.set_shader_parameter("fog_density", clamp(final_fog_density * 25.0, 0.0, 1.0))
environment_config.material_fog.set_shader_parameter("night_intensity", night_val) environment_config.material_fog.set_shader_parameter("night_intensity", night_val)
environment_config.material_fog.set_shader_parameter("sun_color", final_tint) environment_config.material_fog.set_shader_parameter("sun_color", final_tint)
if fog:
for child in fog.get_children():
var fog_mesh := child as MeshInstance3D
if fog_mesh == null:
continue
var fog_material := fog_mesh.get_surface_override_material(0) as ShaderMaterial
if fog_material == null:
continue
fog_material.set_shader_parameter("fog_color", final_fog_color)
fog_material.set_shader_parameter("fog_density", clamp(final_fog_density * 25.0, 0.0, 1.0))
fog_material.set_shader_parameter("night_intensity", night_val)
fog_material.set_shader_parameter("sun_color", final_tint)
func create_sound_players(): func create_sound_players():
rain_audio_player = AudioStreamPlayer.new() rain_audio_player = AudioStreamPlayer.new()
rain_audio_player.name = "RainAudioPlayer" rain_audio_player.name = "RainAudioPlayer"
@@ -304,23 +265,6 @@ func _get_weather_anchor_position() -> Variant:
return camera.global_position return camera.global_position
return null 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: func _follow_camera() -> void:
var cam_pos = _get_weather_anchor_position() var cam_pos = _get_weather_anchor_position()
if cam_pos == null: if cam_pos == null:
@@ -333,12 +277,6 @@ func _follow_camera() -> void:
particles_wind.global_position = Vector3(cam_pos.x, cam_pos.y, cam_pos.z) particles_wind.global_position = Vector3(cam_pos.x, cam_pos.y, cam_pos.z)
if particles_fireflies: if particles_fireflies:
particles_fireflies.global_position = Vector3(cam_pos.x, particles_fireflies.position.y, cam_pos.z) 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 #endregion
#region Fireflies #region Fireflies
@@ -369,7 +307,6 @@ func toggle_wind(value: bool):
particles_wind.emitting = is_windy particles_wind.emitting = is_windy
_apply_wind_state() _apply_wind_state()
_emit_weather_event_label()
#disable wind and set default values and materials #disable wind and set default values and materials
func init_wind(): func init_wind():
@@ -473,67 +410,6 @@ func _update_wind_amount_from_strength(value: float) -> void:
environment_config.wind_amount = roundi(max_wind_amount * amount_ratio) 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: func _apply_cloud_config() -> void:
var dir = environment_config.wind_direction var dir = environment_config.wind_direction
var cloud_scale = environment_config.cloud_scale var cloud_scale = environment_config.cloud_scale
@@ -565,7 +441,6 @@ func _apply_cloud_config() -> void:
func toggle_storm(value: bool): func toggle_storm(value: bool):
is_storm = value is_storm = value
_emit_weather_event_label()
#set lightning #set lightning
func init_lightning(): func init_lightning():
@@ -679,7 +554,6 @@ func toggle_rain(value: bool):
is_raining = value is_raining = value
if not particles_rain: if not particles_rain:
_emit_weather_event_label()
return return
if is_raining and is_snowing: if is_raining and is_snowing:
@@ -713,7 +587,6 @@ func toggle_rain(value: bool):
trigger_after_rain()) trigger_after_rain())
puddle_tween = create_tween() puddle_tween = create_tween()
puddle_tween.tween_method(set_puddle_amount, puddle_amount, 0.0, environment_config.puddle_dry_time) puddle_tween.tween_method(set_puddle_amount, puddle_amount, 0.0, environment_config.puddle_dry_time)
_emit_weather_event_label()
func trigger_morning() -> void: func trigger_morning() -> void:
spawn_single_godray() spawn_single_godray()
@@ -810,47 +683,12 @@ func toggle_snow(value: bool):
var target_snow_amount: float = 1.0 if is_snowing else 0.0 var target_snow_amount: float = 1.0 if is_snowing else 0.0
if snow_tween and snow_tween.is_valid(): if snow_tween and snow_tween.is_valid():
snow_tween.kill() snow_tween.kill()
if snow_weather_tween and snow_weather_tween.is_valid():
snow_weather_tween.kill()
var snow_amount_transition_duration: float = _get_snow_amount_transition_duration(is_snowing)
snow_tween = create_tween() snow_tween = create_tween()
snow_tween.tween_method( snow_tween.tween_method(init_snow_amount, actual_snow_amount, target_snow_amount, environment_config.snow_transaction_time)
init_snow_amount,
actual_snow_amount,
target_snow_amount,
snow_amount_transition_duration
)
snow_weather_tween = create_tween()
snow_weather_tween.tween_method(
init_snow_weather_amount,
snow_weather_amount,
target_snow_amount,
environment_config.snow_fade_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 #disable snow and set default values and shader
func init_snow(value: float = 0.0): func init_snow(value: float = 0.0):
actual_snow_amount = value actual_snow_amount = value
snow_weather_amount = value
RenderingServer.global_shader_parameter_set("global_snow_amount", value) RenderingServer.global_shader_parameter_set("global_snow_amount", value)
if particles_snow: if particles_snow:
@@ -861,13 +699,6 @@ func init_snow(value: float = 0.0):
RenderingServer.global_shader_parameter_set("global_snow_color", environment_config.snow_color) RenderingServer.global_shader_parameter_set("global_snow_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_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_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_start_time", -1.0)
RenderingServer.global_shader_parameter_set("global_snow_melt_time", -1.0) RenderingServer.global_shader_parameter_set("global_snow_melt_time", -1.0)
@@ -875,9 +706,6 @@ func init_snow_amount(value: float):
actual_snow_amount = value actual_snow_amount = value
RenderingServer.global_shader_parameter_set("global_snow_amount", value) RenderingServer.global_shader_parameter_set("global_snow_amount", value)
func init_snow_weather_amount(value: float):
snow_weather_amount = value
func start_snow_accumulation() -> void: func start_snow_accumulation() -> void:
RenderingServer.global_shader_parameter_set("global_snow_melt_time", -1.0) RenderingServer.global_shader_parameter_set("global_snow_melt_time", -1.0)
RenderingServer.global_shader_parameter_set("global_snow_start_time", Time.get_ticks_msec() / 1000.0) RenderingServer.global_shader_parameter_set("global_snow_start_time", Time.get_ticks_msec() / 1000.0)
@@ -886,18 +714,6 @@ func start_snow_melt() -> void:
RenderingServer.global_shader_parameter_set("global_snow_melt_time", Time.get_ticks_msec() / 1000.0) RenderingServer.global_shader_parameter_set("global_snow_melt_time", Time.get_ticks_msec() / 1000.0)
RenderingServer.global_shader_parameter_set("global_snow_melt_speed", environment_config.snow_melt_speed) RenderingServer.global_shader_parameter_set("global_snow_melt_speed", environment_config.snow_melt_speed)
func _get_snow_amount_transition_duration(is_accumulating: bool) -> float:
if environment_config == null:
return 0.0
var speed: float = environment_config.snow_melt_speed
if is_accumulating:
speed = environment_config.snow_accumulation_speed
if speed <= 0.0:
return environment_config.snow_transaction_time
return 1.0 / speed
#endregion #endregion
#region Post-Process #region Post-Process
@@ -912,10 +728,6 @@ func toggle_blur(value: bool) -> void:
ApplyPostProcessBlurConfig() ApplyPostProcessBlurConfig()
func toggle_fog(value: bool) -> void:
if fog:
fog.visible = value
func toggle_shadows(value: bool) -> void: func toggle_shadows(value: bool) -> void:
if environment_shadows: if environment_shadows:
environment_shadows.visible = value environment_shadows.visible = value

View File

@@ -3,19 +3,11 @@ render_mode blend_mix, depth_draw_never;
//Snow globals //Snow globals
global uniform float global_snow_start_time = -1.0; global uniform float global_snow_start_time = -1.0;
global uniform float global_snow_accumulation_speed = 0.005; global uniform float global_snow_accumulation_speed = 0.1;
global uniform float global_snow_melt_time = -1.0; global uniform float global_snow_melt_time = -1.0;
global uniform float global_snow_melt_speed = 0.1; 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 float global_snow_threshold = 0.5;
global uniform vec4 global_snow_color = vec4(0.92, 0.96, 1.0, 1.0); 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_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_edge_softness : hint_range(0.01, 0.5) = 0.2;
uniform float snow_roughness_variation : hint_range(0.0, 0.3) = 0.15; uniform float snow_roughness_variation : hint_range(0.0, 0.3) = 0.15;
@@ -37,55 +29,6 @@ uniform float puddle_threshold : hint_range(0.0, 0.8) = 0.45;
uniform sampler2D noise_texture : filter_linear_mipmap, repeat_enable; 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() {
float snow_progress = clamp(global_snow_amount, 0.0, 1.0);
if (global_snow_start_time >= 0.0) {
float timed_progress = clamp((TIME - global_snow_start_time) * global_snow_accumulation_speed, 0.0, 1.0);
snow_progress = max(snow_progress, timed_progress);
}
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 = min(snow_progress, 1.0 - melt);
}
return snow_progress;
}
float ripple_ring(vec2 uv, float time_offset) { float ripple_ring(vec2 uv, float time_offset) {
float d = length(uv); float d = length(uv);
float ring = sin(d * 30.0 - TIME * ripple_speed + time_offset) * 0.5 + 0.5; float ring = sin(d * 30.0 - TIME * ripple_speed + time_offset) * 0.5 + 0.5;
@@ -93,27 +36,6 @@ float ripple_ring(vec2 uv, float time_offset) {
return ring * fade; 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() { void fragment() {
vec3 world_pos = (INV_VIEW_MATRIX * vec4(VERTEX, 1.0)).xyz; vec3 world_pos = (INV_VIEW_MATRIX * vec4(VERTEX, 1.0)).xyz;
vec3 world_normal = normalize((INV_VIEW_MATRIX * vec4(NORMAL, 0.0)).xyz); vec3 world_normal = normalize((INV_VIEW_MATRIX * vec4(NORMAL, 0.0)).xyz);
@@ -121,24 +43,25 @@ void fragment() {
float noise_val = texture(noise_texture, world_pos.xz * snow_noise_scale).r; float noise_val = texture(noise_texture, world_pos.xz * snow_noise_scale).r;
//Snow //Snow
float snow_progress = v_snow_amount; float snow_amount = 0.0;
float snow_accumulation = snow_progress * global_snow_max_accumulation; if (global_snow_start_time >= 0.0) {
snow_amount = clamp((TIME - global_snow_start_time) * global_snow_accumulation_speed, 0.0, 1.0);
}
if (global_snow_melt_time >= 0.0) {
float melt = clamp((TIME - global_snow_melt_time) * global_snow_melt_speed, 0.0, 1.0);
snow_amount *= (1.0 - melt);
}
float snow_edge = smoothstep( float snow_edge = smoothstep(
global_snow_threshold - snow_edge_softness, global_snow_threshold - snow_edge_softness,
global_snow_threshold + snow_edge_softness, global_snow_threshold + snow_edge_softness,
facing_up facing_up + (noise_val - 0.5) * 0.4
); );
float flat_accumulation = smoothstep(0.0, 0.35, v_snow_cap_mask) * snow_accumulation; float snow_coverage = smoothstep(0.0, 0.6, noise_val + snow_amount - 0.4);
float snow_variation = mix(0.75, 1.15, noise_val); float snow_factor = snow_edge * snow_coverage * snow_amount;
float snow_coverage = clamp(snow_progress * snow_variation + flat_accumulation * 0.25, 0.0, 1.0);
float snow_factor = max(snow_edge * snow_coverage, flat_accumulation);
float snow_opacity = clamp(snow_factor, 0.0, 1.0);
snow_opacity = max(snow_opacity, flat_accumulation * 0.9);
float shade = mix(-snow_color_variation, snow_color_variation, noise_val); 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); 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); float snow_rough = mix(0.15 - snow_roughness_variation, 0.15 + snow_roughness_variation, noise_val);
//Rain //Rain
@@ -250,7 +173,7 @@ void fragment() {
ALBEDO = snow_albedo; ALBEDO = snow_albedo;
ROUGHNESS = snow_rough; ROUGHNESS = snow_rough;
METALLIC = 0.0; METALLIC = 0.0;
ALPHA = snow_opacity; ALPHA = snow_factor;
} else { } else {
ALBEDO = rain_albedo; ALBEDO = rain_albedo;
ROUGHNESS = rain_rough; ROUGHNESS = rain_rough;

Some files were not shown because too many files have changed in this diff Show More