Zylann / godot_voxel

Voxel module for Godot Engine
MIT License
2.71k stars 251 forks source link

Ability to change voxel bounds height parameter to < 128 #211

Open wacyym opened 4 years ago

wacyym commented 4 years ago

Hello @Zylann,

Im trying to implement SpinTires-like game with dynamic mud terrain and i dont need fully dynamic ground, only partial will be enough (sort of mud-islands). Also, If i understand correctly, one of the way to improve performance - is decrease voxel bounds - less voxels - more performance, right?

I reduce all voxel bounds to 128 - its good, but I do not need a wide range of heights at all - for me 32 height will be enough - wouldn't it be difficult to add this feature to the plugin? screen

Zylann commented 4 years ago

It prevents you to go below because you asked for 4 LODs, and LODs work only with cubic octrees. The base block size is 16 voxels, so the second LOD will be 32, third 64, and fourth 128, so it's not currently possible to go below that. The only way is to reduce the number of LODs.

Note, empty (or full) space does not necessarily store voxels. There is an optimization in place in most generators which avoids allocating memory if all voxels in a block have the same value, and most generators also know where terrain surface will be, so they skip the rest. The box you see here is an octree, not actual blocks (showing non-uniform blocks makes Godot lag too much, I need to find a trick to show them efficiently).

Also, if you don't need LOD, you can use VoxelTerrain, which works by increments of 16.

wacyym commented 4 years ago

Thanks for the detailed super fast answer! all became much clearer!

wacyym commented 4 years ago

In case of using several "voxel islands" - whats better to use: VoxelTerrain or VoxelLodTerrain (are the overhead costs for LOD generation high?)?

Zylann commented 4 years ago

If your islands are few and relatively small (64x64?), several VoxelTerrain could be enough. Otherwise, you could go for multiple VoxelLodTerrain. The advantage of a few LODs is that initial generation will be faster for terrains that are far away. I used the latter to make a solar system with 4 planets which are about 800 voxels in diameter. The ability to do this is recent, so I'm still iterating on it.