aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortpart <tpart120@proton.me>2024-07-27 14:15:51 +0200
committertpart <tpart120@proton.me>2024-07-27 14:15:55 +0200
commit3a5e8ad83abe6b7daf8e6168a72c143d96538497 (patch)
treee4951ce1b3bd8dc368b80aaf390fe61b37af9e90
parentee7f28b87db60506278f7ae6ce61253062852713 (diff)
downloadhurrycurry-3a5e8ad83abe6b7daf8e6168a72c143d96538497.tar
hurrycurry-3a5e8ad83abe6b7daf8e6168a72c143d96538497.tar.bz2
hurrycurry-3a5e8ad83abe6b7daf8e6168a72c143d96538497.tar.zst
Add night sky support; Refactor environment system
-rw-r--r--client/game.tscn2
-rw-r--r--client/map/auto_setup/environment_setup.gd3
-rw-r--r--client/map/environment.gd15
-rw-r--r--client/map/environment/environment.gd20
-rw-r--r--client/map/environment/environment.tscn (renamed from client/map/environment.tscn)4
-rw-r--r--client/map/environment/presets/day_sky.tres4
-rw-r--r--client/map/environment/presets/night_sky.tres7
-rw-r--r--client/map/environment/world_environment.tscn19
-rw-r--r--client/map/world_environment.tscn21
-rw-r--r--client/project.godot1
10 files changed, 56 insertions, 40 deletions
diff --git a/client/game.tscn b/client/game.tscn
index 86851ded..28631499 100644
--- a/client/game.tscn
+++ b/client/game.tscn
@@ -5,7 +5,7 @@
[ext_resource type="Script" path="res://map/auto_setup/light_setup.gd" id="5_6fpff"]
[ext_resource type="Script" path="res://multiplayer.gd" id="6_fbxu8"]
[ext_resource type="PackedScene" uid="uid://b4gone8fu53r7" path="res://map/map.tscn" id="6_prg6t"]
-[ext_resource type="PackedScene" uid="uid://nroo08m5og0" path="res://map/environment.tscn" id="7_v2apt"]
+[ext_resource type="PackedScene" uid="uid://nroo08m5og0" path="res://map/environment/environment.tscn" id="7_v2apt"]
[node name="Game" type="Node3D"]
script = ExtResource("1_sftfn")
diff --git a/client/map/auto_setup/environment_setup.gd b/client/map/auto_setup/environment_setup.gd
index 3e6049b3..64180d8c 100644
--- a/client/map/auto_setup/environment_setup.gd
+++ b/client/map/auto_setup/environment_setup.gd
@@ -18,6 +18,9 @@ class_name EnvironmentSetup
@export var allow_sdfgi := true
+func set_sky(sky_name: String):
+ environment.sky.sky_material = load("res://map/environment/presets/%s_sky.tres" % sky_name)
+
func _ready():
apply_settings()
Global.settings_changed.connect(apply_settings)
diff --git a/client/map/environment.gd b/client/map/environment.gd
deleted file mode 100644
index 5fcfc53d..00000000
--- a/client/map/environment.gd
+++ /dev/null
@@ -1,15 +0,0 @@
-extends Node3D
-
-func update(active: Array):
- if active.has("night"):
- pass
-
- $Wind.emitting = active.has("wind")
- var a: ParticleProcessMaterial = $Wind.process_material
- # TODO ramp
- a.initial_velocity_max = 15. if active.has("wind") else 0.
- a.initial_velocity_min = 15. if active.has("wind") else 0.
-
- # TODO ramp
- $Rain.emitting = active.has("rain")
- $Rain.amount = 500 if active.has("rain") else 0
diff --git a/client/map/environment/environment.gd b/client/map/environment/environment.gd
new file mode 100644
index 00000000..4f866ac8
--- /dev/null
+++ b/client/map/environment/environment.gd
@@ -0,0 +1,20 @@
+extends Node3D
+
+@onready var rain: GPUParticles3D = $Rain
+@onready var wind: GPUParticles3D = $Wind
+
+@onready var world_environment: EnvironmentSetup = $WorldEnvironment
+
+func update(active: Array):
+ if active.has("night"):
+ world_environment.set_sky("night")
+
+ wind.emitting = active.has("wind")
+ var a: ParticleProcessMaterial = wind.process_material
+ # TODO ramp
+ a.initial_velocity_max = 15. if active.has("wind") else 0.
+ a.initial_velocity_min = 15. if active.has("wind") else 0.
+
+ # TODO ramp
+ rain.emitting = active.has("rain")
+ rain.amount = 500 if active.has("rain") else 0
diff --git a/client/map/environment.tscn b/client/map/environment/environment.tscn
index b254f468..73e2be55 100644
--- a/client/map/environment.tscn
+++ b/client/map/environment/environment.tscn
@@ -1,7 +1,7 @@
[gd_scene load_steps=11 format=3 uid="uid://nroo08m5og0"]
-[ext_resource type="Script" path="res://map/environment.gd" id="1_qy481"]
-[ext_resource type="PackedScene" uid="uid://cb4ic3ssk4r8r" path="res://map/world_environment.tscn" id="2_68o16"]
+[ext_resource type="Script" path="res://map/environment/environment.gd" id="1_qy481"]
+[ext_resource type="PackedScene" uid="uid://cb4ic3ssk4r8r" path="res://map/environment/world_environment.tscn" id="2_68o16"]
[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_fyrr8"]
emission_shape_offset = Vector3(0, 5, 0)
diff --git a/client/map/environment/presets/day_sky.tres b/client/map/environment/presets/day_sky.tres
new file mode 100644
index 00000000..0e1c9458
--- /dev/null
+++ b/client/map/environment/presets/day_sky.tres
@@ -0,0 +1,4 @@
+[gd_resource type="ProceduralSkyMaterial" format=3 uid="uid://617pq1rgdgbn"]
+
+[resource]
+ground_bottom_color = Color(0.0826605, 0.065772, 0.0461518, 1)
diff --git a/client/map/environment/presets/night_sky.tres b/client/map/environment/presets/night_sky.tres
new file mode 100644
index 00000000..f1b888ef
--- /dev/null
+++ b/client/map/environment/presets/night_sky.tres
@@ -0,0 +1,7 @@
+[gd_resource type="ProceduralSkyMaterial" format=3 uid="uid://c88b6e1mfqds0"]
+
+[resource]
+sky_top_color = Color(0.167333, 0.162044, 0.423032, 1)
+sky_horizon_color = Color(0.390429, 0.285861, 0.305681, 1)
+ground_bottom_color = Color(0.0826605, 0.065772, 0.0461518, 1)
+ground_horizon_color = Color(0.392157, 0.286275, 0.305882, 1)
diff --git a/client/map/environment/world_environment.tscn b/client/map/environment/world_environment.tscn
new file mode 100644
index 00000000..b3298e28
--- /dev/null
+++ b/client/map/environment/world_environment.tscn
@@ -0,0 +1,19 @@
+[gd_scene load_steps=5 format=3 uid="uid://cb4ic3ssk4r8r"]
+
+[ext_resource type="Material" uid="uid://c88b6e1mfqds0" path="res://map/environment/presets/night_sky.tres" id="1_6wb0p"]
+[ext_resource type="Script" path="res://map/auto_setup/environment_setup.gd" id="1_iatcp"]
+
+[sub_resource type="Sky" id="Sky_trwp7"]
+sky_material = ExtResource("1_6wb0p")
+
+[sub_resource type="Environment" id="Environment_8cwcp"]
+background_mode = 2
+sky = SubResource("Sky_trwp7")
+tonemap_mode = 2
+ssao_enabled = true
+sdfgi_use_occlusion = true
+sdfgi_energy = 2.0
+
+[node name="WorldEnvironment" type="WorldEnvironment"]
+environment = SubResource("Environment_8cwcp")
+script = ExtResource("1_iatcp")
diff --git a/client/map/world_environment.tscn b/client/map/world_environment.tscn
deleted file mode 100644
index 4ca96f37..00000000
--- a/client/map/world_environment.tscn
+++ /dev/null
@@ -1,21 +0,0 @@
-[gd_scene load_steps=5 format=3 uid="uid://cb4ic3ssk4r8r"]
-
-[ext_resource type="Script" path="res://map/auto_setup/environment_setup.gd" id="1_iatcp"]
-
-[sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_py7px"]
-ground_bottom_color = Color(0.0826605, 0.065772, 0.0461518, 1)
-
-[sub_resource type="Sky" id="Sky_ultpf"]
-sky_material = SubResource("ProceduralSkyMaterial_py7px")
-
-[sub_resource type="Environment" id="Environment_m4dli"]
-background_mode = 2
-sky = SubResource("Sky_ultpf")
-tonemap_mode = 2
-ssao_enabled = true
-sdfgi_use_occlusion = true
-sdfgi_energy = 2.0
-
-[node name="WorldEnvironment" type="WorldEnvironment"]
-environment = SubResource("Environment_m4dli")
-script = ExtResource("1_iatcp")
diff --git a/client/project.godot b/client/project.godot
index 25ff30f4..dff42d0e 100644
--- a/client/project.godot
+++ b/client/project.godot
@@ -201,4 +201,3 @@ locale/translations_pot_files=PackedStringArray("res://global.gd", "res://menu/o
textures/vram_compression/import_etc2_astc=true
anti_aliasing/quality/msaa_2d=1
anti_aliasing/quality/msaa_3d=1
-viewport/transparent_background=true