Skip to content

Commit 27e2ee4

Browse files
authored
Merge pull request #70 from Forceflow/dev
Dev
2 parents 8101efa + f76e814 commit 27e2ee4

18 files changed

+1321
-352
lines changed

.travis.yml

-51
This file was deleted.

CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ SET(CUDA_VOXELIZER_SRCS
4646
./src/util_cuda.cpp
4747
./src/util_io.cpp
4848
./src/cpu_voxelizer.cpp
49+
./src/libs/magicavoxel_file_writer/VoxWriter.cpp
4950
)
5051
SET(CUDA_VOXELIZER_SRCS_CU
5152
./src/voxelize.cu

README.md

+20-18
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,43 @@
11
[![Build Status](https://travis-ci.org/Forceflow/cuda_voxelizer.svg?branch=master)](https://travis-ci.org/Forceflow/cuda_voxelizer) ![](https://img.shields.io/github/license/Forceflow/cuda_voxelizer.svg) [![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.me/Forceflow)
22

3-
# cuda_voxelizer v0.4.14
3+
# cuda_voxelizer v0.5
44
A command-line tool to convert polygon meshes to (annotated) voxel grids.
55
* Supported input formats: .ply, .off, .obj, .3DS, .SM and RAY
6-
* Supported output formats: .binvox, .obj, morton ordered grid
6+
* Supported output formats: .vox, .binvox, .obj cubes and point cloud, morton ordered grid
77
* Requires a CUDA-compatible video card. Compute Capability 2.0 or higher (Nvidia Fermi or better).
88
* Since v0.4.4, the voxelizer reverts to a (slower) CPU voxelization method when no CUDA device is found
99

1010
## Usage
1111
Program options:
1212
* `-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/).
1617
* `obj`: A mesh containing actual cubes (made up of triangle faces) for each voxel.
1718
* `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.
2021
* `-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.
2122
* `-solid` : (Experimental) Use solid voxelization instead of voxelizing the mesh faces. Needs a watertight input mesh.
2223

23-
2424
## 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`.
2726

2827
`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.
2928

3029
![output_examples](https://raw.githubusercontent.com/Forceflow/cuda_voxelizer/main/img/output_examples.jpg)
3130

3231
## Building
33-
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.
3534

3635
### Dependencies
3736
The project has the following build dependencies:
3837
* [Nvidia Cuda 8.0 Toolkit (or higher)](https://developer.nvidia.com/cuda-toolkit) for CUDA + Thrust libraries (standard included)
3938
* [Trimesh2](https://github.com/Forceflow/trimesh2) for model importing. Latest version recommended.
4039
* [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.
4241

4342
### Build using CMake (Windows, Linux)
4443

@@ -63,7 +62,7 @@ cmake --build . --parallel number_of_cores
6362

6463
### Build using Visual Studio project (Windows)
6564

66-
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.
6766

6867
```
6968
<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
8685
| 1024³ | 8.6 ms | 1047.5 ms |
8786
| 2048³ | 44.6 ms | 4147.4 ms |
8887

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+
9094
* The [.binvox file format](https://www.patrickmin.com/binvox/binvox.html) was created by Michael Kazhdan.
9195
* [Patrick Min](https://www.patrickmin.com/binvox/) wrote some interesting tools to work with it:
9296
* [viewvox](https://www.patrickmin.com/viewvox/): Visualization of voxel grids (a copy of this tool is included in cuda_voxelizer releases)
9397
* [thinvox](https://www.patrickmin.com/thinvox/): Thinning of voxel grids
9498
* [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
9699
* [Zarbuz](https://github.com/zarbuz)'s [FileToVox](https://github.com/Zarbuz/FileToVox) looks interesting as well
97100
* If you want a good customizable CPU-based voxelizer, I can recommend [VoxSurf](https://github.com/sylefeb/VoxSurf).
98101
* Another hackable voxel viewer is Sean Barrett's excellent [stb_voxel_render.h](https://github.com/nothings/stb/blob/master/stb_voxel_render.h).
99102
* Nvidia also has a voxel library called [GVDB](https://developer.nvidia.com/gvdb), that does a lot more than just voxelizing.
100103

101104
## 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".
103106

104107
* Noncubic grid support
105108
* Memory limits test
106-
* Output to more popular voxel formats like MagicaVoxel, Minecraft
107109
* Implement partitioning for larger models
108110
* Do a pre-pass to categorize triangles
109111
* Implement capture of normals / color / texture data

msvc/vs2019/cuda_voxelizer.sln

-27
This file was deleted.

msvc/vs2019/cuda_voxelizer.vcxproj

-138
This file was deleted.

0 commit comments

Comments
 (0)