From 91ea645579f28840ebe6a6ad2b80e37ef7fc0163 Mon Sep 17 00:00:00 2001 From: Zireael07 Date: Thu, 27 Jan 2022 15:50:41 +0100 Subject: [PATCH] fix: replace the 3.x sky with a vulkan setup (fixes performance issue) --- game/Spatial_simple.tscn | 19 +++++++-------- game/vulkan sky/Node3D.tscn | 37 +++-------------------------- game/vulkan sky/vulkan_sky_env.tres | 31 ++++++++++++++++++++++++ 3 files changed, 43 insertions(+), 44 deletions(-) create mode 100644 game/vulkan sky/vulkan_sky_env.tres diff --git a/game/Spatial_simple.tscn b/game/Spatial_simple.tscn index 7bedbb1..09eb632 100644 --- a/game/Spatial_simple.tscn +++ b/game/Spatial_simple.tscn @@ -1,12 +1,11 @@ -[gd_scene load_steps=9 format=3 uid="uid://do1x8k5fq0jtp"] +[gd_scene load_steps=8 format=3 uid="uid://do1x8k5fq0jtp"] [ext_resource type="PackedScene" uid="uid://bh5qfdgmv1k1t" path="res://roads/road_segment_straight.tscn" id="1"] [ext_resource type="PackedScene" uid="uid://e6fhyicompkr" path="res://roads/road_segment.tscn" id="2"] -[ext_resource type="Environment" path="res://dynamic_env.tres" id="3"] +[ext_resource type="Script" path="res://vulkan sky/daynight.gd" id="2_r7md2"] +[ext_resource type="Environment" uid="uid://c56vuaipcdg3k" path="res://vulkan sky/vulkan_sky_env.tres" id="3_6h6kk"] [ext_resource type="PackedScene" path="res://roads/intersection.tscn" id="4"] -[ext_resource type="Script" path="res://scripts/WorldEnvironment.gd" id="7"] [ext_resource type="PackedScene" uid="uid://caucweey32fbc" path="res://car/kinematics/kinematic_car_base.tscn" id="9"] -[ext_resource type="PackedScene" path="res://dynamic_sky/scene.tscn" id="10"] [sub_resource type="BoxShape3D" id="1"] size = Vector3(400, 0.1, 400) @@ -24,14 +23,14 @@ shape = SubResource( "1" ) [node name="city" type="Node3D" parent="."] -[node name="scene" parent="city" instance=ExtResource( "10" )] +[node name="scene" type="Node3D" parent="city"] +script = ExtResource( "2_r7md2" ) -[node name="WorldEnvironment" type="WorldEnvironment" parent="city"] -environment = ExtResource( "3" ) -script = ExtResource( "7" ) +[node name="WorldEnvironment" type="WorldEnvironment" parent="city/scene"] +environment = ExtResource( "3_6h6kk" ) -[node name="DirectionalLight3D" type="DirectionalLight3D" parent="city"] -transform = Transform3D(1, 0, 0, 0, -0.766044, 0.642788, 0, -0.642788, -0.766044, 0, 18.629, 0) +[node name="DirectionalLight3D" type="DirectionalLight3D" parent="city/scene"] +transform = Transform3D(1, 0, 0, 0, 0.866025, 0.5, 0, -0.5, 0.866025, 0, 18.629, 0) shadow_enabled = true shadow_bias = 0.0 shadow_reverse_cull_face = true diff --git a/game/vulkan sky/Node3D.tscn b/game/vulkan sky/Node3D.tscn index 27e6b70..3f53828 100644 --- a/game/vulkan sky/Node3D.tscn +++ b/game/vulkan sky/Node3D.tscn @@ -1,48 +1,17 @@ -[gd_scene load_steps=7 format=3 uid="uid://cdnw34xyuxbh1"] +[gd_scene load_steps=3 format=3 uid="uid://cdnw34xyuxbh1"] -[ext_resource type="Texture2D" uid="uid://ds5nliexnxvyd" path="res://vulkan sky/textures/noise.png" id="1_5uyfw"] [ext_resource type="Script" path="res://vulkan sky/daynight.gd" id="1_7qdev"] -[ext_resource type="Shader" uid="uid://btotycw2uifv3" path="res://vulkan sky/sky_custom.tres" id="1_xbnim"] - -[sub_resource type="ShaderMaterial" id="ShaderMaterial_n3wus"] -shader = ExtResource( "1_xbnim" ) -shader_param/sky_top_color = Color(0.35, 0.46, 0.71, 1) -shader_param/sky_horizon_color = Color(0.55, 0.69, 0.81, 1) -shader_param/sky_curve = 0.09 -shader_param/sky_energy = 1.0 -shader_param/ground_bottom_color = Color(0.12, 0.12, 0.13, 1) -shader_param/ground_horizon_color = Color(0.37, 0.33, 0.31, 1) -shader_param/ground_curve = 0.02 -shader_param/ground_energy = 1.0 -shader_param/sun_angle_max = 1.74 -shader_param/sun_curve = 0.05 -shader_param/COVERAGE = 0.535 -shader_param/clouds_tex = ExtResource( "1_5uyfw" ) - -[sub_resource type="Sky" id="Sky_y75us"] -sky_material = SubResource( "ShaderMaterial_n3wus" ) -process_mode = 3 -radiance_size = 0 - -[sub_resource type="Environment" id="Environment_r1ciq"] -background_mode = 2 -sky = SubResource( "Sky_y75us" ) -ambient_light_color = Color(1, 1, 1, 1) -glow_hdr_threshold = 2.2 -fog_light_color = Color(0.0221679, 0.0337797, 0.0744209, 1) +[ext_resource type="Environment" uid="uid://c56vuaipcdg3k" path="res://vulkan sky/vulkan_sky_env.tres" id="2_46w70"] [node name="Node3D" type="Node3D"] script = ExtResource( "1_7qdev" ) [node name="WorldEnvironment" type="WorldEnvironment" parent="."] -environment = SubResource( "Environment_r1ciq" ) -script = null +environment = ExtResource( "2_46w70" ) [node name="DirectionalLight3D" type="DirectionalLight3D" parent="."] transform = Transform3D(1, 0, 0, 0, 0.866024, 0.499999, 0, -0.499999, 0.866024, 0, 0, 0) light_color = Color(1, 0.878431, 0.329412, 1) -script = null [node name="Camera3D" type="Camera3D" parent="."] transform = Transform3D(-1, 0, -8.74228e-08, 0, 1, 0, 8.74228e-08, 0, -1, 0, 1, 0) -script = null diff --git a/game/vulkan sky/vulkan_sky_env.tres b/game/vulkan sky/vulkan_sky_env.tres new file mode 100644 index 0000000..061bf10 --- /dev/null +++ b/game/vulkan sky/vulkan_sky_env.tres @@ -0,0 +1,31 @@ +[gd_resource type="Environment" load_steps=5 format=3 uid="uid://c56vuaipcdg3k"] + +[ext_resource type="Shader" uid="uid://btotycw2uifv3" path="res://vulkan sky/sky_custom.tres" id="1_jwecp"] +[ext_resource type="Texture2D" uid="uid://ds5nliexnxvyd" path="res://vulkan sky/textures/noise.png" id="2_v4vqf"] + +[sub_resource type="ShaderMaterial" id="ShaderMaterial_n3wus"] +shader = ExtResource( "1_jwecp" ) +shader_param/sky_top_color = Color(0.35, 0.46, 0.71, 1) +shader_param/sky_horizon_color = Color(0.55, 0.69, 0.81, 1) +shader_param/sky_curve = 0.09 +shader_param/sky_energy = 1.0 +shader_param/ground_bottom_color = Color(0.12, 0.12, 0.13, 1) +shader_param/ground_horizon_color = Color(0.37, 0.33, 0.31, 1) +shader_param/ground_curve = 0.02 +shader_param/ground_energy = 1.0 +shader_param/sun_angle_max = 1.74 +shader_param/sun_curve = 0.05 +shader_param/COVERAGE = 0.535 +shader_param/clouds_tex = ExtResource( "2_v4vqf" ) + +[sub_resource type="Sky" id="Sky_y75us"] +sky_material = SubResource( "ShaderMaterial_n3wus" ) +process_mode = 3 +radiance_size = 0 + +[resource] +background_mode = 2 +sky = SubResource( "Sky_y75us" ) +ambient_light_color = Color(1, 1, 1, 1) +glow_hdr_threshold = 2.2 +fog_light_color = Color(0.0221679, 0.0337797, 0.0744209, 1)