You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Supported output formats: .vox, .binvox, .obj cubes and point cloud, morton ordered grid
7
7
* Requires a CUDA-compatible video card. Compute Capability 2.0 or higher (Nvidia Fermi or better).
8
8
* Since v0.4.4, the voxelizer reverts to a (slower) CPU voxelization method when no CUDA device is found
9
9
10
10
## Usage
11
11
Program options:
12
12
*`-f <path to model file>`: **(required)** A path to a polygon-based 3D model file.
13
-
*`-s <voxel grid length>`: The length of the cubical voxel grid. Default: 256, resulting in a 256 x 256 x 256 voxelization grid. The tool will automatically select the tightest cubical bounding box around the model.
14
-
*`-o <output format>`: The output format for voxelized models, default: *binvox*. Output files are saved in the same folder as the input file.
15
-
*`binvox`: A [binvox](http://www.patrickmin.com/binvox/binvox.html) file (default). Can be viewed using [viewvox](http://www.patrickmin.com/viewvox/).
13
+
*`-s <voxel grid length>`: **(default: 256)** The length of the cubical voxel grid. The process will construct the tightest possible cubical bounding box around the input model.
14
+
*`-o <output format>`: The output format for voxelized models, default: *binvox*. Output files are saved in the same folder as the input file, in the format `<original file name>_<grid_size>.extension`.
15
+
*`vox`: **(default)** A [vox](https://github.com/ephtracy/voxel-model/blob/master/MagicaVoxel-file-format-vox.txt) file, which is the native format of and can be viewed with the excellent [MagicaVoxel](https://ephtracy.github.io/).
16
+
*`binvox`: A [binvox](http://www.patrickmin.com/binvox/binvox.html) file. Can be viewed using [viewvox](http://www.patrickmin.com/viewvox/).
16
17
*`obj`: A mesh containing actual cubes (made up of triangle faces) for each voxel.
17
18
*`obj_points`: A mesh containing a point cloud, with a vertex for each voxel. Can be viewed using any compatible viewer that can just display vertices, like [Blender](https://www.blender.org/) or [Meshlab](https://www.meshlab.net/).
18
-
*`morton`: a binary file containing a Morton-ordered grid. This is a format I personally use for other tools.
19
-
*`-cpu`: Force voxelization on the CPU instead of GPU. For when a CUDA device is not detected/compatible, or for very small models where GPU call overhead is not worth it. This is done multi-threaded, but will be slower for large models / grid sizes.
19
+
*`morton`: a binary file containing a Morton-ordered grid. This is an internal format I use for other tools.
20
+
*`-cpu`: Force multi-threaded voxelization on the CPU instead of GPU. Can be used when a CUDA device is not detected/compatible, or for very small models where GPU call overhead is not worth it.
20
21
*`-thrust` : Use Thrust library for copying the model data to the GPU, for a possible speed / throughput improvement. I found this to be very system-dependent. Default: disabled.
21
22
*`-solid` : (Experimental) Use solid voxelization instead of voxelizing the mesh faces. Needs a watertight input mesh.
22
23
23
-
24
24
## Examples
25
-
26
-
`cuda_voxelizer -f bunny.ply -s 256` generates a 256 x 256 x 256 binvox-based voxel model which will be stored in `bunny_256.binvox`.
25
+
`cuda_voxelizer -f bunny.ply -s 256` generates a 256 x 256 x 256 vox-based voxel model which will be stored in `bunny_256.vox`.
27
26
28
27
`cuda_voxelizer -f torus.ply -s 64 -o obj -thrust -solid` generates a solid (filled) 64 x 64 x 64 .obj voxel model which will be stored in `torus_64.obj`. During voxelization, the Cuda Thrust library will be used for a possible speedup, but YMMV.
The build process is aimed at 64-bit executables. It's probably possible to build for 32-bit as well, but I'm not actively testing/supporting this.
34
-
You can build using CMake, or using the provided Visual Studio project. Since 2022, cuda_voxelizer builds via [Github Actions](https://github.com/Forceflow/cuda_voxelizer/actions) as well, check the .[yml config file](https://github.com/Forceflow/cuda_voxelizer/blob/main/.github/workflows/autobuild.yml) for more info.
32
+
The build process is aimed at 64-bit executables. It's possible to build for 32-bit as well, but I'm not actively testing/supporting this.
33
+
You can build using CMake or using the provided Visual Studio project. Since 2022, cuda_voxelizer builds via [Github Actions](https://github.com/Forceflow/cuda_voxelizer/actions) as well, check the .[yml config file](https://github.com/Forceflow/cuda_voxelizer/blob/main/.github/workflows/autobuild.yml) for more info.
35
34
36
35
### Dependencies
37
36
The project has the following build dependencies:
38
37
*[Nvidia Cuda 8.0 Toolkit (or higher)](https://developer.nvidia.com/cuda-toolkit) for CUDA + Thrust libraries (standard included)
39
38
*[Trimesh2](https://github.com/Forceflow/trimesh2) for model importing. Latest version recommended.
40
39
*[GLM](http://glm.g-truc.net/0.9.8/index.html) for vector math. Any recent version will do.
41
-
*[OpenMP](https://www.openmp.org/)
40
+
*[OpenMP](https://www.openmp.org/) for multi-threading.
Project solutions for Visual Studio 2019 and 2022 are provided in the `msvc`folder. They are configured for CUDA 11, but you can edit the project file to make it work with lower CUDA versions. You can edit the `custom_includes.props` file to configure the library locations, and specify a place where the resulting binaries should be placed.
65
+
A project solution for Visual Studio 2022 is provided in the `msvc`folder. It is configured for CUDA 11, but you can edit the project file to make it work with other CUDA versions. You can edit the `custom_includes.props` file to configure the library locations, and specify a place where the resulting binaries should be placed.
67
66
68
67
```
69
68
<TRIMESH_DIR>C:\libs\trimesh2\</TRIMESH_DIR>
@@ -86,24 +85,27 @@ Project solutions for Visual Studio 2019 and 2022 are provided in the `msvc`fold
86
85
| 1024³ | 8.6 ms | 1047.5 ms |
87
86
| 2048³ | 44.6 ms | 4147.4 ms |
88
87
89
-
## Notes / See Also
88
+
## Thanks
89
+
* The [MagicaVoxel](https://ephtracy.github.io/) I/O was implemented using [MagicaVoxel File Writer](https://github.com/aiekick/MagicaVoxel_File_Writer) by [aiekick](https://github.com/aiekick).
90
+
* Thanks to [conceptclear](https://github.com/conceptclear) for implementing solid voxelization.
91
+
92
+
## See also
93
+
90
94
* The [.binvox file format](https://www.patrickmin.com/binvox/binvox.html) was created by Michael Kazhdan.
91
95
*[Patrick Min](https://www.patrickmin.com/binvox/) wrote some interesting tools to work with it:
92
96
*[viewvox](https://www.patrickmin.com/viewvox/): Visualization of voxel grids (a copy of this tool is included in cuda_voxelizer releases)
93
97
*[thinvox](https://www.patrickmin.com/thinvox/): Thinning of voxel grids
94
98
*[binvox-rw-py](https://github.com/dimatura/binvox-rw-py) is a Python module to interact with .binvox files
95
-
* Thanks to [conceptclear](https://github.com/conceptclear) for implementing solid voxelization
96
99
*[Zarbuz](https://github.com/zarbuz)'s [FileToVox](https://github.com/Zarbuz/FileToVox) looks interesting as well
97
100
* If you want a good customizable CPU-based voxelizer, I can recommend [VoxSurf](https://github.com/sylefeb/VoxSurf).
98
101
* Another hackable voxel viewer is Sean Barrett's excellent [stb_voxel_render.h](https://github.com/nothings/stb/blob/master/stb_voxel_render.h).
99
102
* Nvidia also has a voxel library called [GVDB](https://developer.nvidia.com/gvdb), that does a lot more than just voxelizing.
100
103
101
104
## Todo / Possible future work
102
-
This is on my list of nice things to add. Don't hesistate to crack one of these yourself and make a PR!
105
+
This is on my list of "nice things to add".
103
106
104
107
* Noncubic grid support
105
108
* Memory limits test
106
-
* Output to more popular voxel formats like MagicaVoxel, Minecraft
107
109
* Implement partitioning for larger models
108
110
* Do a pre-pass to categorize triangles
109
111
* Implement capture of normals / color / texture data
0 commit comments