mattatz / unity-voxel

Mesh voxelization for Unity.
MIT License
1.4k stars 151 forks source link

Issue with the GPU Voxelization (partial voxelization) #13

Open kannebankai opened 2 years ago

kannebankai commented 2 years ago

We use the GPU voxelization part on all types of meshs from primitives to more complex meshs. However, the voxelization can end up being incorrect depending on the voxelSize parameter.

For exemple with a voxelSize of 1 or 0,05 on the primitive cube instantiated at runtime the voxelization have no problem at all. But, if we try to do the voxelization of the same object but with a voxelSize of 0,1 this time it will end up creating only few faces depending on the cube position.

Here is an exemple of the voxelization with the parameter voxelSize equal to 0,1. The first image is from a cube in (0,0,0), the second is from a cube in (-6.7,0,1.2).

image

image

Do you have an hint for why does it act like this ?

racer161 commented 2 years ago

I think it has to do with the way the polygon tracing works in this particular package. Because there's no "Antialiasing" applied occasional an edge will be missed because it doesn't cover enough of a voxel.

image

Here's an example of how this can happen in 2D in some of the most common machine learning libraries. As you can imagine the image processing or multiple samples required to clean up these issues can be expensive. So its probably best to find the highest voxel resolution that works for your project while maintaining performance. Or conversely you could make the features of your model larger.

kannebankai commented 2 years ago

This could work but we have to let the users decide which voxel resolution they want, so ultimately we modified and rewrote the whole surface and volume voxelization behaviour to make this work as intended for us.

Mitko88 commented 2 years ago

@kannebankai, can you share what you modified?