This Godot project can create a chunk based mesh-array with collisions and navigation.
It's not yet ready to be used in a real project! It's just a fun project of mine to learn mesh generation (I added some explanations as comments for myself, maybe they're helpful for you too).
If you do want to use it in your project, just follow these steps:
- Copy the script
TerrainGenerator.gd
and attach it to aNode3D
- Save your scene and then reload the saved scene
- Fill in the exported variables with values you like (Saved scene's already set up with values I like)
- Hit
Create New Terrain
,Create Water Mesh
,Create Collision Mesh
&Create Navigation Region
- Don't set
d_draw_spheres
to true for big terrains or high values ofterrain_resolution
. Godot likes to crash if you do.. - It takes around 6 to 7 seconds for a terrain of size 1024x1024 with a chunk size of 64 (On an i5-9400 with 8GB of RAM - integrated GPU)
- Be careful with the noise configuration values, too harsh of a change might make your terrain look funky
- Try to balance the
noise_height_modifier
& theheightmap_modifier
when sampling a heightmap - Edit the exported variable
navigation_mesh
to adapt it to your requirements - The same is true for the exported variable
shader_material
that's currently used to color the terrain - Try to balance the values for
noise_height_modifier
&max_rock_height
(in the shader settings) with theterrain_unit_size
(Multiplying both values with theterrain_unit_size
seems to work pretty good from a bit of testing)
- Add unit size changing (1u in Godot multiplied by X to stretch the terrain)
- Add
center_terrain
(You can set the flag but it's not doing anything..) - Add signals
- Add edge falloff
by heightmap orby code (Could take some percentage and check against current x/z position -> Should be fasterthan sampling another heightmap) - Better shaders (
Urgent! Current shader looks real bad for bigger terrain..UV-Positions were all over the place..) - Fix scene not starting anymore 😠
- Create a water mesh & shader
- Fix shader breaking on window resize
- Add unit tests 🙈
- Fix navigation regions' weird pattern when increasing
terrain_unit_size
(Looks like a 45° top down tile..) - ...