Implements procedural ground tile generation

Adds procedural ground tile generation with chunking for improved performance.

Includes:
- Ground tile entity with debug text and cell information
- Grass and tree placement based on cell data
- Ground shader for visual representation
- Chunk loading and unloading system based on player position
This commit is contained in:
Dan Baker 2025-06-24 13:14:21 +01:00
parent 95665f54eb
commit b5bf7619e6
21 changed files with 532 additions and 149 deletions

View file

@ -1,43 +1,84 @@
[gd_scene load_steps=7 format=3 uid="uid://bwcevwwphdvq"]
[gd_scene load_steps=18 format=3 uid="uid://bwcevwwphdvq"]
[ext_resource type="Script" uid="uid://bq7hia2dit80y" path="res://Entities/GroundTile/ground_tile.gd" id="1_uwxqs"]
[ext_resource type="PackedScene" uid="uid://ckesk3bs6g7tt" path="res://Stages/Test3D/assets/fish.glb" id="2_h4g11"]
[ext_resource type="ArrayMesh" uid="uid://duj6747nq4qsk" path="res://Stages/Test3D/assets/stylizedGrassMeshes/grass.res" id="3_8mhad"]
[ext_resource type="Script" uid="uid://cacp8ncwuofuj" path="res://Entities/GroundTile/scripts/grass.gd" id="3_224hx"]
[ext_resource type="Material" uid="uid://b1miqvl8lus75" path="res://Stages/Test3D/GrassMaterialOverride.tres" id="3_f37ob"]
[ext_resource type="Script" uid="uid://btju6b83mvgvk" path="res://Entities/GroundTile/scripts/grass_multimesh.gd" id="4_3wpcb"]
[ext_resource type="PackedScene" uid="uid://dgvycnw8hpebx" path="res://Stages/Test3D/assets/tree-tall.glb" id="6_7lc7k"]
[ext_resource type="Script" uid="uid://cqko4m7cbxsfb" path="res://Entities/GroundTile/scripts/trees.gd" id="7_7lc7k"]
[ext_resource type="PackedScene" uid="uid://cccqxa0y0ksju" path="res://Stages/Test3D/assets/tree-trunk.glb" id="7_jysav"]
[ext_resource type="PackedScene" uid="uid://cwfp2cf8no8fi" path="res://Stages/Test3D/assets/tree.glb" id="8_q0r4p"]
[ext_resource type="PackedScene" uid="uid://bwdibgbi3ycqn" path="res://Stages/Test3D/assets/tree-autumn-tall.glb" id="12_4hjaq"]
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_oqd8f"]
albedo_color = Color(0.171, 0.57, 0.24415, 1)
[sub_resource type="ViewportTexture" id="ViewportTexture_h4g11"]
viewport_path = NodePath("DebugText/DebugTextViewport")
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_f37ob"]
albedo_color = Color(0.706084, 0.408439, 0.274016, 1)
metallic = 1.0
[sub_resource type="PlaneMesh" id="PlaneMesh_oqd8f"]
[sub_resource type="BoxShape3D" id="BoxShape3D_h4g11"]
size = Vector3(2, 2, 2)
[sub_resource type="ViewportTexture" id="ViewportTexture_h4g11"]
viewport_path = NodePath("DebugText")
[sub_resource type="MultiMesh" id="MultiMesh_3wpcb"]
transform_format = 1
mesh = ExtResource("3_8mhad")
[sub_resource type="PlaneMesh" id="PlaneMesh_f37ob"]
flip_faces = true
[node name="GroundTile" type="Node3D"]
script = ExtResource("1_uwxqs")
[node name="DebugText" type="Node3D" parent="."]
visible = false
[node name="DebugTextViewport" type="SubViewport" parent="DebugText"]
size = Vector2i(50, 50)
[node name="DebugTextLabel" type="Label" parent="DebugText/DebugTextViewport"]
offset_right = 40.0
offset_bottom = 23.0
text = "Hello world"
[node name="DebugTextBillboard" type="Sprite3D" parent="DebugText"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.0461426, 0.199493, 0.0660986)
texture = SubResource("ViewportTexture_h4g11")
[node name="Ground" type="MeshInstance3D" parent="."]
material_override = SubResource("StandardMaterial3D_oqd8f")
material_override = SubResource("StandardMaterial3D_f37ob")
cast_shadow = 0
mesh = SubResource("PlaneMesh_oqd8f")
[node name="GroundCollision" type="StaticBody3D" parent="."]
[node name="GroundCollision" type="StaticBody3D" parent="Ground"]
[node name="CollisionShape3D" type="CollisionShape3D" parent="GroundCollision"]
[node name="CollisionShape3D" type="CollisionShape3D" parent="Ground/GroundCollision"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -1, 0)
shape = SubResource("BoxShape3D_h4g11")
[node name="fish2" parent="." instance=ExtResource("2_h4g11")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.00713956, 0, 0.0313604)
[node name="DebugText" type="SubViewport" parent="."]
size = Vector2i(50, 50)
[node name="Grass" type="Node3D" parent="."]
script = ExtResource("3_224hx")
[node name="DebugTextLabel" type="Label" parent="DebugText"]
offset_right = 40.0
offset_bottom = 23.0
text = "Hello world"
[node name="GrassMultimesh" type="MultiMeshInstance3D" parent="Grass"]
material_override = ExtResource("3_f37ob")
cast_shadow = 0
multimesh = SubResource("MultiMesh_3wpcb")
script = ExtResource("4_3wpcb")
[node name="Sprite3D" type="Sprite3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -0.0939356)
texture = SubResource("ViewportTexture_h4g11")
[node name="GrassTarget" type="MeshInstance3D" parent="Grass"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.0111763, 0)
mesh = SubResource("PlaneMesh_f37ob")
[node name="Trees" type="Node3D" parent="."]
script = ExtResource("7_7lc7k")
tree_scenes = Array[PackedScene]([ExtResource("8_q0r4p"), ExtResource("6_7lc7k"), ExtResource("12_4hjaq"), ExtResource("8_q0r4p"), ExtResource("8_q0r4p"), ExtResource("8_q0r4p"), ExtResource("8_q0r4p")])
[node name="tree-trunk2" parent="." instance=ExtResource("7_jysav")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.554052, 0, 0.470964)