new terrain plugin

This commit is contained in:
Nikolai Fesenko
2025-08-13 21:08:35 +02:00
parent 43fb8410c3
commit 85d50d3bd4
221 changed files with 11867 additions and 1 deletions

View File

@@ -0,0 +1,42 @@
[gd_scene load_steps=8 format=3 uid="uid://cofnhdcclon1w"]
[ext_resource type="Script" path="res://demo/src/CodeGenerated.gd" id="1_h7vyv"]
[ext_resource type="PackedScene" uid="uid://domhm87hbhbg1" path="res://demo/components/Player.tscn" id="2_3v2uf"]
[ext_resource type="PackedScene" uid="uid://bb2lp50sjndus" path="res://demo/components/Environment.tscn" id="3_71ikj"]
[ext_resource type="PackedScene" uid="uid://di5fovhcyd7re" path="res://demo/components/Enemy.tscn" id="4_p8qry"]
[ext_resource type="PackedScene" uid="uid://d2jihfohphuue" path="res://demo/components/UI.tscn" id="4_x5ge4"]
[ext_resource type="Script" path="res://demo/src/RuntimeNavigationBaker.gd" id="5_445ur"]
[sub_resource type="NavigationMesh" id="NavigationMesh_vs6am"]
geometry_parsed_geometry_type = 1
agent_height = 2.0
agent_max_slope = 30.0
[node name="CodeGenerated" type="Node"]
script = ExtResource("1_h7vyv")
[node name="Environment" parent="." instance=ExtResource("3_71ikj")]
[node name="Player" parent="." instance=ExtResource("2_3v2uf")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 50, 0)
[node name="Enemy" parent="." node_paths=PackedStringArray("target") instance=ExtResource("4_p8qry")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 10, 50, -10)
target = NodePath("../Player")
[node name="UI" parent="." instance=ExtResource("4_x5ge4")]
[node name="RuntimeNavigationBaker" type="Node" parent="." node_paths=PackedStringArray("player")]
script = ExtResource("5_445ur")
enabled = false
template = SubResource("NavigationMesh_vs6am")
player = NodePath("../Player")
[node name="RunThisSceneLabel3D" type="Label3D" parent="."]
pixel_size = 0.001
billboard = 1
no_depth_test = true
fixed_size = true
text = "Run This Scene"
font_size = 64
outline_size = 10

99
demo/Demo.tscn Normal file
View File

@@ -0,0 +1,99 @@
[gd_scene load_steps=13 format=3 uid="uid://chol2xlfbq7cu"]
[ext_resource type="Script" uid="uid://chstoagn42gbr" path="res://demo/src/DemoScene.gd" id="1_k7qca"]
[ext_resource type="PackedScene" uid="uid://d2jihfohphuue" path="res://demo/components/UI.tscn" id="2_nqak5"]
[ext_resource type="PackedScene" uid="uid://dwnhqfjq7v1pq" path="res://demo/components/Borders.tscn" id="3_cw38j"]
[ext_resource type="PackedScene" uid="uid://domhm87hbhbg1" path="res://demo/components/Player.tscn" id="3_ht63y"]
[ext_resource type="PackedScene" uid="uid://djhl3foqkj4e2" path="res://demo/components/Tunnel.tscn" id="3_kdh0b"]
[ext_resource type="PackedScene" uid="uid://bb2lp50sjndus" path="res://demo/components/Environment.tscn" id="3_yqldq"]
[ext_resource type="PackedScene" uid="uid://d3sr0a7dxfkr8" path="res://addons/terrain_3d/extras/particle_example/Terrain3DParticles.tscn" id="8_fwrtk"]
[ext_resource type="Terrain3DAssets" uid="uid://dal3jhw6241qg" path="res://demo/data/assets.tres" id="8_g2of2"]
[sub_resource type="Gradient" id="Gradient_vr1m7"]
offsets = PackedFloat32Array(0.2, 1)
colors = PackedColorArray(1, 1, 1, 1, 0, 0, 0, 1)
[sub_resource type="FastNoiseLite" id="FastNoiseLite_d8lcj"]
noise_type = 2
frequency = 0.03
cellular_jitter = 3.0
cellular_return_type = 0
domain_warp_enabled = true
domain_warp_type = 1
domain_warp_amplitude = 50.0
domain_warp_fractal_type = 2
domain_warp_fractal_lacunarity = 1.5
domain_warp_fractal_gain = 1.0
[sub_resource type="NoiseTexture2D" id="NoiseTexture2D_bov7h"]
seamless = true
color_ramp = SubResource("Gradient_vr1m7")
noise = SubResource("FastNoiseLite_d8lcj")
[sub_resource type="Terrain3DMaterial" id="Terrain3DMaterial_jrc01"]
_shader_parameters = {
"_mouse_layer": 2147483648,
"auto_base_texture": 0,
"auto_height_reduction": 0.05,
"auto_overlay_texture": 1,
"auto_slope": 0.45,
"bias_distance": 512.0,
"blend_sharpness": 0.5,
"depth_blur": 0.0,
"dual_scale_far": 170.0,
"dual_scale_near": 100.0,
"dual_scale_reduction": 0.3,
"dual_scale_texture": 0,
"enable_macro_variation": true,
"enable_projection": true,
&"flat_terrain_normals": false,
"macro_variation1": Color(0.855, 0.8625, 0.9, 1),
"macro_variation2": Color(0.9, 0.885, 0.81, 1),
"macro_variation_slope": 0.333,
"mipmap_bias": 1.0,
"noise1_angle": 0.1,
"noise1_offset": Vector2(0.5, 0.5),
"noise1_scale": 0.04,
"noise2_scale": 0.076,
"noise_texture": SubResource("NoiseTexture2D_bov7h"),
"projection_threshold": 0.87,
"tri_scale_reduction": 0.3,
"world_noise_fragment_normals": false,
"world_noise_height": 34.0,
"world_noise_lod_distance": 7500.0,
"world_noise_max_octaves": 4,
"world_noise_min_octaves": 2,
"world_noise_offset": Vector3(2.17, -1.225, 1.9),
"world_noise_region_blend": 0.33,
"world_noise_scale": 9.85
}
world_background = 2
auto_shader = true
dual_scaling = true
[node name="Demo" type="Node"]
script = ExtResource("1_k7qca")
[node name="UI" parent="." instance=ExtResource("2_nqak5")]
[node name="Environment" parent="." instance=ExtResource("3_yqldq")]
[node name="Borders" parent="." instance=ExtResource("3_cw38j")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 512, -3, 512)
collision_mask = 3
[node name="Tunnel" parent="." instance=ExtResource("3_kdh0b")]
[node name="Player" parent="." instance=ExtResource("3_ht63y")]
transform = Transform3D(0.176947, 0, -0.98422, 0, 1, 0, 0.98422, 0, 0.176947, 223.143, 105.348, -1833.08)
[node name="Terrain3D" type="Terrain3D" parent="."]
data_directory = "res://demo/data"
material = SubResource("Terrain3DMaterial_jrc01")
assets = ExtResource("8_g2of2")
collision_mask = 3
top_level = true
metadata/_edit_lock_ = true
[node name="Terrain3DParticles" parent="Terrain3D" node_paths=PackedStringArray("terrain") instance=ExtResource("8_fwrtk")]
terrain = NodePath("..")

98
demo/NavigationDemo.tscn Normal file
View File

@@ -0,0 +1,98 @@
[gd_scene load_steps=14 format=3 uid="uid://x34e4v60vdmy"]
[ext_resource type="Script" path="res://demo/src/DemoScene.gd" id="1_po4vw"]
[ext_resource type="PackedScene" uid="uid://bb2lp50sjndus" path="res://demo/components/Environment.tscn" id="2_i74wg"]
[ext_resource type="PackedScene" uid="uid://dwnhqfjq7v1pq" path="res://demo/components/Borders.tscn" id="3_3upu0"]
[ext_resource type="PackedScene" uid="uid://domhm87hbhbg1" path="res://demo/components/Player.tscn" id="4_fk3ul"]
[ext_resource type="PackedScene" uid="uid://djhl3foqkj4e2" path="res://demo/components/Tunnel.tscn" id="5_2lvlr"]
[ext_resource type="PackedScene" uid="uid://d2jihfohphuue" path="res://demo/components/UI.tscn" id="5_rc7e2"]
[ext_resource type="NavigationMesh" uid="uid://yf3fu23666k8" path="res://demo/data/nav_mesh.res" id="8_6jfdr"]
[ext_resource type="Terrain3DAssets" uid="uid://dal3jhw6241qg" path="res://demo/data/assets.tres" id="10_qmhh8"]
[ext_resource type="PackedScene" uid="uid://di5fovhcyd7re" path="res://demo/components/Enemy.tscn" id="12_b2xl8"]
[sub_resource type="Gradient" id="Gradient_vr1m7"]
offsets = PackedFloat32Array(0.2, 1)
colors = PackedColorArray(1, 1, 1, 1, 0, 0, 0, 1)
[sub_resource type="FastNoiseLite" id="FastNoiseLite_d8lcj"]
noise_type = 2
frequency = 0.03
cellular_jitter = 3.0
cellular_return_type = 0
domain_warp_enabled = true
domain_warp_type = 1
domain_warp_amplitude = 50.0
domain_warp_fractal_type = 2
domain_warp_fractal_lacunarity = 1.5
domain_warp_fractal_gain = 1.0
[sub_resource type="NoiseTexture2D" id="NoiseTexture2D_bov7h"]
seamless = true
color_ramp = SubResource("Gradient_vr1m7")
noise = SubResource("FastNoiseLite_d8lcj")
[sub_resource type="Terrain3DMaterial" id="Terrain3DMaterial_s5mq5"]
_shader_parameters = {
"_mouse_layer": 2147483648,
"auto_base_texture": 0,
"auto_height_reduction": 0.1,
"auto_overlay_texture": 1,
"auto_slope": 1.0,
"bias_distance": 512.0,
"blend_sharpness": 0.87,
"depth_blur": 0.0,
"dual_scale_far": 170.0,
"dual_scale_near": 100.0,
"dual_scale_reduction": 0.3,
"dual_scale_texture": 0,
"enable_macro_variation": true,
"enable_projection": true,
"height_blending": true,
"macro_variation1": Color(0.878431, 0.862745, 0.901961, 1),
"macro_variation2": Color(0.898039, 0.898039, 0.803922, 1),
"macro_variation_slope": 0.333,
"mipmap_bias": 1.0,
"noise1_angle": 0.1,
"noise1_offset": Vector2(0.5, 0.5),
"noise1_scale": 0.04,
"noise2_scale": 0.076,
"noise3_scale": 0.225,
"noise_texture": SubResource("NoiseTexture2D_bov7h"),
"projection_angular_division": 1.436,
"projection_threshold": 0.8,
"tri_scale_reduction": 0.3
}
world_background = 0
auto_shader = true
dual_scaling = true
[node name="Demo" type="Node"]
script = ExtResource("1_po4vw")
[node name="UI" parent="." instance=ExtResource("5_rc7e2")]
[node name="Environment" parent="." instance=ExtResource("2_i74wg")]
[node name="Borders" parent="." instance=ExtResource("3_3upu0")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 512, -2.5, 512)
[node name="Tunnel" parent="." instance=ExtResource("5_2lvlr")]
[node name="Player" parent="." instance=ExtResource("4_fk3ul")]
transform = Transform3D(0.0774673, 0, -0.996995, 0, 1, 0, 0.996995, 0, 0.0774673, 229.418, 104.956, -1838.16)
[node name="Enemy" parent="." node_paths=PackedStringArray("target") instance=ExtResource("12_b2xl8")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 192.727, 105.171, -1787.81)
target = NodePath("../Player")
[node name="NavigationRegion3D" type="NavigationRegion3D" parent="."]
navigation_mesh = ExtResource("8_6jfdr")
[node name="Terrain3D" type="Terrain3D" parent="NavigationRegion3D"]
data_directory = "res://demo/data"
material = SubResource("Terrain3DMaterial_s5mq5")
assets = ExtResource("10_qmhh8")
collision_mask = 3
mesh_size = 64
top_level = true
metadata/_edit_lock_ = true

View File

@@ -0,0 +1,25 @@
[gd_resource type="StandardMaterial3D" load_steps=2 format=3 uid="uid://fkhkir6t1hml"]
[ext_resource type="Texture2D" uid="uid://c307hdmos4gtm" path="res://demo/assets/textures/rock023_nrm_rgh.png" id="2_3is54"]
[resource]
transparency = 1
vertex_color_use_as_albedo = true
albedo_color = Color(0.4, 1, 1, 0.647059)
metallic_specular = 1.0
roughness = 0.2
roughness_texture = ExtResource("2_3is54")
roughness_texture_channel = 3
emission_enabled = true
emission = Color(0, 0.145098, 0.776471, 1)
emission_energy_multiplier = 1.4
normal_enabled = true
normal_scale = 0.4
normal_texture = ExtResource("2_3is54")
rim_enabled = true
rim = 0.25
clearcoat_roughness = 0.0
ao_light_affect = 1.0
ao_texture_channel = 3
refraction_enabled = true
refraction_scale = -0.1

View File

@@ -0,0 +1,24 @@
[gd_resource type="StandardMaterial3D" load_steps=2 format=3 uid="uid://cso4f2iyuxpmc"]
[ext_resource type="Texture2D" uid="uid://c307hdmos4gtm" path="res://demo/assets/textures/rock023_nrm_rgh.png" id="2_1t610"]
[resource]
transparency = 1
vertex_color_use_as_albedo = true
albedo_color = Color(0.4, 0.4, 1, 0.556863)
metallic_specular = 1.0
roughness = 0.2
roughness_texture = ExtResource("2_1t610")
roughness_texture_channel = 3
emission_enabled = true
emission = Color(0.235294, 0.145098, 0.776471, 1)
normal_enabled = true
normal_scale = 0.4
normal_texture = ExtResource("2_1t610")
rim_enabled = true
rim = 0.25
clearcoat_roughness = 0.0
ao_light_affect = 1.0
ao_texture_channel = 3
refraction_enabled = true
refraction_scale = -0.1

View File

@@ -0,0 +1,24 @@
[gd_resource type="StandardMaterial3D" load_steps=2 format=3 uid="uid://ickkffutwcvo"]
[ext_resource type="Texture2D" uid="uid://c307hdmos4gtm" path="res://demo/assets/textures/rock023_nrm_rgh.png" id="2_k2yhv"]
[resource]
transparency = 1
albedo_color = Color(0.670588, 0.0588235, 0.384314, 0.509804)
metallic_specular = 1.0
roughness = 0.2
roughness_texture = ExtResource("2_k2yhv")
roughness_texture_channel = 3
emission_enabled = true
emission = Color(0.258824, 0.0823529, 0.25098, 1)
normal_enabled = true
normal_scale = 0.4
normal_texture = ExtResource("2_k2yhv")
rim_enabled = true
rim = 0.25
clearcoat_roughness = 0.0
ao_enabled = true
ao_light_affect = 1.0
ao_texture_channel = 3
refraction_enabled = true
refraction_scale = -0.1

View File

@@ -0,0 +1,17 @@
[gd_resource type="StandardMaterial3D" load_steps=3 format=3 uid="uid://d0hyi5n6ng25w"]
[ext_resource type="Texture2D" uid="uid://c88j3oj0lf6om" path="res://demo/assets/textures/rock023_alb_ht.png" id="1_1js8i"]
[ext_resource type="Texture2D" uid="uid://c307hdmos4gtm" path="res://demo/assets/textures/rock023_nrm_rgh.png" id="2_snl3x"]
[resource]
albedo_color = Color(0.501406, 0.501407, 0.501406, 1)
albedo_texture = ExtResource("1_1js8i")
roughness = 0.95
roughness_texture = ExtResource("2_snl3x")
roughness_texture_channel = 3
normal_enabled = true
normal_texture = ExtResource("2_snl3x")
uv1_scale = Vector3(0.4, 0.4, 0.4)
uv1_triplanar = true
uv1_world_triplanar = true
texture_filter = 5

View File

@@ -0,0 +1,16 @@
[gd_resource type="StandardMaterial3D" load_steps=3 format=3 uid="uid://nbbdrx8vma80"]
[ext_resource type="Texture2D" uid="uid://c88j3oj0lf6om" path="res://demo/assets/textures/rock023_alb_ht.png" id="1_mek0c"]
[ext_resource type="Texture2D" uid="uid://c307hdmos4gtm" path="res://demo/assets/textures/rock023_nrm_rgh.png" id="2_pp13c"]
[resource]
vertex_color_use_as_albedo = true
albedo_color = Color(0.83, 0.83, 0.83, 1)
albedo_texture = ExtResource("1_mek0c")
normal_enabled = true
normal_texture = ExtResource("2_pp13c")
uv1_scale = Vector3(0.02, 0.02, 0.02)
uv1_triplanar = true
uv1_triplanar_sharpness = 6.06286
uv1_world_triplanar = true
texture_filter = 5

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,56 @@
[gd_scene load_steps=9 format=3 uid="uid://bn5nf4esciwex"]
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_788j8"]
albedo_color = Color(1, 0, 0, 1)
[sub_resource type="SphereMesh" id="SphereMesh_u4ac2"]
material = SubResource("StandardMaterial3D_788j8")
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_3i52q"]
albedo_color = Color(1, 0.540167, 0.11, 1)
[sub_resource type="BoxMesh" id="BoxMesh_xyuxq"]
material = SubResource("StandardMaterial3D_3i52q")
size = Vector3(0.85, 0.85, 0.85)
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_p0ha4"]
albedo_color = Color(0.48, 1, 0.497333, 1)
[sub_resource type="PrismMesh" id="PrismMesh_xnm4h"]
material = SubResource("StandardMaterial3D_p0ha4")
size = Vector3(1, 1, 0.855)
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_4koei"]
albedo_color = Color(0.45, 0.596667, 1, 1)
[sub_resource type="CylinderMesh" id="CylinderMesh_dp7xj"]
material = SubResource("StandardMaterial3D_4koei")
top_radius = 0.0
bottom_radius = 0.34
height = 1.54
radial_segments = 4
[node name="TestMultimesh" type="Node3D"]
[node name="Node3D" type="Node3D" parent="."]
[node name="MeshInstance3D1" type="MeshInstance3D" parent="Node3D"]
mesh = SubResource("SphereMesh_u4ac2")
skeleton = NodePath("../..")
[node name="MeshInstance3D2" type="MeshInstance3D" parent="Node3D"]
visible = false
mesh = SubResource("BoxMesh_xyuxq")
skeleton = NodePath("../..")
[node name="MeshInstance3D3" type="MeshInstance3D" parent="Node3D"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.118133, 0)
visible = false
mesh = SubResource("PrismMesh_xnm4h")
skeleton = NodePath("../..")
[node name="MeshInstance3D4" type="MeshInstance3D" parent="Node3D"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.246009, 0)
visible = false
mesh = SubResource("CylinderMesh_dp7xj")
skeleton = NodePath("../..")

View File

@@ -0,0 +1,139 @@
[gd_scene load_steps=21 format=3 uid="uid://dqwgv1ahsvqio"]
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_788j8"]
albedo_color = Color(1, 0, 0, 1)
[sub_resource type="SphereMesh" id="SphereMesh_u4ac2"]
material = SubResource("StandardMaterial3D_788j8")
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_0qa1y"]
albedo_color = Color(1, 0.907, 0.38, 1)
[sub_resource type="TorusMesh" id="TorusMesh_tjrnq"]
material = SubResource("StandardMaterial3D_0qa1y")
inner_radius = 0.141
outer_radius = 0.601
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_3i52q"]
albedo_color = Color(1, 0.540167, 0.11, 1)
[sub_resource type="BoxMesh" id="BoxMesh_xyuxq"]
material = SubResource("StandardMaterial3D_3i52q")
size = Vector3(0.85, 0.85, 0.85)
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_p0ha4"]
albedo_color = Color(0.48, 1, 0.497333, 1)
[sub_resource type="PrismMesh" id="PrismMesh_xnm4h"]
material = SubResource("StandardMaterial3D_p0ha4")
size = Vector3(1, 1, 0.855)
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_jv6fb"]
albedo_color = Color(0.3384, 0.538933, 0.94, 1)
[sub_resource type="CylinderMesh" id="CylinderMesh_i1yhp"]
material = SubResource("StandardMaterial3D_jv6fb")
top_radius = 0.0
bottom_radius = 0.59
height = 1.08
radial_segments = 4
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_0qk4s"]
albedo_color = Color(0.62325, 0.495, 0.9, 1)
[sub_resource type="CylinderMesh" id="CylinderMesh_bvmel"]
material = SubResource("StandardMaterial3D_0qk4s")
top_radius = 0.765
bottom_radius = 0.34
height = 1.54
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_438mn"]
albedo_color = Color(0.933333, 0.2, 1, 1)
[sub_resource type="CylinderMesh" id="CylinderMesh_x8oip"]
material = SubResource("StandardMaterial3D_438mn")
top_radius = 0.33
bottom_radius = 0.34
height = 1.0
radial_segments = 7
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_hqr78"]
albedo_color = Color(0.51, 0.456705, 0.3417, 1)
[sub_resource type="CylinderMesh" id="CylinderMesh_dp7xj"]
material = SubResource("StandardMaterial3D_hqr78")
top_radius = 0.29
bottom_radius = 0.59
height = 0.65
radial_segments = 4
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_aba40"]
albedo_color = Color(0.1512, 0.36, 0.17208, 1)
[sub_resource type="CylinderMesh" id="CylinderMesh_8ctts"]
material = SubResource("StandardMaterial3D_aba40")
top_radius = 0.45
bottom_radius = 0.495
height = 1.54
radial_segments = 4
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_tl8dq"]
albedo_color = Color(0.2279, 0.36888, 0.53, 1)
[sub_resource type="CylinderMesh" id="CylinderMesh_w2aj8"]
material = SubResource("StandardMaterial3D_tl8dq")
top_radius = 0.0
bottom_radius = 0.77
height = 1.54
radial_segments = 4
[node name="TestMultimesh" type="Node3D"]
[node name="Node3D" type="Node3D" parent="."]
[node name="MeshInstance3D0" type="MeshInstance3D" parent="Node3D"]
mesh = SubResource("SphereMesh_u4ac2")
skeleton = NodePath("../..")
[node name="MeshInstance3D1" type="MeshInstance3D" parent="Node3D"]
mesh = SubResource("TorusMesh_tjrnq")
skeleton = NodePath("../..")
[node name="MeshInstance3D2" type="MeshInstance3D" parent="Node3D"]
mesh = SubResource("BoxMesh_xyuxq")
skeleton = NodePath("../..")
[node name="MeshInstance3D3" type="MeshInstance3D" parent="Node3D"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.118133, 0)
mesh = SubResource("PrismMesh_xnm4h")
skeleton = NodePath("../..")
[node name="MeshInstance3D4" type="MeshInstance3D" parent="Node3D"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.246009, 0)
mesh = SubResource("CylinderMesh_i1yhp")
skeleton = NodePath("../..")
[node name="MeshInstance3D5" type="MeshInstance3D" parent="Node3D"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.246009, 0)
mesh = SubResource("CylinderMesh_bvmel")
skeleton = NodePath("../..")
[node name="MeshInstance3D6" type="MeshInstance3D" parent="Node3D"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.246009, 0)
mesh = SubResource("CylinderMesh_x8oip")
skeleton = NodePath("../..")
[node name="MeshInstance3D7" type="MeshInstance3D" parent="Node3D"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.246009, 0)
mesh = SubResource("CylinderMesh_dp7xj")
skeleton = NodePath("../..")
[node name="MeshInstance3D8" type="MeshInstance3D" parent="Node3D"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.246009, 0)
mesh = SubResource("CylinderMesh_8ctts")
skeleton = NodePath("../..")
[node name="MeshInstance3D9" type="MeshInstance3D" parent="Node3D"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.246009, 0)
mesh = SubResource("CylinderMesh_w2aj8")
skeleton = NodePath("../..")

Binary file not shown.

View File

@@ -0,0 +1,44 @@
[remap]
importer="scene"
importer_version=1
type="PackedScene"
uid="uid://bxwiqxgwoh630"
path="res://.godot/imported/RockA.glb-2e416adf16cd89c5c5afc8e204027147.scn"
[deps]
source_file="res://demo/assets/models/RockA.glb"
dest_files=["res://.godot/imported/RockA.glb-2e416adf16cd89c5c5afc8e204027147.scn"]
[params]
nodes/root_type="StaticBody3D"
nodes/root_name="Scene Root"
nodes/apply_root_scale=true
nodes/root_scale=1.0
nodes/import_as_skeleton_bones=false
nodes/use_node_type_suffixes=true
meshes/ensure_tangents=true
meshes/generate_lods=true
meshes/create_shadow_meshes=true
meshes/light_baking=1
meshes/lightmap_texel_size=0.2
meshes/force_disable_compression=false
skins/use_named_skins=true
animation/import=true
animation/fps=30
animation/trimming=false
animation/remove_immutable_tracks=true
animation/import_rest_as_RESET=false
import_script/path=""
_subresources={
"materials": {
"@MATERIAL:0": {
"use_external/enabled": true,
"use_external/path": "res://demo/assets/materials/M_rock30.tres"
}
}
}
gltf/naming_version=0
gltf/embedded_image_handling=1

File diff suppressed because one or more lines are too long

Binary file not shown.

View File

@@ -0,0 +1,44 @@
[remap]
importer="scene"
importer_version=1
type="PackedScene"
uid="uid://nta3sef6c2el"
path="res://.godot/imported/RockB.glb-d0df90244ab14da61106a961f4faa07f.scn"
[deps]
source_file="res://demo/assets/models/RockB.glb"
dest_files=["res://.godot/imported/RockB.glb-d0df90244ab14da61106a961f4faa07f.scn"]
[params]
nodes/root_type="StaticBody3D"
nodes/root_name="Scene Root"
nodes/apply_root_scale=true
nodes/root_scale=1.0
nodes/import_as_skeleton_bones=false
nodes/use_node_type_suffixes=true
meshes/ensure_tangents=true
meshes/generate_lods=true
meshes/create_shadow_meshes=true
meshes/light_baking=1
meshes/lightmap_texel_size=0.2
meshes/force_disable_compression=false
skins/use_named_skins=true
animation/import=true
animation/fps=30
animation/trimming=false
animation/remove_immutable_tracks=true
animation/import_rest_as_RESET=false
import_script/path=""
_subresources={
"materials": {
"@MATERIAL:0": {
"use_external/enabled": true,
"use_external/path": "res://demo/assets/materials/M_rock30.tres"
}
}
}
gltf/naming_version=0
gltf/embedded_image_handling=1

File diff suppressed because one or more lines are too long

Binary file not shown.

View File

@@ -0,0 +1,44 @@
[remap]
importer="scene"
importer_version=1
type="PackedScene"
uid="uid://c8cx4xjwluvxw"
path="res://.godot/imported/RockC.glb-5881ee1ff2072066a3de122ce4239bee.scn"
[deps]
source_file="res://demo/assets/models/RockC.glb"
dest_files=["res://.godot/imported/RockC.glb-5881ee1ff2072066a3de122ce4239bee.scn"]
[params]
nodes/root_type="StaticBody3D"
nodes/root_name="Scene Root"
nodes/apply_root_scale=true
nodes/root_scale=1.0
nodes/import_as_skeleton_bones=false
nodes/use_node_type_suffixes=true
meshes/ensure_tangents=true
meshes/generate_lods=true
meshes/create_shadow_meshes=true
meshes/light_baking=1
meshes/lightmap_texel_size=0.2
meshes/force_disable_compression=false
skins/use_named_skins=true
animation/import=true
animation/fps=30
animation/trimming=false
animation/remove_immutable_tracks=true
animation/import_rest_as_RESET=false
import_script/path=""
_subresources={
"materials": {
"@MATERIAL:0": {
"use_external/enabled": true,
"use_external/path": "res://demo/assets/materials/M_rock30.tres"
}
}
}
gltf/naming_version=0
gltf/embedded_image_handling=1

File diff suppressed because one or more lines are too long

Binary file not shown.

View File

@@ -0,0 +1,44 @@
[remap]
importer="scene"
importer_version=1
type="PackedScene"
uid="uid://jib546bbort5"
path="res://.godot/imported/Tunnel.glb-09729773791c3078e933c866961e1b60.scn"
[deps]
source_file="res://demo/assets/models/Tunnel.glb"
dest_files=["res://.godot/imported/Tunnel.glb-09729773791c3078e933c866961e1b60.scn"]
[params]
nodes/root_type="StaticBody3D"
nodes/root_name="Scene Root"
nodes/apply_root_scale=true
nodes/root_scale=1.0
nodes/import_as_skeleton_bones=false
nodes/use_node_type_suffixes=true
meshes/ensure_tangents=true
meshes/generate_lods=true
meshes/create_shadow_meshes=true
meshes/light_baking=1
meshes/lightmap_texel_size=0.2
meshes/force_disable_compression=true
skins/use_named_skins=true
animation/import=true
animation/fps=30
animation/trimming=false
animation/remove_immutable_tracks=true
animation/import_rest_as_RESET=false
import_script/path=""
_subresources={
"materials": {
"material_0": {
"use_external/enabled": false,
"use_external/path": "uid://nbbdrx8vma80"
}
}
}
gltf/naming_version=0
gltf/embedded_image_handling=1

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,12 @@
All ambientCG assets are provided under the
Creative Commons CC0 1.0 Universal License.
https://docs.ambientcg.com/license/
Grass:
https://ambientcg.com/view?id=Ground037
Rock:
https://ambientcg.com/view?id=Rock030
Cliff:
https://ambientcg.com/view?id=Rock023

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 MiB

View File

@@ -0,0 +1,35 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://ddprscrpsofah"
path.bptc="res://.godot/imported/ground037_alb_ht.png-d854c3c88beba9927351b95063edffa2.bptc.ctex"
metadata={
"imported_formats": ["s3tc_bptc"],
"vram_texture": true
}
[deps]
source_file="res://demo/assets/textures/ground037_alb_ht.png"
dest_files=["res://.godot/imported/ground037_alb_ht.png-d854c3c88beba9927351b95063edffa2.bptc.ctex"]
[params]
compress/mode=2
compress/high_quality=true
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=2
compress/channel_pack=0
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 MiB

View File

@@ -0,0 +1,35 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://c1ots7w6i0i1q"
path.bptc="res://.godot/imported/ground037_nrm_rgh.png-02372c72ee87f1844ee708d952e43e96.bptc.ctex"
metadata={
"imported_formats": ["s3tc_bptc"],
"vram_texture": true
}
[deps]
source_file="res://demo/assets/textures/ground037_nrm_rgh.png"
dest_files=["res://.godot/imported/ground037_nrm_rgh.png-02372c72ee87f1844ee708d952e43e96.bptc.ctex"]
[params]
compress/mode=2
compress/high_quality=true
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=2
compress/channel_pack=0
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 MiB

View File

@@ -0,0 +1,35 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://c88j3oj0lf6om"
path.bptc="res://.godot/imported/rock023_alb_ht.png-9c06b8a5f11d940d1c46d8928f6d6a5c.bptc.ctex"
metadata={
"imported_formats": ["s3tc_bptc"],
"vram_texture": true
}
[deps]
source_file="res://demo/assets/textures/rock023_alb_ht.png"
dest_files=["res://.godot/imported/rock023_alb_ht.png-9c06b8a5f11d940d1c46d8928f6d6a5c.bptc.ctex"]
[params]
compress/mode=2
compress/high_quality=true
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=2
compress/channel_pack=0
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=0

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 MiB

View File

@@ -0,0 +1,35 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://c307hdmos4gtm"
path.bptc="res://.godot/imported/rock023_nrm_rgh.png-dd524905a15817dac8149681cddc8975.bptc.ctex"
metadata={
"imported_formats": ["s3tc_bptc"],
"vram_texture": true
}
[deps]
source_file="res://demo/assets/textures/rock023_nrm_rgh.png"
dest_files=["res://.godot/imported/rock023_nrm_rgh.png-dd524905a15817dac8149681cddc8975.bptc.ctex"]
[params]
compress/mode=2
compress/high_quality=true
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=2
compress/channel_pack=0
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=0

View File

@@ -0,0 +1,57 @@
[gd_scene load_steps=6 format=3 uid="uid://dwnhqfjq7v1pq"]
[ext_resource type="Material" uid="uid://d0hyi5n6ng25w" path="res://demo/assets/materials/M_rock23_black_tp.tres" id="1_goand"]
[sub_resource type="BoxMesh" id="BoxMesh_1kfaq"]
size = Vector3(1025.01, 4, 1)
[sub_resource type="BoxShape3D" id="BoxShape3D_s0c8u"]
size = Vector3(1025, 100, 1)
[sub_resource type="BoxMesh" id="BoxMesh_kfxc8"]
size = Vector3(3072, 4, 1)
[sub_resource type="BoxShape3D" id="BoxShape3D_pyqb2"]
size = Vector3(1, 100, 3072)
[node name="Borders" type="StaticBody3D"]
[node name="MeshInstance3D" type="MeshInstance3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2, 512)
mesh = SubResource("BoxMesh_1kfaq")
skeleton = NodePath("../..")
surface_material_override/0 = ExtResource("1_goand")
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 50, 512)
shape = SubResource("BoxShape3D_s0c8u")
[node name="MeshInstance3D2" type="MeshInstance3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2, -2560)
mesh = SubResource("BoxMesh_1kfaq")
skeleton = NodePath("../..")
surface_material_override/0 = ExtResource("1_goand")
[node name="CollisionShape3D2" type="CollisionShape3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 50, -2560)
shape = SubResource("BoxShape3D_s0c8u")
[node name="MeshInstance3D3" type="MeshInstance3D" parent="."]
transform = Transform3D(-4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, 512, 2, -1024)
mesh = SubResource("BoxMesh_kfxc8")
skeleton = NodePath("../..")
surface_material_override/0 = ExtResource("1_goand")
[node name="CollisionShape3D3" type="CollisionShape3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 512, 50, -1024)
shape = SubResource("BoxShape3D_pyqb2")
[node name="MeshInstance3D4" type="MeshInstance3D" parent="."]
transform = Transform3D(-4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, -512, 2, -1024)
mesh = SubResource("BoxMesh_kfxc8")
skeleton = NodePath("../..")
surface_material_override/0 = ExtResource("1_goand")
[node name="CollisionShape3D4" type="CollisionShape3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -512, 50, -1024)
shape = SubResource("BoxShape3D_pyqb2")

View File

@@ -0,0 +1,84 @@
[gd_scene load_steps=11 format=3 uid="uid://dyt8c2xqmddo2"]
[ext_resource type="Script" uid="uid://chstoagn42gbr" path="res://demo/src/DemoScene.gd" id="1_2gjn4"]
[ext_resource type="PackedScene" uid="uid://d2jihfohphuue" path="res://demo/components/UI.tscn" id="2_3obxr"]
[ext_resource type="PackedScene" uid="uid://bb2lp50sjndus" path="res://demo/components/Environment.tscn" id="3_b7ioy"]
[ext_resource type="PackedScene" uid="uid://dwnhqfjq7v1pq" path="res://demo/components/Borders.tscn" id="4_nn6wp"]
[ext_resource type="PackedScene" uid="uid://domhm87hbhbg1" path="res://demo/components/Player.tscn" id="5_bwggt"]
[ext_resource type="Terrain3DAssets" uid="uid://dal3jhw6241qg" path="res://demo/data/assets.tres" id="6_3r2au"]
[sub_resource type="Gradient" id="Gradient_f1plm"]
offsets = PackedFloat32Array(0.2, 1)
colors = PackedColorArray(1, 1, 1, 1, 0, 0, 0, 1)
[sub_resource type="FastNoiseLite" id="FastNoiseLite_bfcw0"]
noise_type = 2
frequency = 0.03
cellular_jitter = 3.0
cellular_return_type = 0
domain_warp_enabled = true
domain_warp_type = 1
domain_warp_amplitude = 50.0
domain_warp_fractal_type = 2
domain_warp_fractal_lacunarity = 1.5
domain_warp_fractal_gain = 1.0
[sub_resource type="NoiseTexture2D" id="NoiseTexture2D_quxx0"]
seamless = true
color_ramp = SubResource("Gradient_f1plm")
noise = SubResource("FastNoiseLite_bfcw0")
[sub_resource type="Terrain3DMaterial" id="Terrain3DMaterial_klrp5"]
_shader_parameters = {
"auto_base_texture": 0,
"auto_height_reduction": 0.1,
"auto_overlay_texture": 1,
"auto_slope": 1.0,
"bias_distance": 512.0,
"blend_sharpness": 0.87,
"depth_blur": 0.0,
"dual_scale_far": 170.0,
"dual_scale_near": 100.0,
"dual_scale_reduction": 0.3,
"dual_scale_texture": 0,
"enable_macro_variation": true,
"enable_projection": true,
"height_blending": true,
"macro_variation1": Color(1, 1, 1, 1),
"macro_variation2": Color(1, 1, 1, 1),
"macro_variation_slope": 0.333,
"mipmap_bias": 1.0,
"noise1_angle": 0.0,
"noise1_offset": Vector2(0.5, 0.5),
"noise1_scale": 0.04,
"noise2_scale": 0.076,
"noise3_scale": 0.225,
"noise_texture": SubResource("NoiseTexture2D_quxx0"),
"projection_angular_division": 1.436,
"projection_threshold": 0.8,
"tri_scale_reduction": 0.3,
&"world_space_normal_blend": true
}
auto_shader = true
dual_scaling = true
[node name="Demo" type="Node"]
script = ExtResource("1_2gjn4")
[node name="UI" parent="." instance=ExtResource("2_3obxr")]
[node name="World" parent="." instance=ExtResource("3_b7ioy")]
[node name="Borders" parent="." instance=ExtResource("4_nn6wp")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 512, 0, 512)
[node name="Player" parent="." instance=ExtResource("5_bwggt")]
transform = Transform3D(0.134125, 0, -0.990965, 0, 1, 0, 0.990965, 0, 0.134125, 216.455, 103.968, -1835.34)
[node name="Terrain3D" type="Terrain3D" parent="."]
data_directory = "res://demo/data"
material = SubResource("Terrain3DMaterial_klrp5")
assets = ExtResource("6_3r2au")
collision_mask = 3
top_level = true
metadata/_edit_lock_ = true

View File

@@ -0,0 +1,34 @@
[gd_scene load_steps=6 format=3 uid="uid://di5fovhcyd7re"]
[ext_resource type="Script" path="res://demo/src/Enemy.gd" id="1_yudyn"]
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_lwhhq"]
height = 1.5
[sub_resource type="SeparationRayShape3D" id="SeparationRayShape3D_i8f01"]
[sub_resource type="CapsuleMesh" id="CapsuleMesh_lsqiy"]
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_d4cor"]
albedo_color = Color(1, 0, 0, 1)
[node name="Enemy" type="CharacterBody3D"]
collision_layer = 2
script = ExtResource("1_yudyn")
[node name="CollisionShapeBody" type="CollisionShape3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.25, 0)
shape = SubResource("CapsuleShape3D_lwhhq")
[node name="CollisionShapeRay" type="CollisionShape3D" parent="."]
transform = Transform3D(1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, 1, 0)
shape = SubResource("SeparationRayShape3D_i8f01")
[node name="Body" type="MeshInstance3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0)
mesh = SubResource("CapsuleMesh_lsqiy")
surface_material_override/0 = SubResource("StandardMaterial3D_d4cor")
[node name="NavigationAgent3D" type="NavigationAgent3D" parent="."]
path_desired_distance = 2.0
debug_enabled = true

View File

@@ -0,0 +1,34 @@
[gd_scene load_steps=5 format=3 uid="uid://bb2lp50sjndus"]
[sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_vibap"]
sky_top_color = Color(0.192157, 0.282353, 0.509804, 1)
sky_horizon_color = Color(0.505882, 0.615686, 0.709804, 1)
ground_bottom_color = Color(0.211765, 0.313726, 0.552941, 1)
ground_horizon_color = Color(0.505882, 0.615686, 0.709804, 1)
ground_curve = 0.13
[sub_resource type="Sky" id="Sky_srg7c"]
sky_material = SubResource("ProceduralSkyMaterial_vibap")
[sub_resource type="Environment" id="Environment_8jcgm"]
background_mode = 2
sky = SubResource("Sky_srg7c")
ambient_light_source = 3
ambient_light_color = Color(0.55, 0.55, 0.55, 1)
ambient_light_sky_contribution = 0.3
tonemap_mode = 3
[sub_resource type="CameraAttributesPractical" id="CameraAttributesPractical_0gcl0"]
[node name="Environment" type="Node3D"]
[node name="WorldEnvironment" type="WorldEnvironment" parent="."]
environment = SubResource("Environment_8jcgm")
camera_attributes = SubResource("CameraAttributesPractical_0gcl0")
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="."]
transform = Transform3D(-0.866024, -0.433016, 0.250001, 0, 0.499998, 0.866026, -0.500003, 0.749999, -0.43301, 0, 0, 0)
shadow_enabled = true
shadow_blur = 2.0
directional_shadow_blend_splits = true
directional_shadow_max_distance = 256.0

View File

@@ -0,0 +1,44 @@
[gd_scene load_steps=7 format=3 uid="uid://domhm87hbhbg1"]
[ext_resource type="Script" path="res://demo/src/Player.gd" id="1_nm1yx"]
[ext_resource type="Script" path="res://demo/src/CameraManager.gd" id="2_loos7"]
[sub_resource type="SphereShape3D" id="SphereShape3D_smq6u"]
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_lwhhq"]
height = 1.5
[sub_resource type="SeparationRayShape3D" id="SeparationRayShape3D_twc2s"]
[sub_resource type="CapsuleMesh" id="CapsuleMesh_lsqiy"]
[node name="Player" type="CharacterBody3D"]
collision_layer = 2
script = ExtResource("1_nm1yx")
[node name="CameraManager" type="Node3D" parent="."]
script = ExtResource("2_loos7")
[node name="Arm" type="SpringArm3D" parent="CameraManager"]
unique_name_in_owner = true
transform = Transform3D(1, 0, 0, 0, 0.906308, 0.422618, 0, -0.422618, 0.906308, 0, 2.32515, -0.0321627)
shape = SubResource("SphereShape3D_smq6u")
spring_length = 6.0
margin = 0.5
[node name="Camera3D" type="Camera3D" parent="CameraManager/Arm"]
unique_name_in_owner = true
near = 0.25
far = 16384.0
[node name="CollisionShapeBody" type="CollisionShape3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.25, 0)
shape = SubResource("CapsuleShape3D_lwhhq")
[node name="CollisionShapeRay" type="CollisionShape3D" parent="."]
transform = Transform3D(1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, 1, 0)
shape = SubResource("SeparationRayShape3D_twc2s")
[node name="Body" type="MeshInstance3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0)
mesh = SubResource("CapsuleMesh_lsqiy")

167
demo/components/Tunnel.tscn Normal file
View File

@@ -0,0 +1,167 @@
[gd_scene load_steps=10 format=3 uid="uid://djhl3foqkj4e2"]
[ext_resource type="PackedScene" uid="uid://be6nrf0b8j4l0" path="res://demo/assets/models/RockA.tscn" id="1_m1xck"]
[ext_resource type="PackedScene" uid="uid://bwvtgwartxt0g" path="res://demo/assets/models/RockB.tscn" id="2_hybky"]
[ext_resource type="PackedScene" uid="uid://lsvs8a7urkca" path="res://demo/assets/models/RockC.tscn" id="3_nbn1a"]
[ext_resource type="PackedScene" uid="uid://vvayjv3rbx1d" path="res://demo/assets/models/Tunnel.tscn" id="4_klbpo"]
[ext_resource type="PackedScene" uid="uid://cribhhvg03u8g" path="res://demo/assets/models/CrystalC.tscn" id="5_bb2w0"]
[ext_resource type="Material" uid="uid://cso4f2iyuxpmc" path="res://demo/assets/materials/M_crystal_purple.tres" id="6_s6twx"]
[ext_resource type="Material" uid="uid://ickkffutwcvo" path="res://demo/assets/materials/M_crystal_red.tres" id="7_7fkm2"]
[ext_resource type="Script" uid="uid://c444j1ucmv5ti" path="res://demo/src/CaveEntrance.gd" id="9_fn2ke"]
[sub_resource type="BoxShape3D" id="BoxShape3D_goiy4"]
size = Vector3(530.482, 38.6343, 235.603)
[node name="Tunnel" type="Node3D"]
[node name="EntranceL" type="Node3D" parent="."]
[node name="RockA1" parent="EntranceL" instance=ExtResource("1_m1xck")]
transform = Transform3D(5.82988, -5.4374, -4.00004, 6.04396, 6.55839, -0.106264, 3.00604, -2.64109, 7.9713, 807.937, 137.298, 467.411)
[node name="RockA2" parent="EntranceL" instance=ExtResource("1_m1xck")]
transform = Transform3D(4.67905, 4.22076, -5.5926, 6.98724, -3.31022, 3.34764, -0.52024, -6.49718, -5.3387, 766.019, 104.95, 452.605)
[node name="RockA3" parent="EntranceL" instance=ExtResource("1_m1xck")]
transform = Transform3D(1.19782, 11.0889, 4.42738, -11.9291, 0.921057, 0.9205, 0.510788, -4.49312, 11.1153, 793.166, 76.9378, 454.834)
[node name="RockB1" parent="EntranceL" instance=ExtResource("2_hybky")]
transform = Transform3D(-2.10522, -4.25988, 3.15298, 3.05166, -3.74811, -3.02637, 4.33304, 0.570028, 3.66329, 824.574, 112.54, 446.946)
[node name="RockB3" parent="EntranceL" instance=ExtResource("2_hybky")]
transform = Transform3D(4.29222, 4.57142, 1.24961, -2.49948, 3.61605, -4.6432, -4.02641, 2.62846, 4.21447, 773.937, 140.911, 469.972)
[node name="RockC1" parent="EntranceL" instance=ExtResource("3_nbn1a")]
transform = Transform3D(-1.86839, -3.85072, -1.99813, -0.0474326, -2.1573, 4.20181, -4.33801, 1.6821, 0.814656, 786.081, 135.376, 453.531)
[node name="RockC2" parent="EntranceL" instance=ExtResource("3_nbn1a")]
transform = Transform3D(-3.90856, -4.56077, 3.35866, 3.81036, 0.902037, 5.65911, -4.19074, 5.07383, 2.01294, 791.859, 164.408, 508.107)
[node name="EntranceR" type="Node3D" parent="."]
[node name="RockA1" parent="EntranceR" instance=ExtResource("1_m1xck")]
transform = Transform3D(-0.271255, 1.28607, -2.97471, -1.25761, 2.70942, 1.28605, 2.98685, 1.25759, 0.271335, 299.644, 127.203, 424.309)
[node name="RockA2" parent="EntranceR" instance=ExtResource("1_m1xck")]
transform = Transform3D(2.29164, -2.44454, 3.0731, 3.84134, 0.657286, -2.34167, 0.814771, 3.77671, 2.39666, 318.179, 95.8599, 421.731)
[node name="RockA5" parent="EntranceR" instance=ExtResource("1_m1xck")]
transform = Transform3D(1.09929, -4.37397, 0.575562, 3.84134, 0.657286, -2.34167, 2.16957, 1.05247, 3.85443, 321.814, 95.8599, 436.931)
[node name="RockA3" parent="EntranceR" instance=ExtResource("1_m1xck")]
transform = Transform3D(3.70822, 1.86229, 1.85804, 2.19079, -0.408409, -3.96295, -1.45634, 4.12752, -1.23046, 338.177, 116.66, 430.367)
[node name="RockA4" parent="EntranceR" instance=ExtResource("1_m1xck")]
transform = Transform3D(1.9779, 0.270409, 4.08487, -4.00125, 1.0869, 1.86547, -0.865577, -4.40646, 0.710812, 320.977, 134.583, 441.012)
[node name="RockB1" parent="EntranceR" instance=ExtResource("2_hybky")]
transform = Transform3D(-1.64956, -1.63286, 1.75857, 0.196316, 2.03499, 2.07367, -2.39171, 1.29322, -1.04267, 295.848, 109.828, 419.45)
[node name="RockB3" parent="EntranceR" instance=ExtResource("2_hybky")]
transform = Transform3D(-2.03718, 1.29729, 2.88404, -2.82928, 0.784888, -2.35156, -1.41272, -3.44263, 0.550663, 306.288, 128.712, 434.042)
[node name="RockB4" parent="EntranceR" instance=ExtResource("2_hybky")]
transform = Transform3D(1.97436, 2.87133, -1.41708, -2.82928, 0.784888, -2.35156, -1.49926, 2.30004, 2.57153, 328.686, 129.709, 427.63)
[node name="RockB2" parent="EntranceR" instance=ExtResource("2_hybky")]
transform = Transform3D(-2.17746, 0.476253, -1.87396, -1.61495, 1.104, 2.15708, 1.06324, 2.65221, -0.561397, 303.461, 107.797, 428.826)
[node name="RockC1" parent="EntranceR" instance=ExtResource("3_nbn1a")]
transform = Transform3D(1.74949, 1.15588, 0.576742, -1.01213, 1.82987, -0.597152, -0.802676, 0.21197, 2.01002, 335.27, 110.419, 418.362)
[node name="RockC2" parent="EntranceR" instance=ExtResource("3_nbn1a")]
transform = Transform3D(4.31956, 5.88829, -1.29353, -3.67086, 1.30662, -6.31041, -4.78226, 4.31561, 3.67549, 345.465, 146.581, 480.747)
[node name="TunnelMesh" parent="." instance=ExtResource("4_klbpo")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 546.733, 112.043, 468.686)
[node name="CrystalGroup1" type="Node3D" parent="."]
transform = Transform3D(0.567756, 0.0788585, -0.00345403, 0.0729824, -0.514888, 0.241124, 0.0300693, -0.239266, -0.520024, 415.722, 122.719, 611.385)
[node name="CrystalC" parent="CrystalGroup1" instance=ExtResource("5_bb2w0")]
transform = Transform3D(0.990472, -0.134216, 0.0307963, 0.132893, 0.873058, -0.469155, 0.0360812, 0.468779, 0.882577, 0.050354, 1.72128, 4.54956)
[node name="CrystalC3" parent="CrystalGroup1" instance=ExtResource("5_bb2w0")]
transform = Transform3D(0.999999, 2.98023e-08, 0, 1.40402e-08, 0.999999, 1.19209e-07, 6.89635e-09, -1.49012e-07, 0.999999, 4.00897, 3.69431, -0.617554)
[node name="CrystalC2" parent="CrystalGroup1" instance=ExtResource("5_bb2w0")]
transform = Transform3D(-0.513116, -0.374576, 0.95887, -0.130632, 1.08641, 0.354495, -1.02111, 0.0492404, -0.527189, -1.70374, 4.03528, -0.568237)
[node name="OmniLight3D" type="OmniLight3D" parent="CrystalGroup1"]
transform = Transform3D(1, 3.21278e-08, -1.96807e-08, -3.21278e-08, 1, 1.02499e-07, 1.96807e-08, -1.02499e-07, 1, 1.11737, 4.79865, 1.8949)
light_color = Color(0.4, 0.760784, 1, 1)
light_energy = 16.0
shadow_enabled = true
omni_range = 83.054
[node name="CrystalGroup2" type="Node3D" parent="."]
transform = Transform3D(-0.536793, -0.0213862, -0.199931, -0.116106, 0.498308, 0.25843, 0.164163, 0.282504, -0.470976, 553.318, 103.571, 647.425)
[node name="CrystalC" parent="CrystalGroup2" instance=ExtResource("5_bb2w0")]
transform = Transform3D(0.704558, -0.579782, 0.130258, 0.554941, 0.56972, -0.465804, 0.212495, 0.434496, 0.784585, 0.815979, 1.24854, 2.5437)
[node name="Rock3" parent="CrystalGroup2/CrystalC" index="0"]
surface_material_override/0 = ExtResource("6_s6twx")
[node name="CrystalC3" parent="CrystalGroup2" instance=ExtResource("5_bb2w0")]
transform = Transform3D(0.127208, -0.0568556, -1.06836, -0.317718, 1.02534, -0.0923969, 1.02161, 0.32596, 0.104294, 4.00861, 3.69458, -0.617188)
[node name="Rock3" parent="CrystalGroup2/CrystalC3" index="0"]
surface_material_override/0 = ExtResource("6_s6twx")
[node name="CrystalC2" parent="CrystalGroup2" instance=ExtResource("5_bb2w0")]
transform = Transform3D(-0.642172, -0.213226, 0.774009, 0.484154, 0.687794, 0.591163, -0.640428, 0.733767, -0.329203, 7.28876, 1.71277, 4.52783)
[node name="Rock3" parent="CrystalGroup2/CrystalC2" index="0"]
surface_material_override/0 = ExtResource("6_s6twx")
[node name="OmniLight3D" type="OmniLight3D" parent="CrystalGroup2"]
transform = Transform3D(1.74454, 2.98023e-08, -2.98023e-08, -5.60482e-08, 1.74454, 1.49012e-07, 3.43338e-08, -1.78814e-07, 1.74454, 1.11737, 4.79865, 1.8949)
light_color = Color(0.396078, 0.333333, 0.878431, 1)
light_energy = 16.0
shadow_enabled = true
omni_range = 83.054
[node name="CrystalGroup3" type="Node3D" parent="."]
transform = Transform3D(-0.536793, -0.0213862, -0.199931, 0.0789312, -0.546626, -0.153451, -0.184932, -0.17123, 0.514837, 711.291, 124.136, 579.252)
[node name="CrystalC" parent="CrystalGroup3" instance=ExtResource("5_bb2w0")]
transform = Transform3D(0.898105, -0.188271, 0.0864646, 0.196692, 0.654036, -0.618921, 0.0650697, 0.621535, 0.677476, 0.589844, 2.22089, 3.04785)
[node name="Rock3" parent="CrystalGroup3/CrystalC" index="0"]
surface_material_override/0 = ExtResource("7_7fkm2")
[node name="CrystalC3" parent="CrystalGroup3" instance=ExtResource("5_bb2w0")]
transform = Transform3D(0.15544, 0.0752453, -1.06348, -0.370935, 1.01139, 0.0173435, 0.999527, 0.363637, 0.171821, 4.00867, 3.69458, -0.617432)
[node name="Rock3" parent="CrystalGroup3/CrystalC3" index="0"]
surface_material_override/0 = ExtResource("7_7fkm2")
[node name="CrystalC2" parent="CrystalGroup3" instance=ExtResource("5_bb2w0")]
transform = Transform3D(-0.573134, -0.100696, 0.847536, 0.285048, 0.939695, 0.304405, -0.804489, 0.404691, -0.495942, 7.2887, 1.71283, 4.52771)
[node name="Rock3" parent="CrystalGroup3/CrystalC2" index="0"]
surface_material_override/0 = ExtResource("7_7fkm2")
[node name="OmniLight3D" type="OmniLight3D" parent="CrystalGroup3"]
transform = Transform3D(1.74454, 2.98023e-08, -2.98023e-08, -5.60482e-08, 1.74454, 1.49012e-07, 3.43338e-08, -1.78814e-07, 1.74454, 1.11737, 4.79865, 1.8949)
light_color = Color(0.388235, 0.101961, 0.2, 1)
light_energy = 16.0
shadow_enabled = true
omni_range = 83.054
[node name="CaveArea3D" type="Area3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 549.961, 110.763, 526.656)
collision_mask = 2
script = ExtResource("9_fn2ke")
[node name="CollisionShape3D" type="CollisionShape3D" parent="CaveArea3D"]
transform = Transform3D(0.998441, 0, -0.0558215, 0, 1, 0, 0.0558215, 0, 0.998441, -8.36676, 3.78637, 30.7709)
shape = SubResource("BoxShape3D_goiy4")
[editable path="CrystalGroup2/CrystalC"]
[editable path="CrystalGroup2/CrystalC3"]
[editable path="CrystalGroup2/CrystalC2"]
[editable path="CrystalGroup3/CrystalC"]
[editable path="CrystalGroup3/CrystalC3"]
[editable path="CrystalGroup3/CrystalC2"]

66
demo/components/UI.tscn Normal file
View File

@@ -0,0 +1,66 @@
[gd_scene load_steps=2 format=3 uid="uid://d2jihfohphuue"]
[ext_resource type="Script" path="res://demo/src/UI.gd" id="1_why5e"]
[node name="UI" type="Control"]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_why5e")
[node name="Label" type="Label" parent="."]
unique_name_in_owner = true
layout_mode = 1
offset_left = 5.0
offset_top = 5.0
offset_right = 275.0
offset_bottom = 340.0
theme_override_colors/font_shadow_color = Color(0, 0, 0, 0.662745)
theme_override_constants/shadow_offset_x = 1
theme_override_constants/shadow_offset_y = 1
text = "FPS: 100
Position: (100, 100, 100)
Move Speed: 10
Player
Move: WASDEQ,Space,Mouse
Move speed: Wheel,+/-,Shift
Camera view: V
Gravity toggle: G
Collision toggle: C
Window
Quit: F8
UI toggle: F9
Render mode: F10
Full screen: F11
Mouse toggle: Escape
"
[node name="Panel" type="Panel" parent="Label"]
modulate = Color(1, 1, 1, 0.392157)
show_behind_parent = true
layout_mode = 0
offset_left = -5.0
offset_top = -5.0
offset_right = 248.0
offset_bottom = 444.0
[node name="HSeparator" type="HSeparator" parent="Label/Panel"]
top_level = true
layout_mode = 0
offset_left = 6.0
offset_top = 129.0
offset_right = 246.0
offset_bottom = 138.0
[node name="HSeparator2" type="HSeparator" parent="Label/Panel"]
top_level = true
layout_mode = 0
offset_left = 6.0
offset_top = 310.0
offset_right = 246.0
offset_bottom = 319.0

57
demo/data/assets.tres Normal file
View File

@@ -0,0 +1,57 @@
[gd_resource type="Terrain3DAssets" load_steps=11 format=3 uid="uid://dal3jhw6241qg"]
[ext_resource type="PackedScene" uid="uid://bn5nf4esciwex" path="res://demo/assets/models/LODExample.tscn" id="1_4jrdu"]
[ext_resource type="Texture2D" uid="uid://c88j3oj0lf6om" path="res://demo/assets/textures/rock023_alb_ht.png" id="2_pog6b"]
[ext_resource type="Texture2D" uid="uid://ddprscrpsofah" path="res://demo/assets/textures/ground037_alb_ht.png" id="3_g8f2m"]
[ext_resource type="Texture2D" uid="uid://c307hdmos4gtm" path="res://demo/assets/textures/rock023_nrm_rgh.png" id="3_wncaf"]
[ext_resource type="Texture2D" uid="uid://c1ots7w6i0i1q" path="res://demo/assets/textures/ground037_nrm_rgh.png" id="4_aw5y1"]
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_b2vqk"]
transparency = 4
cull_mode = 2
vertex_color_use_as_albedo = true
backlight_enabled = true
backlight = Color(0.5, 0.5, 0.5, 1)
distance_fade_mode = 1
distance_fade_min_distance = 128.0
distance_fade_max_distance = 96.0
[sub_resource type="Terrain3DMeshAsset" id="Terrain3DMeshAsset_2qf8x"]
name = "TextureCard"
generated_type = 1
height_offset = 0.5
material_override = SubResource("StandardMaterial3D_b2vqk")
last_lod = 0
last_shadow_lod = 0
lod0_range = 128.0
[sub_resource type="Terrain3DMeshAsset" id="Terrain3DMeshAsset_or12t"]
name = "LODExample"
id = 1
scene_file = ExtResource("1_4jrdu")
height_offset = 0.5
last_lod = 3
last_shadow_lod = 3
[sub_resource type="Terrain3DTextureAsset" id="Terrain3DTextureAsset_lha57"]
name = "Cliff"
albedo_texture = ExtResource("2_pog6b")
normal_texture = ExtResource("3_wncaf")
normal_depth = 1.0
ao_strength = 2.0
roughness = -0.05
[sub_resource type="Terrain3DTextureAsset" id="Terrain3DTextureAsset_od0q7"]
name = "Grass"
id = 1
albedo_color = Color(0.67451, 0.74902, 0.686275, 1)
albedo_texture = ExtResource("3_g8f2m")
normal_texture = ExtResource("4_aw5y1")
normal_depth = 1.0
ao_strength = 2.0
uv_scale = 0.2
detiling_rotation = 0.161
[resource]
mesh_list = Array[Terrain3DMeshAsset]([SubResource("Terrain3DMeshAsset_2qf8x"), SubResource("Terrain3DMeshAsset_or12t")])
texture_list = Array[Terrain3DTextureAsset]([SubResource("Terrain3DTextureAsset_lha57"), SubResource("Terrain3DTextureAsset_od0q7")])

BIN
demo/data/nav_mesh.res Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

29
demo/src/CameraManager.gd Normal file
View File

@@ -0,0 +1,29 @@
extends Node3D
const CAMERA_MAX_PITCH: float = deg_to_rad(70)
const CAMERA_MIN_PITCH: float = deg_to_rad(-89.9)
const CAMERA_RATIO: float = .625
@export var mouse_sensitivity: float = .002
@export var mouse_y_inversion: float = -1.0
@onready var _camera_yaw: Node3D = self
@onready var _camera_pitch: Node3D = %Arm
func _ready() -> void:
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
func _input(p_event: InputEvent) -> void:
if p_event is InputEventMouseMotion and Input.get_mouse_mode() == Input.MOUSE_MODE_CAPTURED:
rotate_camera(p_event.relative)
get_viewport().set_input_as_handled()
return
func rotate_camera(p_relative:Vector2) -> void:
_camera_yaw.rotation.y -= p_relative.x * mouse_sensitivity
_camera_yaw.orthonormalize()
_camera_pitch.rotation.x += p_relative.y * mouse_sensitivity * CAMERA_RATIO * mouse_y_inversion
_camera_pitch.rotation.x = clamp(_camera_pitch.rotation.x, CAMERA_MIN_PITCH, CAMERA_MAX_PITCH)

View File

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

22
demo/src/CaveEntrance.gd Normal file
View File

@@ -0,0 +1,22 @@
extends Area3D
func _ready() -> void:
body_entered.connect(_on_body_entered)
body_exited.connect(_on_body_exited)
func _on_body_entered(body: Node3D) -> void:
if body.name == "Player":
var env: WorldEnvironment = get_node_or_null("../../Environment/WorldEnvironment")
if env:
var tween: Tween = get_tree().create_tween()
tween.tween_property(env.environment, "ambient_light_energy", .1, .33)
func _on_body_exited(body: Node3D) -> void:
if body.name == "Player":
var env: WorldEnvironment = get_node_or_null("../../Environment/WorldEnvironment")
if env:
var tween: Tween = get_tree().create_tween()
tween.tween_property(env.environment, "ambient_light_energy", 1., .33)

View File

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

133
demo/src/CodeGenerated.gd Normal file
View File

@@ -0,0 +1,133 @@
extends Node
var terrain: Terrain3D
func _ready() -> void:
$UI.player = $Player
if has_node("RunThisSceneLabel3D"):
$RunThisSceneLabel3D.queue_free()
terrain = await create_terrain()
# Enable runtime navigation baking using the terrain
# Enable `Debug/Visible Navigation` if you wish to see it
$RuntimeNavigationBaker.terrain = terrain
$RuntimeNavigationBaker.enabled = true
func create_terrain() -> Terrain3D:
# Create textures
var green_gr := Gradient.new()
green_gr.set_color(0, Color.from_hsv(100./360., .35, .3))
green_gr.set_color(1, Color.from_hsv(120./360., .4, .37))
var green_ta: Terrain3DTextureAsset = await create_texture_asset("Grass", green_gr, 1024)
green_ta.uv_scale = 0.1
green_ta.detiling_rotation = 0.1
var brown_gr := Gradient.new()
brown_gr.set_color(0, Color.from_hsv(30./360., .4, .3))
brown_gr.set_color(1, Color.from_hsv(30./360., .4, .4))
var brown_ta: Terrain3DTextureAsset = await create_texture_asset("Dirt", brown_gr, 1024)
brown_ta.uv_scale = 0.03
green_ta.detiling_rotation = 0.1
var grass_ma: Terrain3DMeshAsset = create_mesh_asset("Grass", Color.from_hsv(120./360., .4, .37))
# Create a terrain
var terrain := Terrain3D.new()
terrain.name = "Terrain3D"
add_child(terrain, true)
# Set material and assets
terrain.material.world_background = Terrain3DMaterial.NONE
terrain.material.auto_shader = true
terrain.material.set_shader_param("auto_slope", 10)
terrain.material.set_shader_param("blend_sharpness", .975)
terrain.assets = Terrain3DAssets.new()
terrain.assets.set_texture(0, green_ta)
terrain.assets.set_texture(1, brown_ta)
terrain.assets.set_mesh_asset(0, grass_ma)
# Generate height map w/ 32-bit noise and import it with scale
var noise := FastNoiseLite.new()
noise.frequency = 0.0005
var img: Image = Image.create_empty(2048, 2048, false, Image.FORMAT_RF)
for x in img.get_width():
for y in img.get_height():
img.set_pixel(x, y, Color(noise.get_noise_2d(x, y), 0., 0., 1.))
terrain.region_size = 1024
terrain.data.import_images([img, null, null], Vector3(-1024, 0, -1024), 0.0, 150.0)
# Instance foliage
var xforms: Array[Transform3D]
var width: int = 100
var step: int = 2
for x in range(0, width, step):
for z in range(0, width, step):
var pos := Vector3(x, 0, z) - Vector3(width, 0, width) * .5
pos.y = terrain.data.get_height(pos)
xforms.push_back(Transform3D(Basis(), pos))
terrain.instancer.add_transforms(0, xforms)
# Enable the next line and `Debug/Visible Collision Shapes` to see collision
#terrain.collision.mode = Terrain3DCollision.DYNAMIC_EDITOR
return terrain
func create_texture_asset(asset_name: String, gradient: Gradient, texture_size: int = 512) -> Terrain3DTextureAsset:
# Create noise map
var fnl := FastNoiseLite.new()
fnl.frequency = 0.004
# Create albedo noise texture
var alb_noise_tex := NoiseTexture2D.new()
alb_noise_tex.width = texture_size
alb_noise_tex.height = texture_size
alb_noise_tex.seamless = true
alb_noise_tex.noise = fnl
alb_noise_tex.color_ramp = gradient
await alb_noise_tex.changed
var alb_noise_img: Image = alb_noise_tex.get_image()
# Create albedo + height texture
for x in alb_noise_img.get_width():
for y in alb_noise_img.get_height():
var clr: Color = alb_noise_img.get_pixel(x, y)
clr.a = clr.v # Noise as height
alb_noise_img.set_pixel(x, y, clr)
alb_noise_img.generate_mipmaps()
var albedo := ImageTexture.create_from_image(alb_noise_img)
# Create normal + rough texture
var nrm_noise_tex := NoiseTexture2D.new()
nrm_noise_tex.width = texture_size
nrm_noise_tex.height = texture_size
nrm_noise_tex.as_normal_map = true
nrm_noise_tex.seamless = true
nrm_noise_tex.noise = fnl
await nrm_noise_tex.changed
var nrm_noise_img = nrm_noise_tex.get_image()
for x in nrm_noise_img.get_width():
for y in nrm_noise_img.get_height():
var normal_rgh: Color = nrm_noise_img.get_pixel(x, y)
normal_rgh.a = 0.8 # Roughness
nrm_noise_img.set_pixel(x, y, normal_rgh)
nrm_noise_img.generate_mipmaps()
var normal := ImageTexture.create_from_image(nrm_noise_img)
var ta := Terrain3DTextureAsset.new()
ta.name = asset_name
ta.albedo_texture = albedo
ta.normal_texture = normal
return ta
func create_mesh_asset(asset_name: String, color: Color) -> Terrain3DMeshAsset:
var ma := Terrain3DMeshAsset.new()
ma.name = asset_name
ma.generated_type = Terrain3DMeshAsset.TYPE_TEXTURE_CARD
ma.material_override.albedo_color = color
return ma

View File

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

23
demo/src/DemoScene.gd Normal file
View File

@@ -0,0 +1,23 @@
@tool
extends Node
@onready var terrain: Terrain3D = find_child("Terrain3D")
func _ready():
if not Engine.is_editor_hint() and has_node("UI"):
$UI.player = $Player
# Load Sky3D into the demo environment if enabled
if Engine.is_editor_hint() and has_node("Environment") and \
Engine.get_singleton(&"EditorInterface").is_plugin_enabled("sky_3d"):
$Environment.queue_free()
var sky3d = load("res://addons/sky_3d/src/Sky3D.gd").new()
sky3d.name = "Sky3D"
add_child(sky3d, true)
move_child(sky3d, 1)
sky3d.owner = self
sky3d.current_time = 10
sky3d.enable_editor_time = false

View File

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

58
demo/src/Enemy.gd Normal file
View File

@@ -0,0 +1,58 @@
extends CharacterBody3D
const RETARGET_COOLDOWN: float = 1.0
@export var MOVE_SPEED: float = 50.0
@export var target: Node3D
@onready var nav_agent: NavigationAgent3D = $NavigationAgent3D
var _retarget_timer: float = 1.0
func _ready() -> void:
nav_agent.velocity_computed.connect(_on_velocity_computed)
func _process(p_delta: float) -> void:
_retarget_timer += p_delta
if _retarget_timer > RETARGET_COOLDOWN and target:
# Don't reset the target position every frame. It triggers an A* search, which is expensive.
_retarget_timer = 0.0
nav_agent.set_target_position(target.global_position)
func is_on_nav_mesh() -> bool:
var closest_point := NavigationServer3D.map_get_closest_point(nav_agent.get_navigation_map(), global_position)
return global_position.distance_squared_to(closest_point) < nav_agent.path_max_distance ** 2
func _physics_process(p_delta: float) -> void:
if nav_agent.is_navigation_finished():
velocity.x = 0.0
velocity.z = 0.0
else:
var next_path_position: Vector3 = nav_agent.get_next_path_position()
var current_agent_position: Vector3 = global_position
var velocity_xz := (next_path_position - current_agent_position).normalized() * MOVE_SPEED
velocity.x = velocity_xz.x
velocity.z = velocity_xz.z
velocity.y -= 40 * p_delta
if nav_agent.avoidance_enabled:
nav_agent.set_velocity(velocity)
else:
_on_velocity_computed(velocity)
# Ensure enemy doesn't fall through terrain when collision absent
if get_parent().terrain:
var height: float = get_parent().terrain.data.get_height(global_position)
if not is_nan(height):
global_position.y = maxf(global_position.y, height)
func _on_velocity_computed(p_safe_velocity: Vector3) -> void:
velocity.x = p_safe_velocity.x
velocity.z = p_safe_velocity.z
move_and_slide()

1
demo/src/Enemy.gd.uid Normal file
View File

@@ -0,0 +1 @@
uid://6j2rrp5f1gjs

81
demo/src/Player.gd Normal file
View File

@@ -0,0 +1,81 @@
extends CharacterBody3D
@export var MOVE_SPEED: float = 50.0
@export var JUMP_SPEED: float = 2.0
@export var first_person: bool = false :
set(p_value):
first_person = p_value
if first_person:
var tween: Tween = create_tween()
tween.tween_property($CameraManager/Arm, "spring_length", 0.0, .33)
tween.tween_callback($Body.set_visible.bind(false))
else:
$Body.visible = true
create_tween().tween_property($CameraManager/Arm, "spring_length", 6.0, .33)
@export var gravity_enabled: bool = true :
set(p_value):
gravity_enabled = p_value
if not gravity_enabled:
velocity.y = 0
@export var collision_enabled: bool = true :
set(p_value):
collision_enabled = p_value
$CollisionShapeBody.disabled = ! collision_enabled
$CollisionShapeRay.disabled = ! collision_enabled
func _physics_process(p_delta) -> void:
var direction: Vector3 = get_camera_relative_input()
var h_veloc: Vector2 = Vector2(direction.x, direction.z).normalized() * MOVE_SPEED
if Input.is_key_pressed(KEY_SHIFT):
h_veloc *= 2
velocity.x = h_veloc.x
velocity.z = h_veloc.y
if gravity_enabled:
velocity.y -= 40 * p_delta
move_and_slide()
# Returns the input vector relative to the camera. Forward is always the direction the camera is facing
func get_camera_relative_input() -> Vector3:
var input_dir: Vector3 = Vector3.ZERO
if Input.is_key_pressed(KEY_A): # Left
input_dir -= %Camera3D.global_transform.basis.x
if Input.is_key_pressed(KEY_D): # Right
input_dir += %Camera3D.global_transform.basis.x
if Input.is_key_pressed(KEY_W): # Forward
input_dir -= %Camera3D.global_transform.basis.z
if Input.is_key_pressed(KEY_S): # Backward
input_dir += %Camera3D.global_transform.basis.z
if Input.is_key_pressed(KEY_E) or Input.is_key_pressed(KEY_SPACE): # Up
velocity.y += JUMP_SPEED + MOVE_SPEED*.016
if Input.is_key_pressed(KEY_Q): # Down
velocity.y -= JUMP_SPEED + MOVE_SPEED*.016
if Input.is_key_pressed(KEY_KP_ADD) or Input.is_key_pressed(KEY_EQUAL):
MOVE_SPEED = clamp(MOVE_SPEED + .5, 5, 9999)
if Input.is_key_pressed(KEY_KP_SUBTRACT) or Input.is_key_pressed(KEY_MINUS):
MOVE_SPEED = clamp(MOVE_SPEED - .5, 5, 9999)
return input_dir
func _input(p_event: InputEvent) -> void:
if p_event is InputEventMouseButton and p_event.pressed:
if p_event.button_index == MOUSE_BUTTON_WHEEL_UP:
MOVE_SPEED = clamp(MOVE_SPEED + 5, 5, 9999)
elif p_event.button_index == MOUSE_BUTTON_WHEEL_DOWN:
MOVE_SPEED = clamp(MOVE_SPEED - 5, 5, 9999)
elif p_event is InputEventKey:
if p_event.pressed:
if p_event.keycode == KEY_V:
first_person = ! first_person
elif p_event.keycode == KEY_G:
gravity_enabled = ! gravity_enabled
elif p_event.keycode == KEY_C:
collision_enabled = ! collision_enabled
# Else if up/down released
elif p_event.keycode in [ KEY_Q, KEY_E, KEY_SPACE ]:
velocity.y = 0

1
demo/src/Player.gd.uid Normal file
View File

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

View File

@@ -0,0 +1,151 @@
extends Node
signal bake_finished
@export var enabled: bool = true : set = set_enabled
@export var enter_cost: float = 0.0 : set = set_enter_cost
@export var travel_cost: float = 1.0 : set = set_travel_cost
@export_flags_3d_navigation var navigation_layers: int = 1 : set = set_navigation_layers
@export var template: NavigationMesh : set = set_template
@export var terrain: Terrain3D
@export var player: Node3D
@export var mesh_size := Vector3(256, 512, 256)
@export var min_rebake_distance: float = 64.0
@export var bake_cooldown: float = 1.0
@export_group("Debug")
@export var log_timing: bool = false
var _scene_geometry: NavigationMeshSourceGeometryData3D
var _current_center := Vector3(INF,INF,INF)
var _bake_task_id: int = -1
var _bake_task_timer: float = 0.0
var _bake_cooldown_timer: float = 0.0
var _nav_region: NavigationRegion3D
func _ready():
_nav_region = NavigationRegion3D.new()
_nav_region.navigation_layers = navigation_layers
_nav_region.enabled = enabled
_nav_region.enter_cost = enter_cost
_nav_region.travel_cost = travel_cost
# Enabling edge connections comes with a performance penalty that causes hitches whenever
# the nav mesh is updated. The navigation server has to compare each edge, and it does this on
# the main thread.
_nav_region.use_edge_connections = false
add_child(_nav_region)
_update_map_cell_size()
# If you're using ProtonScatter, you will want to delay this next call until after all
# your scatter nodes have finished setting up. Here, we just defer one frame so that nodes
# after this one in the tree get set up first
parse_scene.call_deferred()
func set_enabled(p_value: bool) -> void:
enabled = p_value
if _nav_region:
_nav_region.enabled = enabled
set_process(enabled and template)
func set_enter_cost(p_value: bool) -> void:
enter_cost = p_value
if _nav_region:
_nav_region.enter_cost = enter_cost
func set_travel_cost(p_value: bool) -> void:
travel_cost = p_value
if _nav_region:
_nav_region.travel_cost = travel_cost
func set_navigation_layers(p_value: int) -> void:
navigation_layers = p_value
if _nav_region:
_nav_region.navigation_layers = navigation_layers
func set_template(p_value: NavigationMesh) -> void:
template = p_value
set_process(enabled and template)
_update_map_cell_size()
func parse_scene() -> void:
_scene_geometry = NavigationMeshSourceGeometryData3D.new()
NavigationServer3D.parse_source_geometry_data(template, _scene_geometry, self)
func _update_map_cell_size() -> void:
if get_viewport() and template:
var map := get_viewport().find_world_3d().navigation_map
NavigationServer3D.map_set_cell_size(map, template.cell_size)
NavigationServer3D.map_set_cell_height(map, template.cell_height)
func _process(p_delta: float) -> void:
if _bake_task_id != -1:
_bake_task_timer += p_delta
if not player or _bake_task_id != -1:
return
if _bake_cooldown_timer > 0.0:
_bake_cooldown_timer -= p_delta
return
var track_pos := player.global_position
if player is CharacterBody3D:
# Center on where the player is likely _going to be_:
track_pos += player.velocity * bake_cooldown
if track_pos.distance_squared_to(_current_center) >= min_rebake_distance * min_rebake_distance:
_current_center = track_pos
_rebake(_current_center)
func _rebake(p_center: Vector3) -> void:
assert(template != null)
_bake_task_id = WorkerThreadPool.add_task(_task_bake.bind(p_center), false, "RuntimeNavigationBaker")
_bake_task_timer = 0.0
_bake_cooldown_timer = bake_cooldown
func _task_bake(p_center: Vector3) -> void:
var nav_mesh: NavigationMesh = template.duplicate()
nav_mesh.filter_baking_aabb = AABB(-mesh_size * 0.5, mesh_size)
nav_mesh.filter_baking_aabb_offset = p_center
var source_geometry: NavigationMeshSourceGeometryData3D
source_geometry = _scene_geometry.duplicate()
if terrain:
var aabb: AABB = nav_mesh.filter_baking_aabb
aabb.position += nav_mesh.filter_baking_aabb_offset
var faces: PackedVector3Array = terrain.generate_nav_mesh_source_geometry(aabb, false)
source_geometry.add_faces(faces, Transform3D.IDENTITY)
if source_geometry.has_data():
NavigationServer3D.bake_from_source_geometry_data(nav_mesh, source_geometry)
_bake_finished.call_deferred(nav_mesh)
else:
_bake_finished.call_deferred(null)
func _bake_finished(p_nav_mesh: NavigationMesh) -> void:
if log_timing:
print("Navigation bake took ", _bake_task_timer, "s")
_bake_task_timer = 0.0
_bake_task_id = -1
if p_nav_mesh:
_nav_region.navigation_mesh = p_nav_mesh
bake_finished.emit()
assert(!NavigationServer3D.region_get_use_edge_connections(_nav_region.get_region_rid()))

View File

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

64
demo/src/UI.gd Normal file
View File

@@ -0,0 +1,64 @@
extends Control
var player: Node
var visible_mode: int = 1
func _init() -> void:
RenderingServer.set_debug_generate_wireframes(true)
func _process(p_delta) -> void:
$Label.text = "FPS: %d\n" % Engine.get_frames_per_second()
if(visible_mode == 1):
$Label.text += "Move Speed: %.1f\n" % player.MOVE_SPEED if player else ""
$Label.text += "Position: %.1v\n" % player.global_position if player else ""
$Label.text += """
Player
Move: WASDEQ,Space,Mouse
Move speed: Wheel,+/-,Shift
Camera View: V
Gravity toggle: G
Collision toggle: C
Window
Quit: F8
UI toggle: F9
Render mode: F10
Full screen: F11
Mouse toggle: Escape / F12
"""
func _unhandled_key_input(p_event: InputEvent) -> void:
if p_event is InputEventKey and p_event.pressed:
match p_event.keycode:
KEY_F8:
get_tree().quit()
KEY_F9:
visible_mode = (visible_mode + 1 ) % 3
$Label/Panel.visible = (visible_mode == 1)
visible = visible_mode > 0
KEY_F10:
var vp = get_viewport()
vp.debug_draw = (vp.debug_draw + 1 ) % 6
get_viewport().set_input_as_handled()
KEY_F11:
toggle_fullscreen()
get_viewport().set_input_as_handled()
KEY_ESCAPE, KEY_F12:
if Input.get_mouse_mode() == Input.MOUSE_MODE_VISIBLE:
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
else:
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
get_viewport().set_input_as_handled()
func toggle_fullscreen() -> void:
if DisplayServer.window_get_mode() == DisplayServer.WINDOW_MODE_EXCLUSIVE_FULLSCREEN or \
DisplayServer.window_get_mode() == DisplayServer.WINDOW_MODE_FULLSCREEN:
DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_WINDOWED)
DisplayServer.window_set_size(Vector2(1280, 720))
else:
DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_EXCLUSIVE_FULLSCREEN)

1
demo/src/UI.gd.uid Normal file
View File

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