diff --git a/project.godot b/project.godot index e78137e..d888355 100644 --- a/project.godot +++ b/project.godot @@ -21,6 +21,7 @@ config/icon="res://icon.png" XRToolsUserSettings="*res://addons/godot-xr-tools/user_settings/user_settings.gd" XRToolsRumbleManager="*res://addons/godot-xr-tools/rumble/rumble_manager.gd" DebugCam="*res://addons/debug_camera/scripts/DebugCamAutoload.gd" +PerformanceSettingsSingleton="*res://scenes/performance_settings.gd" [editor] diff --git a/scenes/environment.tres b/scenes/environment.tres new file mode 100644 index 0000000..71713ca --- /dev/null +++ b/scenes/environment.tres @@ -0,0 +1,18 @@ +[gd_resource type="Environment" load_steps=2 format=3 uid="uid://c1yf8e4qr42hr"] + +[sub_resource type="Sky" id="Sky_c23dr"] + +[resource] +background_mode = 2 +sky = SubResource("Sky_c23dr") +ambient_light_color = Color(0.364084, 0.364084, 0.364084, 1) +ambient_light_sky_contribution = 0.4 +ambient_light_energy = 0.34 +tonemap_mode = 2 +glow_enabled = true +glow_normalized = true +glow_intensity = 0.22 +glow_blend_mode = 1 +volumetric_fog_enabled = true +volumetric_fog_density = 0.1744 +volumetric_fog_albedo = Color(0.60933, 0.60933, 0.60933, 1) diff --git a/scenes/manipulatorsphere.tres b/scenes/manipulatorsphere.tres index da6c4f5..9a70d56 100644 --- a/scenes/manipulatorsphere.tres +++ b/scenes/manipulatorsphere.tres @@ -63,7 +63,6 @@ void fragment() { } " -graph_offset = Vector2(-471.144, 48.9653) nodes/fragment/0/position = Vector2(620, 180) nodes/fragment/2/node = SubResource("VisualShaderNodeInput_5b52k") nodes/fragment/2/position = Vector2(-940, 280) diff --git a/scenes/performance_settings.gd b/scenes/performance_settings.gd new file mode 100644 index 0000000..c82f771 --- /dev/null +++ b/scenes/performance_settings.gd @@ -0,0 +1,34 @@ +class_name PerformanceSettings +extends Node + +var environment: Environment = preload("res://scenes/environment.tres") + +var voxel_gi_enabled := true +var bloom_enabled := true +var volumetric_fog_enabled := true + +func get_voxel_gi_enabled() -> bool: + return voxel_gi_enabled + +func _ready() -> void: + # Initialize environment settings + environment.glow_enabled = bloom_enabled + environment.volumetric_fog_enabled = volumetric_fog_enabled + _update_voxel_gi() + +func toggle_voxel_gi(enabled: bool) -> void: + voxel_gi_enabled = enabled + _update_voxel_gi() + +func toggle_bloom(enabled: bool) -> void: + bloom_enabled = enabled + environment.glow_enabled = bloom_enabled + +func toggle_volumetric_fog(enabled: bool) -> void: + volumetric_fog_enabled = enabled + environment.volumetric_fog_enabled = volumetric_fog_enabled + +func _update_voxel_gi() -> void: + var voxel_gi = get_tree().current_scene.get_node_or_null("VoxelGI") + if voxel_gi: + voxel_gi.visible = voxel_gi_enabled diff --git a/scenes/performance_settings_menu.gd b/scenes/performance_settings_menu.gd new file mode 100644 index 0000000..5f91bb5 --- /dev/null +++ b/scenes/performance_settings_menu.gd @@ -0,0 +1,14 @@ +extends Node2D + +func _ready() -> void: + %VoxelToggle.button_pressed = PerformanceSettingsSingleton.voxel_gi_enabled + %VoxelToggle.toggled.connect(PerformanceSettingsSingleton.toggle_voxel_gi) + + %BloomToggle.button_pressed = PerformanceSettingsSingleton.bloom_enabled + %BloomToggle.toggled.connect(PerformanceSettingsSingleton.toggle_bloom) + + %VolumetricFogToggle.button_pressed = PerformanceSettingsSingleton.volumetric_fog_enabled + %VolumetricFogToggle.toggled.connect(PerformanceSettingsSingleton.toggle_volumetric_fog) + +func _process(_delta: float) -> void: + %FpsIndicator.text = "FPS: %d" % Engine.get_frames_per_second() diff --git a/scenes/performance_settings_menu.tscn b/scenes/performance_settings_menu.tscn new file mode 100644 index 0000000..e30b0ad --- /dev/null +++ b/scenes/performance_settings_menu.tscn @@ -0,0 +1,72 @@ +[gd_scene load_steps=2 format=3 uid="uid://cyd8poa47ir2i"] + +[ext_resource type="Script" path="res://scenes/performance_settings_menu.gd" id="1_20qfm"] + +[node name="PerformanceSettingsMenu" type="Node2D"] +script = ExtResource("1_20qfm") + +[node name="MarginContainer" type="MarginContainer" parent="."] +offset_right = 40.0 +offset_bottom = 40.0 + +[node name="ColorRect" type="ColorRect" parent="MarginContainer"] +layout_mode = 2 +color = Color(0, 0, 0, 1) + +[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer"] +layout_mode = 2 +size_flags_horizontal = 3 +size_flags_vertical = 3 + +[node name="Label" type="Label" parent="MarginContainer/VBoxContainer"] +layout_mode = 2 +text = "Performance Settings" +horizontal_alignment = 1 + +[node name="FpsIndicator" type="Label" parent="MarginContainer/VBoxContainer"] +unique_name_in_owner = true +layout_mode = 2 +text = "current fps" +horizontal_alignment = 1 + +[node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer/VBoxContainer"] +layout_mode = 2 + +[node name="Label3" type="Label" parent="MarginContainer/VBoxContainer/HBoxContainer"] +layout_mode = 2 +text = "Enable VoxelGI" +horizontal_alignment = 1 + +[node name="VoxelToggle" type="CheckButton" parent="MarginContainer/VBoxContainer/HBoxContainer"] +unique_name_in_owner = true +layout_mode = 2 +size_flags_horizontal = 3 +button_pressed = true + +[node name="HBoxContainer2" type="HBoxContainer" parent="MarginContainer/VBoxContainer"] +layout_mode = 2 + +[node name="Label3" type="Label" parent="MarginContainer/VBoxContainer/HBoxContainer2"] +layout_mode = 2 +text = "Enable Volumetric Fog" +horizontal_alignment = 1 + +[node name="VolumetricFogToggle" type="CheckButton" parent="MarginContainer/VBoxContainer/HBoxContainer2"] +unique_name_in_owner = true +layout_mode = 2 +size_flags_horizontal = 3 +button_pressed = true + +[node name="HBoxContainer3" type="HBoxContainer" parent="MarginContainer/VBoxContainer"] +layout_mode = 2 + +[node name="Label3" type="Label" parent="MarginContainer/VBoxContainer/HBoxContainer3"] +layout_mode = 2 +text = "Enable Bloom" +horizontal_alignment = 1 + +[node name="BloomToggle" type="CheckButton" parent="MarginContainer/VBoxContainer/HBoxContainer3"] +unique_name_in_owner = true +layout_mode = 2 +size_flags_horizontal = 3 +button_pressed = true diff --git a/scenes/title_scene.tscn b/scenes/title_scene.tscn index 63b5de5..d7cd3e2 100644 --- a/scenes/title_scene.tscn +++ b/scenes/title_scene.tscn @@ -1,32 +1,19 @@ -[gd_scene load_steps=32 format=3 uid="uid://bd86thqpujh3p"] +[gd_scene load_steps=35 format=3 uid="uid://bd86thqpujh3p"] [ext_resource type="Script" path="res://addons/godot-xr-tools/staging/scene_base.gd" id="1_t86sx"] [ext_resource type="PackedScene" uid="uid://7uc6tf2tvn1k" path="res://scenes/xr_origin_3d.tscn" id="2_xk21l"] [ext_resource type="PackedScene" uid="uid://clc5dre31iskm" path="res://addons/godot-xr-tools/xr/start_xr.tscn" id="3_hdcpx"] +[ext_resource type="Environment" uid="uid://c1yf8e4qr42hr" path="res://scenes/environment.tres" id="3_v4538"] [ext_resource type="PackedScene" uid="uid://57q7hhomocdh" path="res://addons/godot-xr-tools/objects/world_grab_area.tscn" id="4_nruf2"] [ext_resource type="VoxelGIData" uid="uid://bxphdae7hohsh" path="res://scenes/title_scene.VoxelGI_data.res" id="5_ebg1r"] [ext_resource type="CompressedTexture3D" uid="uid://c6uya54wegrle" path="res://scenes/title_scene.GPUParticlesCollisionSDF3D_data.exr" id="6_l378m"] [ext_resource type="PackedScene" uid="uid://rsrnbs08nv1n" path="res://scenes/proxy_collision_detector.tscn" id="7_1kkxh"] +[ext_resource type="Script" path="res://scenes/voxel_gi_toggle.gd" id="7_4p11s"] [ext_resource type="PackedScene" uid="uid://c20kawop2lrv" path="res://assets/Arcane Source 2.glb" id="8_h17hj"] [ext_resource type="Script" path="res://scenes/target_highlight_test.gd" id="9_jig6v"] [ext_resource type="PackedScene" uid="uid://bixan352mi1j6" path="res://scenes/manipulator.tscn" id="10_dms3y"] - -[sub_resource type="Sky" id="Sky_c23dr"] - -[sub_resource type="Environment" id="Environment_vgkyp"] -background_mode = 2 -sky = SubResource("Sky_c23dr") -ambient_light_color = Color(0.364084, 0.364084, 0.364084, 1) -ambient_light_sky_contribution = 0.4 -ambient_light_energy = 0.34 -tonemap_mode = 2 -glow_enabled = true -glow_normalized = true -glow_intensity = 0.22 -glow_blend_mode = 1 -volumetric_fog_enabled = true -volumetric_fog_density = 0.1744 -volumetric_fog_albedo = Color(0.60933, 0.60933, 0.60933, 1) +[ext_resource type="PackedScene" uid="uid://clujaf3u776a3" path="res://addons/godot-xr-tools/objects/viewport_2d_in_3d.tscn" id="13_ab6mb"] +[ext_resource type="PackedScene" uid="uid://cyd8poa47ir2i" path="res://scenes/performance_settings_menu.tscn" id="14_s5dwy"] [sub_resource type="StandardMaterial3D" id="StandardMaterial3D_lvd12"] albedo_color = Color(0.563626, 0.563626, 0.563625, 1) @@ -136,13 +123,16 @@ size = Vector3(0.2, 0.2, 0.2) emission_enabled = true emission = Color(0.208505, 0.70691, 0.626474, 1) +[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_a5rjy"] +shading_mode = 0 + [node name="TitleScene" type="Node3D"] script = ExtResource("1_t86sx") [node name="XROrigin3D" parent="." instance=ExtResource("2_xk21l")] [node name="WorldEnvironment" type="WorldEnvironment" parent="."] -environment = SubResource("Environment_vgkyp") +environment = ExtResource("3_v4538") [node name="Floor" type="MeshInstance3D" parent="."] mesh = SubResource("PlaneMesh_gsjte") @@ -173,6 +163,7 @@ shape = SubResource("BoxShape3D_gj4t1") transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.785156, -6.01978) size = Vector3(31, 6.57, 31) data = ExtResource("5_ebg1r") +script = ExtResource("7_4p11s") [node name="GPUParticles3D" type="GPUParticles3D" parent="."] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -5.26492, 1.52311, -8.99933) @@ -253,6 +244,15 @@ mesh = SubResource("PrismMesh_be80n") skeleton = NodePath("../../..") surface_material_override/0 = SubResource("StandardMaterial3D_hyt1m") +[node name="Viewport2Din3D" parent="." instance=ExtResource("13_ab6mb")] +transform = Transform3D(0.866025, 0, -0.5, 0, 1, 0, 0.5, 0, 0.866025, 5.61352, 2, -3) +screen_size = Vector2(2.5, 1.5) +scene = ExtResource("14_s5dwy") +viewport_size = Vector2(250, 150) +update_mode = 2 +material = SubResource("StandardMaterial3D_a5rjy") +scene_properties_keys = PackedStringArray("performance_settings_menu.gd") + [connection signal="target_occupancy_changed" from="ProxyCollisionDetector" to="Target" method="_on_proxy_collision_detector_target_occupancy_changed"] [connection signal="target_occupancy_changed" from="ProxyCollisionDetector" to="Target2" method="_on_proxy_collision_detector_target_occupancy_changed"] diff --git a/scenes/voxel_gi_toggle.gd b/scenes/voxel_gi_toggle.gd new file mode 100644 index 0000000..03b44c7 --- /dev/null +++ b/scenes/voxel_gi_toggle.gd @@ -0,0 +1,5 @@ +extends VoxelGI + +func _ready() -> void: + # toggle according to the singleton settings. + visible = PerformanceSettingsSingleton.voxel_gi_enabled diff --git a/scenes/xr_origin_3d.tscn b/scenes/xr_origin_3d.tscn index 991ece9..a2e07bb 100644 --- a/scenes/xr_origin_3d.tscn +++ b/scenes/xr_origin_3d.tscn @@ -1,8 +1,9 @@ -[gd_scene load_steps=9 format=3 uid="uid://7uc6tf2tvn1k"] +[gd_scene load_steps=10 format=3 uid="uid://7uc6tf2tvn1k"] [ext_resource type="PackedScene" uid="uid://bq86r4yll8po" path="res://addons/godot-xr-tools/hands/scenes/lowpoly/left_fullglove_low.tscn" id="1_gehoc"] [ext_resource type="PackedScene" uid="uid://b4ysuy43poobf" path="res://addons/godot-xr-tools/functions/function_pickup.tscn" id="2_sqnjc"] [ext_resource type="PackedScene" uid="uid://xqimcf20s2jp" path="res://addons/godot-xr-tools/hands/scenes/lowpoly/right_fullglove_low.tscn" id="3_7rd4f"] +[ext_resource type="PackedScene" uid="uid://cqhw276realc" path="res://addons/godot-xr-tools/functions/function_pointer.tscn" id="3_gwcr3"] [ext_resource type="PackedScene" uid="uid://dg3gr6ofd8yx4" path="res://addons/godot-xr-tools/functions/movement_world_grab.tscn" id="4_ou5a5"] [ext_resource type="PackedScene" uid="uid://diyu06cw06syv" path="res://addons/godot-xr-tools/player/player_body.tscn" id="5_ug2p8"] [ext_resource type="Script" path="res://addons/godot-xr-tools/overrides/ground_physics_settings.gd" id="6_2gwa8"] @@ -36,6 +37,10 @@ tracker = &"left_hand" grab_distance = 0.1 ranged_enable = false +[node name="FunctionPointer" parent="LeftHand" instance=ExtResource("3_gwcr3")] +show_laser = 2 +laser_length = 1 + [node name="RightHand" type="XRController3D" parent="."] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.25, 1, 0) tracker = &"right_hand" @@ -46,6 +51,10 @@ tracker = &"right_hand" grab_distance = 0.1 ranged_enable = false +[node name="FunctionPointer" parent="RightHand" instance=ExtResource("3_gwcr3")] +show_laser = 2 +laser_length = 1 + [node name="MovementWorldGrab" parent="." instance=ExtResource("4_ou5a5")] order = 5 world_scale_min = 0.01