Zylann / godot_voxel

Voxel module for Godot Engine
Other
2.45k stars 225 forks source link

VoxelModifier preview mesh has gaps with smoothness #654

Open Piratux opened 1 week ago

Piratux commented 1 week ago

Describe the bug VoxelModifier (this includes VoxelModifierMesh and VoxelModifierSphere) preview mesh starts to have gaps with high enough smoothness.

Image that shows gaps in mesh: image

To Reproduce Steps to reproduce the behavior:

  1. Create VoxelLodTerrain and add VoxelGeneratorFlat generator.
  2. Under VoxelLodTerrain add VoxelModifierSphere.
  3. Set VoxelModifierSphere's radius=30 and smoothness=40.
  4. Notice gaps in the mesh.

Expected behavior Preview mesh should not have any gaps in the mesh.

Environment

MRP Test VoxelModifier mesh gaps.zip

Zylann commented 1 week ago

I believe this is happening purely because of the generator. The flat generator fills space with gradients up to a certain distance to ground. Beyond that, it sets it to uniform far SDF as an optimization. But that means if you use large smoothness factors in modifiers, chunks that lie in the area that's been "optimized out" by the generator will not "blobify" the same way as in areas that have accurate SDF, because gradients dont extend that far. If you wanted this to work at any distance, that optimization just can't happen.

Note that the same issue could happen with different generators doing the same trick. You'd have to calculate full SDF everywhere if you want smoothness to cause shapes to "connect" through arbitrary distances.

Piratux commented 1 week ago

I see, that makes sense. I think it could be a good idea to mention this issue under VoxelModifier's smoothness description.

Zylann commented 1 week ago

Added in 30d6b73707fa893ed66eff5166809c3d030b4205