From 30d2636fdbc4e988a7c81ae1a82b4a6ee8fbd3ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vojte=CC=8Cch=20Struha=CC=81r?= Date: Thu, 13 Feb 2025 22:36:34 +0100 Subject: [PATCH] Add lights demo + Semi-dynamic main menu buttons --- NOTES.md | 7 ++ hud.tscn | 7 +- levels/level_semaphore_lights.tscn | 113 +++++++++++++++++++++++++++++ menu.gd | 20 +++-- menu.tscn | 16 ---- player.tscn | 1 + project.godot | 2 + 7 files changed, 143 insertions(+), 23 deletions(-) create mode 100644 levels/level_semaphore_lights.tscn diff --git a/NOTES.md b/NOTES.md index 767b980..421c7f7 100644 --- a/NOTES.md +++ b/NOTES.md @@ -22,3 +22,10 @@ venkovního úhlu. Protože reálně jsem od něj mega daleko, takže portálov že on má Y-up a Blender používá Z-up. V portal repu je k tomu poznámka ale nepochopil jsem to asi. - Divně se na ten mesh pak projektuje ta textura kamery?? - Možná by stálo za to udělat procedurální mesh. Nejběžnější tvar portálu bude asi obdélník +- `OnScreenNotifier3D` nemůže specifikovat _která_ kamera ten objekt vidí, takže je asi k ničemu. + Portály se vidí různě navzájem, s tolika kamerama ve scéně je to nepředvídatelné trochu. + - **I když** možná by to šlo pofejkovat s culling vrstvama. Vzdáváme se tím rekurzivních portálů, ale kdyby portály **ne**renderovaly ostatní portály, tak by se daly vypnout v momentě kdy nejsou vidět (stonks?) +- **Fejkování světel** (OmniLight) by možná šlo!!! S rendering layerama bys nastavil aby některé světla byly vidět JEN skrz portály a NE tou kamerou co má hráč na sobě. + - Tohle platí hlavně u ~~free-standing~~ portálů na které jde koukat z obou stran. *Bylo by divné kdyby byl zezadu portálu ve vzduchu light source jenom proto, že na druhé straně portálu (bůh ví kde) takový source někde je* + - Free-standing portál neni uplně dobrý příklad, protože by to světlo mělo házet _výseč_ ven. To ničím fajné, to jsme zpátky u raytracingu. Leda by to člověk oblbnul nějakým shadow meshem nebo něco.. hm. Velmi specifické. Ale u těch dveří jako v semaforovém levelu by to fungovalo asi v pohodě, protože kolem futer je stěna. + - Spotlight..? diff --git a/hud.tscn b/hud.tscn index 439ef93..7270b4e 100644 --- a/hud.tscn +++ b/hud.tscn @@ -1,8 +1,10 @@ -[gd_scene load_steps=2 format=3 uid="uid://b5x7fmpwck335"] +[gd_scene load_steps=3 format=3 uid="uid://b5x7fmpwck335"] [ext_resource type="Script" uid="uid://dys441ih752an" path="res://hud.gd" id="1_37p78"] +[ext_resource type="Theme" uid="uid://h8lwapw6q4pv" path="res://menu_theme.tres" id="1_64ctp"] [node name="HUD" type="VBoxContainer"] +theme = ExtResource("1_64ctp") script = ExtResource("1_37p78") [node name="MenuButton" type="Button" parent="."] @@ -10,4 +12,7 @@ unique_name_in_owner = true layout_mode = 2 text = "Back to Menu" +[node name="HSeparator" type="HSeparator" parent="."] +layout_mode = 2 + [connection signal="pressed" from="MenuButton" to="." method="_on_menu_button_pressed"] diff --git a/levels/level_semaphore_lights.tscn b/levels/level_semaphore_lights.tscn new file mode 100644 index 0000000..4a475d7 --- /dev/null +++ b/levels/level_semaphore_lights.tscn @@ -0,0 +1,113 @@ +[gd_scene load_steps=12 format=3 uid="uid://b05da3uh23mfc"] + +[ext_resource type="PackedScene" uid="uid://b5x7fmpwck335" path="res://hud.tscn" id="1_4dtxc"] +[ext_resource type="MeshLibrary" uid="uid://bedqgubx1g1uf" path="res://prototypes.tres" id="2_wbiwv"] +[ext_resource type="ArrayMesh" uid="uid://bqilnvlfws6xh" path="res://portal-mesh.tres" id="3_0fe4d"] +[ext_resource type="Script" uid="uid://d2bvvjsibau8c" path="res://addons/simple-portal-system/scripts/portal.gd" id="4_mmyl2"] +[ext_resource type="Script" uid="uid://bkv7t4hw21byg" path="res://addons/simple-portal-system/scripts/simple_portal_teleport.gd" id="5_1lcpk"] +[ext_resource type="PackedScene" uid="uid://cgdlowfuuorvi" path="res://player.tscn" id="6_slvs7"] +[ext_resource type="Script" uid="uid://cili3lyodjqel" path="res://portal_environment_adapter.gd" id="7_yea2i"] + +[sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_b0o0q"] +sky_horizon_color = Color(0.662243, 0.671743, 0.686743, 1) +ground_horizon_color = Color(0.662243, 0.671743, 0.686743, 1) + +[sub_resource type="Sky" id="Sky_cgnft"] +sky_material = SubResource("ProceduralSkyMaterial_b0o0q") + +[sub_resource type="Environment" id="Environment_snwvi"] +background_mode = 2 +sky = SubResource("Sky_cgnft") +tonemap_mode = 3 +tonemap_exposure = 1.5 +glow_enabled = true + +[sub_resource type="BoxShape3D" id="BoxShape3D_cgnft"] +size = Vector3(2, 2, 0.5) + +[node name="level_semaphore_lights" type="Node3D"] + +[node name="HUD" parent="." instance=ExtResource("1_4dtxc")] +offset_right = 137.0 +offset_bottom = 23.0 + +[node name="Label" type="Label" parent="HUD"] +layout_mode = 2 +text = "Red light is ONLY visible through a portal" + +[node name="WorldEnvironment" type="WorldEnvironment" parent="."] +environment = SubResource("Environment_snwvi") + +[node name="GridMap" type="GridMap" parent="."] +mesh_library = ExtResource("2_wbiwv") +cell_size = Vector3(1, 1, 1) +data = { +"cells": PackedInt32Array(65530, 6, 0, 65531, 6, 0, 65532, 6, 0, 65533, 6, 0, 65534, 6, 0, 65535, 6, 0, 0, 6, 0, 1, 6, 0, 2, 6, 0, 3, 6, 0, 4, 6, 0, 5, 6, 0, 5, 5, 0, 6, 5, 0, 6, 4, 0, 6, 3, 0, 6, 1, 0, 6, 2, 0, 5, 3, 0, 5, 4, 0, 6, 6, 0, 5, 2, 0, 6, 0, 0, 65535, 65529, 0, 65534, 65529, 0, 65533, 65529, 0, 65532, 65529, 0, 65531, 65529, 0, 65530, 65529, 0, 65529, 65529, 0, 65529, 65530, 0, 65529, 65531, 0, 65528, 65531, 0, 65528, 65532, 0, 65528, 65533, 0, 65528, 65534, 0, 65528, 65535, 0, 65528, 0, 0, 65528, 1, 0, 65528, 2, 0, 65528, 3, 0, 65528, 4, 0, 65528, 5, 0, 65528, 6, 0, 65529, 6, 0, 65529, 1, 0, 65529, 0, 0, 65529, 65535, 0, 65529, 65534, 0, 65529, 65533, 0, 65530, 65535, 0, 65530, 0, 0, 65530, 1, 0, 65530, 2, 0, 65530, 3, 0, 65529, 3, 0, 65529, 4, 0, 65529, 5, 0, 65530, 4, 0, 65530, 5, 0, 65531, 5, 0, 65529, 2, 0, 65530, 65534, 0, 65530, 65533, 0, 65529, 65532, 0, 65530, 65530, 0, 65531, 65530, 0, 65531, 65531, 0, 65531, 65532, 0, 65531, 65533, 0, 65530, 65532, 0, 65528, 65530, 0, 65528, 65529, 0, 65530, 65531, 0, 65534, 65530, 0, 65535, 65530, 0, 65534, 65531, 0, 65533, 65531, 0, 65532, 65531, 0, 65532, 65530, 0, 65533, 65530, 0, 5, 1, 0, 5, 0, 0, 4, 0, 0, 4, 1, 0, 4, 2, 0, 3, 2, 0, 3, 3, 0, 3, 4, 0, 3, 5, 0, 4, 5, 0, 4, 4, 0, 4, 3, 0, 0, 5, 0, 1, 5, 0, 2, 5, 0, 65535, 5, 0, 65534, 5, 0, 65533, 5, 0, 65532, 5, 0, 65531, 4, 0, 65532, 4, 0, 65533, 4, 0, 65534, 4, 0, 65535, 3, 0, 0, 3, 0, 0, 4, 0, 1, 4, 0, 1, 3, 0, 2, 3, 0, 2, 4, 0, 65535, 4, 0, 65534, 3, 0, 65533, 3, 0, 65532, 3, 0, 65531, 3, 0, 65531, 2, 0, 65532, 2, 0, 65533, 2, 0, 65534, 2, 0, 65535, 2, 0, 0, 2, 0, 1, 2, 0, 2, 2, 0, 3, 1, 0, 2, 1, 0, 1, 1, 0, 0, 1, 0, 65535, 1, 0, 65534, 1, 0, 65533, 1, 0, 65532, 1, 0, 65531, 1, 0, 65531, 0, 0, 65531, 65535, 0, 65532, 0, 0, 65533, 0, 0, 65534, 0, 0, 65535, 0, 0, 0, 0, 0, 3, 0, 0, 2, 0, 0, 1, 0, 0, 65535, 65531, 0, 65534, 65532, 0, 65535, 65532, 0, 65535, 65533, 0, 65535, 65534, 0, 65535, 65535, 0, 65534, 65535, 0, 65534, 65534, 0, 65533, 65533, 0, 65533, 65532, 0, 65532, 65532, 0, 65532, 65533, 0, 65532, 65534, 0, 65533, 65534, 0, 65533, 65535, 0, 65532, 65535, 0, 65531, 65534, 0, 65534, 65533, 0, 0, 65535, 0, 1, 65535, 0, 2, 65535, 0, 3, 65535, 0, 4, 65535, 0, 5, 65535, 0, 6, 65535, 0, 65528, 65528, 0, 65529, 65528, 0, 65530, 65528, 0, 65531, 65528, 0, 65532, 65528, 0, 65533, 65528, 0, 65534, 65528, 0, 65535, 65528, 0, 131064, 6, 0, 131065, 6, 0, 131066, 6, 0, 131067, 6, 0, 131068, 6, 0, 131069, 6, 0, 131070, 6, 0, 131071, 6, 0, 65536, 6, 0, 65537, 6, 0, 65538, 6, 0, 65539, 6, 0, 65540, 6, 0, 65541, 6, 0, 65542, 6, 0, 131064, 5, 0, 131064, 4, 0, 131064, 3, 0, 131064, 2, 0, 131064, 1, 0, 131064, 0, 0, 131064, 65535, 0, 131064, 65534, 0, 131064, 65533, 0, 131064, 65532, 0, 131064, 65531, 0, 131064, 65530, 0, 131064, 65529, 0, 131064, 65528, 0, 131065, 65528, 0, 131066, 65528, 0, 131067, 65528, 0, 131068, 65528, 0, 131069, 65528, 0, 131070, 65528, 0, 131071, 65528, 0, 131065, 65535, 0, 131066, 65535, 0, 131069, 65535, 0, 131070, 65535, 0, 131071, 65535, 0, 131071, 65534, 0, 131071, 65533, 0, 131071, 65530, 0, 131071, 65529, 0, 131071, 0, 0, 131071, 1, 0, 131071, 4, 0, 131071, 5, 0, 65536, 65535, 0, 65537, 65535, 0, 65542, 65535, 0, 65542, 0, 0, 65542, 1, 0, 65542, 5, 0, 65542, 4, 0, 65542, 3, 0, 65542, 2, 0, 65541, 65535, 0, 65540, 65535, 0, 196600, 0, 1, 196600, 1, 1, 196600, 2, 1, 196600, 3, 1, 196600, 4, 1, 196600, 5, 1, 196600, 6, 1, 196601, 6, 1, 196602, 6, 1, 196603, 6, 1, 196604, 6, 1, 196605, 6, 1, 196606, 6, 1, 131072, 6, 3, 131073, 6, 3, 131074, 6, 3, 131075, 6, 3, 131076, 6, 3, 131077, 6, 3, 131078, 6, 3, 131078, 5, 3, 131078, 4, 3, 131078, 3, 3, 131078, 2, 3, 131078, 1, 3, 131078, 0, 3, 196600, 65533, 5, 196600, 65534, 5, 196600, 65532, 5, 196600, 65531, 5, 196600, 65530, 5, 196600, 65529, 5, 196600, 65528, 5, 196601, 65528, 5, 196602, 65528, 5, 196603, 65528, 5, 196604, 65528, 5, 196605, 65528, 5, 196606, 65528, 5, 196600, 65535, 0, 196601, 65535, 0, 196602, 65535, 0, 196605, 65535, 0, 196606, 65535, 0, 196607, 65535, 0, 131072, 65535, 0, 131073, 65535, 0, 196607, 1, 0, 196607, 0, 0, 196607, 65534, 0, 196607, 65533, 0, 131078, 65535, 0, 131077, 65535, 0, 131076, 65535, 0, 196607, 65528, 0, 196607, 65529, 0, 196607, 65530, 0, 262143, 65528, 0, 262142, 65528, 0, 262141, 65528, 0, 262140, 65528, 0, 262139, 65528, 0, 262138, 65528, 0, 262137, 65528, 0, 262136, 65528, 0, 262136, 65529, 0, 262136, 65530, 0, 262136, 65531, 0, 262136, 65532, 0, 262136, 65533, 0, 262136, 65534, 0, 262136, 65535, 0, 262136, 0, 0, 262136, 1, 0, 262136, 2, 0, 262136, 3, 0, 262136, 4, 0, 262136, 5, 0, 262137, 6, 0, 262136, 6, 0, 262138, 6, 0, 262139, 6, 0, 262140, 6, 0, 262141, 6, 0, 262142, 6, 0, 196607, 4, 0, 196607, 5, 0, 196607, 6, 0, 262143, 6, 0, 196608, 6, 0, 196609, 6, 0, 196610, 6, 0, 196611, 6, 0, 196612, 6, 0, 196613, 6, 0, 196614, 6, 0, 196614, 5, 0, 196614, 4, 0, 196614, 3, 0, 196614, 2, 0, 196614, 1, 0, 196614, 0, 0, 196614, 65535, 0, 196613, 65535, 0, 196612, 65535, 0, 196609, 65535, 0, 196608, 65535, 0, 262143, 65535, 0, 262142, 65535, 0, 262141, 65535, 0, 262143, 1, 0, 262143, 0, 0, 262143, 65534, 0, 262143, 65533, 0, 262143, 65530, 0, 262143, 65529, 0, 262137, 65535, 0, 262138, 65535, 0, 262143, 5, 0, 262143, 4, 0, 262143, 3, 0, 262143, 2, 0, 262143, 65532, 0, 262143, 65531, 0, 262140, 65535, 0, 262139, 65535, 0, 196611, 65535, 0, 196610, 65535, 0) +} +metadata/_editor_floor_ = Vector3(0, 3, 0) + +[node name="Portal_red" type="MeshInstance3D" parent="." node_paths=PackedStringArray("exit_portal")] +transform = Transform3D(-4.37114e-08, 0, -1, 0, 1, 0, 1, 0, -4.37114e-08, -0.5, 2, -4) +mesh = ExtResource("3_0fe4d") +skeleton = NodePath("") +script = ExtResource("4_mmyl2") +vertical_viewport_resolution = 1080 +disable_viewport_distance = 32.0 +fade_out_distance_max = 30.0 +fade_out_distance_min = 28.0 +fade_out_color = Color(0, 0, 0, 1) +exit_cull_mask = 1048567 +exit_portal = NodePath("../Portal_orange") + +[node name="Teleport" type="Area3D" parent="Portal_red"] +script = ExtResource("5_1lcpk") + +[node name="CollisionShape3D" type="CollisionShape3D" parent="Portal_red/Teleport"] +transform = Transform3D(1, 0, 4.72511e-13, 0, 1, 0, -4.72511e-13, 0, 1, 0, 0, -0.250244) +shape = SubResource("BoxShape3D_cgnft") + +[node name="Portal_orange" type="MeshInstance3D" parent="." node_paths=PackedStringArray("exit_portal")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 3, 2, -0.5) +mesh = ExtResource("3_0fe4d") +skeleton = NodePath("") +script = ExtResource("4_mmyl2") +vertical_viewport_resolution = 1080 +disable_viewport_distance = 32.0 +fade_out_distance_max = 30.0 +fade_out_distance_min = 28.0 +fade_out_color = Color(0, 0, 0, 1) +exit_cull_mask = 1048567 +exit_portal = NodePath("../Portal_red") + +[node name="Teleport" type="Area3D" parent="Portal_orange"] +script = ExtResource("5_1lcpk") + +[node name="CollisionShape3D" type="CollisionShape3D" parent="Portal_orange/Teleport"] +transform = Transform3D(1, 0, 4.72511e-13, 0, 1, 0, -4.72511e-13, 0, 1, 0, 0, -0.250244) +shape = SubResource("BoxShape3D_cgnft") + +[node name="Player" parent="." instance=ExtResource("6_slvs7")] +transform = Transform3D(0.727006, 0, 0.686631, 0, 1, 0, -0.686631, 0, 0.727006, 4.51826, 1.08552, 4.0716) + +[node name="OmniLight3D" type="OmniLight3D" parent="."] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -4, 3, -4) +layers = 8 +light_color = Color(1, 0.362897, 0.340022, 1) +light_energy = 3.0 +omni_range = 4.0 + +[node name="OmniLight3D2" type="OmniLight3D" parent="."] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -4, 3, 3) +light_color = Color(0, 0.729686, 0.363492, 1) +light_energy = 3.0 +omni_range = 4.0 + +[node name="OmniLight3D3" type="OmniLight3D" parent="."] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 3, 3, 3) +light_color = Color(0.887552, 0.489512, 0.22965, 1) +light_energy = 3.0 +omni_range = 4.0 + +[node name="PortalEnvironmentAdapter" type="Node" parent="." node_paths=PackedStringArray("base")] +script = ExtResource("7_yea2i") +base = NodePath("../WorldEnvironment") diff --git a/menu.gd b/menu.gd index 347780f..eed7203 100644 --- a/menu.gd +++ b/menu.gd @@ -3,12 +3,20 @@ extends Control const LEVEL_5_ROOMS = preload("res://levels/level_5rooms.tscn") const LEVEL_3_ROOMS = preload("res://levels/level_3_rooms.tscn") const LEVEL_PLATFORMER = preload("res://levels/level_platformer.tscn") +const LEVEL_SEMAPHORE_LIGHTS = preload("res://levels/level_semaphore_lights.tscn") -func _on_level_button_1_pressed() -> void: - get_tree().change_scene_to_packed(LEVEL_5_ROOMS) +@onready var items_container: VBoxContainer = $CenterContainer/ItemsContainer -func _on_level_button_2_pressed() -> void: - get_tree().change_scene_to_packed(LEVEL_3_ROOMS) +var levels = { + "Semaphore": LEVEL_3_ROOMS, + "Semaphore - Lights": LEVEL_SEMAPHORE_LIGHTS, + "5 rooms": LEVEL_5_ROOMS, + "Infinite fall": LEVEL_PLATFORMER +} -func _on_level_button_3_pressed() -> void: - get_tree().change_scene_to_packed(LEVEL_PLATFORMER) +func _ready() -> void: + for key in levels: + var b = Button.new() + items_container.add_child(b) + b.text = key + b.pressed.connect(func(): get_tree().change_scene_to_packed(levels[key])) diff --git a/menu.tscn b/menu.tscn index 38e025a..9226ffb 100644 --- a/menu.tscn +++ b/menu.tscn @@ -31,19 +31,3 @@ horizontal_alignment = 1 [node name="HSeparator" type="HSeparator" parent="CenterContainer/ItemsContainer"] layout_mode = 2 - -[node name="LevelButton_1" type="Button" parent="CenterContainer/ItemsContainer"] -layout_mode = 2 -text = "Square rooms" - -[node name="LevelButton_2" type="Button" parent="CenterContainer/ItemsContainer"] -layout_mode = 2 -text = "Semafor" - -[node name="LevelButton_3" type="Button" parent="CenterContainer/ItemsContainer"] -layout_mode = 2 -text = "Platformer" - -[connection signal="pressed" from="CenterContainer/ItemsContainer/LevelButton_1" to="." method="_on_level_button_1_pressed"] -[connection signal="pressed" from="CenterContainer/ItemsContainer/LevelButton_2" to="." method="_on_level_button_2_pressed"] -[connection signal="pressed" from="CenterContainer/ItemsContainer/LevelButton_3" to="." method="_on_level_button_3_pressed"] diff --git a/player.tscn b/player.tscn index 9e49507..105df18 100644 --- a/player.tscn +++ b/player.tscn @@ -19,6 +19,7 @@ metadata/teleportable = false [node name="Camera3D" type="Camera3D" parent="."] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.32153, 0) +cull_mask = 1048571 [node name="CollisionShape3D" type="CollisionShape3D" parent="."] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.875, 0) diff --git a/project.godot b/project.godot index 8d98fa2..9bf0227 100644 --- a/project.godot +++ b/project.godot @@ -47,3 +47,5 @@ move_back={ 3d_render/layer_1="World" 3d_render/layer_2="Portals" +3d_render/layer_3="Visible only in portals" +3d_render/layer_4="Visible only in person"