Zylann / voxelgame

Voxel world prototype made with Godot Engine
Other
554 stars 89 forks source link

Caves/tunnels support #56

Closed NewNodeGames closed 4 years ago

NewNodeGames commented 6 years ago

This is not an issue, only a idea or suggestion. I know that with left click I can destroy voxels, but can be nice maps with random caves or tunnels directly created for explore. Is hard or easy to implement?

Zylann commented 6 years ago

I have ideas how to implement structure generation (aka anything bigger than 1 voxel with some procedural rules) but I am not sure it will end up in the module, because caves are not a generic feature (as well as anything not purely related to rendering voxels). It could be added to the demo, but I have to experiment with it first.

You can make caves easily using 3D noise in the block generation function, but more specific kinds of caves (like minecraft's "perlin worms" technique) would require more thoughts in order to generate seamlessly.

The main idea I have for structures is that, when you generate a block (aka 16x16x16 voxels, or a chunk if you prefer), you have to generate data about that structure type in advance for all blocks around it that could potentially overlap with the current block. That doesn't mean you have to fully generate all neighbors, all you need is to produce enough "pre-generated" data so that you can make the structure generate seamlessly once next blocks will actually be generated. Now you can also see that doing that in GDScript is quite intensive^^ In the case of worm-like caves, you can think of a it as having a starting point, trace a path until you reach a maximum boundary, center the resulting set of points on the current block and rasterize carved voxels in the current block. Then, points not affecting the current block would be remembered for future blocks around, and that data would be saved so it doesnt change between further loadings.

There might be other more specific approaches to this: https://gamedev.stackexchange.com/questions/53400/cave-generation-with-perlin-worms

NewNodeGames commented 4 years ago

Seems to be implemented on tinmanjuggernaut fork. Closing.