{"id":13731572,"url":"https://github.com/kctess5/voxelizer","last_synced_at":"2026-01-22T14:03:47.216Z","repository":{"id":73796867,"uuid":"51242930","full_name":"kctess5/voxelizer","owner":"kctess5","description":"A simple mesh voxelizer, GPU accelerated with CUDA","archived":false,"fork":false,"pushed_at":"2016-02-19T05:41:24.000Z","size":36936,"stargazers_count":87,"open_issues_count":2,"forks_count":12,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-11-14T22:35:30.704Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kctess5.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-02-07T09:56:55.000Z","updated_at":"2024-11-02T18:19:58.000Z","dependencies_parsed_at":"2023-04-07T23:36:05.566Z","dependency_job_id":null,"html_url":"https://github.com/kctess5/voxelizer","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kctess5%2Fvoxelizer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kctess5%2Fvoxelizer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kctess5%2Fvoxelizer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kctess5%2Fvoxelizer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kctess5","download_url":"https://codeload.github.com/kctess5/voxelizer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253008261,"owners_count":21839623,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-03T02:01:33.232Z","updated_at":"2026-01-22T14:03:47.189Z","avatar_url":"https://github.com/kctess5.png","language":"C++","funding_links":[],"categories":["Maths"],"sub_categories":[],"readme":"# CUDA C mesh voxelizer\n\nThis is a simple voxelization engine made for MIT's 6.807 Computational Fabrication. Given a .obj mesh, this will output a voxel grid in the form of another .obj file. This voxelizer relies on CUDA for acceleration of the inherently parallel voxelization process.\n\n**WARNING**: this can generate some BIG files if you specify a .obj output and make your computer very sad. Keep the resolution below around 128 for safety. Higher can be achieved, but you will want to use binvox output.\n\nUsing resolution of 256 I generated a 4.7 GB voxel obj file containing over 67 million vertices. This just about crashed my computer as I obliterated my poor swap space. On the bright side, it only took \u003c2 seconds to generate...\n\nThis voxelizer is built on:\n\n- [Möller–Trumbore intersection algorithm](https://en.wikipedia.org/wiki/M%C3%B6ller%E2%80%93Trumbore_intersection_algorithm)\n- CUDA\n\nYou can visualize the output file with MeshLab.\n\n### Usage:\n\n./voxelizer [options] [input path] [ouput path]\n\nOptions: \n\n    -s, --samples     : number of sample rays per vertex    \n\n    -v, --verbose     : Verbosity level. Multiple flags for more verbosity.    \n\n    -r, --resolution  : voxelization resolution (default 32)\n\n    -f, --format      : output format - obj|binvox (default binvox)\n\n    -d, --double      : treat mesh as double-thick\n\n    -h, --help        : Displays usage information and exits.\n\nArguments:\n\n    [input path] : path to .obj mesh\n\n    [ouput path] : path to save voxel grid\n\nExample usage: \n\n64x64x64 resolution, output to ./data/sphere/sphere_voxelized.binvox\n```\n./voxelizer -r 64 ./data/sphere/sphere.obj ./data/sphere/sphere_voxelized\n```\n\n64x64x64 with 11 randomized direction samples to work with a broken mesh\n```\n./voxelizer -r 64 -s 11 ./data/sphere/broken_sphere.obj ./data/sphere/broken_sphere_voxelized\n```\n\n### Build instructions:\n\nYou will need NVIDIA CUDA for this to compile properly.\n\n```\nmkdir build\ncd build\ncmake ..\nmake\n```\n\n### References\n\n- This was very useful for implementing the GPU ray-triangle intersection [https://en.wikipedia.org/wiki/M%C3%B6ller%E2%80%93Trumbore_intersection_algorithm](https://en.wikipedia.org/wiki/M%C3%B6ller%E2%80%93Trumbore_intersection_algorithm)\n- Last semester's graphics assignment in which I implemented ray-triangle intersection\n- The CUDA documentation\n- The given skeleton code\n- binvox file format definition: [http://www.cs.princeton.edu/~min/binvox/binvox.html](http://www.cs.princeton.edu/~min/binvox/binvox.html)\n\n### Known Problems\n\nThere are no known problems with the code. It gets a bit squirly if given very large resolutions, but that's not a surprise.\n\n### Extra Credit\n\nI implemented the voxelization algorithm on the GPU with CUDA. This gives a massive speedup - on the order of 400-2750 times faster than the sample executable.\n\nAdditionally, I implemented multiple sampling for incomplete blocks. Using the -s or --samples argument allows you to specify how many random directions are tested. There are also two different output formats. The standard obj format, as well as the more space efficient binvox format.\n\nI added in the ability to process meshes that are (for whatever reason) double thickness. This is accomplished by using (num_intersections / 2) % 2 for occupancy determination.\n\n### Notes\n\nI liked this assignment!\n\n### Benchmarks\n\nI tested this out with the same parameters as the given executable for all of the given shapes (all with one sample). These are the results on my GTX970:\n\n**GPU (NVIDIA GTX970)**\n\n\tteapot (2464 triangles) @ 64x64x64: 0.083 seconds (396x speedup)\n\tbunny (69664 triangles) @ 64x64x64: 0.88 seconds (2750x speedup)\n\n\tsphere (960 triangles) @ 128x128x128: 0.150 seconds\n\tteapot (2464 triangles) @ 128x128x128: 0.23 seconds\n\tbunny (69664 triangles) @ 128x128x128: 6.54 seconds\n\n\tsphere (960 triangles) @ 256x256x256: 0.825 seconds\n\tteapot (2464 triangles) @ 256x256x256: 2.043 seconds\n\tbunny (69664 triangles) @ 256x256x256: 51.96 seconds\n\n\tsphere (960 triangles) @ 512x512x512: 6.19 seconds\n\tteapot (2464 triangles) @ 512x512x512: 15.64 seconds\n\tbunny (69664 triangles) @ 512x512x512: 417.62 seconds\n\tdragon (100000 triangles) @ 512x512x512, 4 samples in: 2780.39 seconds\n\n\t(1 Billion voxels!)\n\tsphere (960 triangles) @ 1024x1024x1024: 49.93 seconds\n\tteapot (2464 triangles) @ 1024x1024x1024: 126.55 seconds\n\n\n\n**CPU (Intel i5-4590, single threaded)**\n\n\tsphere (960 triangles) @ 64x64x64: 32.9294 seconds\n\tteapot (2464 triangles) @ 64x64x64: 84.0355 seconds\n\tbunny (69664 triangles) @ 64x64x64: 2419.65 seconds\n\n### Pictures\n\nExample mesh bunny\n![Bunny mesh](./images/bunny.png)\nvoxelized to 128x128x128 (with 5 samples)\n![Bunny](./images/bunny_128_5.png)\nvoxelized to 64x64x64\n![Bunny](./images/bunny_64.png)\nvoxelized to 32x32x32\n![Bunny](./images/bunny_32.png)\n\nExample mesh sphere\n![Sphere mesh](./images/bunny.png)\nvoxelized to 64x64x64\n![Sphere](./images/sphere_64.png)\nvoxelized to 32x32x32\n![Sphere](./images/sphere_32.png)\n\nExample mesh teapot\n![Teapot mesh](./images/teapot.png)\nvoxelized to 64x64x64\n![Teapot](./images/teapot_64.png)\nvoxelized to 32x32x32\n![Teapot](./images/teapot_32.png)\n\nExample mesh with gaps\n![Bunny](./images/broken_bunny.png)\n\nBroken mesh with fixed direction\n![Broken Bunny](./images/broken_bunny_64.png)\n\nBroken mesh with 11 randomly sampled directions\n![Broken Bunny](./images/broken_bunny_64_11_samples.png)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkctess5%2Fvoxelizer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkctess5%2Fvoxelizer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkctess5%2Fvoxelizer/lists"}