Skip to content

Commit 583055f

Browse files
committed
Rough Draft the complete terrain gen algorithm
The complete rough drafted algorithm that steps through the necessary steps to convert raw noise into usable procedurally generated terrain.
1 parent f6247f2 commit 583055f

File tree

4 files changed

+335
-49
lines changed

4 files changed

+335
-49
lines changed

README.md

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -93,25 +93,27 @@ gdb --version
9393
1. Determine the correct tile type for each cell in the grid
9494
2. Set the Grid map cells using Godot's Grid map system
9595

96-
8. Sanitizer
97-
98-
1. Smooth out Cliffs & Ramps
99-
2. Ensure cliffs and ramps don't look messy
100-
101-
9. Open Area Finder / Large Structure Locations
96+
8. Open Area Finder / Large Structure Locations
10297

10398
1. Find areas that have flat ground tiles of 3x3 cells
10499
2. Elevation buffer, ensure structures aren’t placed against cliffs and ramps
105100
3. Store the center cell into a list of available locations
106101

107-
10. Poisson Object Placement
102+
9. Poisson Object Placement
103+
104+
1. Create a copy of the finalized grid (tileMap) and increase its size by splitting cells into 4 pieces
105+
2. New grid contains data about each cell's (4x4 area) place-ability
106+
107+
1. Use the data from the previous steps to know cells that can’t have objects placed on them
108+
109+
1. `vector<vector<bool>> walkableMap` size gridx2
110+
1. This is Hydrology Pathing which determines non-placeable cells
111+
1. Find non-walkable area's as object placeable area's
112+
1. `vector<vector<TileType>> tileMap` size grid
113+
1. Use Cliffs & Ramp's Placement as object non-placeable area's
108114

109-
1. Create a copy of the finalized grid and increase its size by splitting cells into 4 pieces
110-
2. Finalized grid contains data about each cell's place-ability
111-
1. Use the data from the previous steps to know cells that can’t have objects placed on them
112-
2. River Pathing determines non-placeable cells
113-
3. Elevation changes are non-placeable cell's
114-
3. Use poisson disk sampling to place non-large objects using the higher density grid
115+
3. Generate a list of placeable points on the grid using poisson disk sampling
116+
1. If a cell is a valid place for object placement, turn all four cells in the new grid to true/valid
115117

116118
## Contributing
117119

demo/terrain_gen_script.gd

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,30 @@ func _ready():
1919
#generate(grid_map, 128, 128, 4, seed_value, 12, NoiseType.VALUE, 0.79, 0.1);
2020

2121
# Simplex Noise Based
22-
generate(grid_map, 128, 128, 4, seed_value, 12, NoiseType.SIMPLEX, 0.3, 0.5, 0.02);
22+
var result: Dictionary = generate(grid_map, 128, 128, 4, seed_value, 12, NoiseType.SIMPLEX, 0.3, 0.2, 0.02);
23+
24+
#
25+
#
26+
# Validate the output of the Generation Result
27+
#
28+
# Returns World Points for object placement
29+
#
30+
31+
var elevation_map: Array = result["elevationMap"]
32+
print("Elevation at (0,0): ", elevation_map[0][0])
33+
34+
var flat_zones: Array = result["flatZones"]
35+
for zone in flat_zones:
36+
print("Flat zone at (%d, %d) with elevation %d" % [zone["x"], zone["y"], zone["elevation"]])
37+
38+
# Access Poisson samples
39+
var poisson_points: Array = result["poissonPoints"]
40+
for point in poisson_points:
41+
print("Poisson sample at: ", point)
42+
43+
# Access 3D flat zone points
44+
var flat_zone_points_3d: Array = result["flatZonePoints3D"]
45+
for point in flat_zone_points_3d:
46+
print("Flat zone 3D point: ", point)
47+
48+

0 commit comments

Comments
 (0)