Skip to content

A 3D Mesh Voxelizer written from scratch which transforms triangular mesh to its voxel counterpart

Notifications You must be signed in to change notification settings

Talkative-Banana/3D-Mesh-Voxelizer

Repository files navigation


Logo

3D-Mesh-Voxelizer

A voxel, short for "volume element," is the three-dimensional equivalent of a pixel in 2D images. It represents a value on a grid in 3D space and is used in various fields such as computer graphics, medical imaging, and scientific visualization. Each voxel typically has a specific position and a value that represents some property of the space it occupies, such as color, density, or intensity.

In computer graphics, voxels are used to create 3D models and environments, offering advantages in representing complex structures and volumetric data that can be difficult to capture with traditional polygon-based models. In medical imaging, voxels are essential in technologies like CT scans and MRI, where they help create detailed 3D representations of the body's interior. In scientific visualization, voxels are used to model and analyze data in fields such as geology, meteorology, and fluid dynamics.

image

This Project explores a new way of voxelization as described in the paper Real-time_voxelization_for_complex_polygonal_models.

Built With

Table of Contents

Table of Contents
  1. About The Project
  2. Documentation
  3. Results
  4. Getting Started
  5. Contributing
  6. Contact
  7. Acknowledgements

Documentation

Main idea

The objective is to avoid projection problems in the rasterization stage performing three passes, each of those viewing the scene in front of one of each axis direction. The coordinate system will be placed at the center of the voxel grid, with their axis parallel to the grid edges.

The method

This process describes a method for voxelizing a triangulated geometric model within its axis-aligned bounding box, using a 3D regular grid. Here’s a summary of the key steps and concepts:

Bounding Box and Grid: The model is placed in a bounding box with dimensions 𝑊×𝐻×𝐷 creating a grid of voxels. The box is split into slabs along the z-axis, each slab having a depth range of 32 (bits per texel).

image

Slabs and Sheet Buffers: Each slab can store 𝑊×𝐻×32 voxels. To fill the bounding box, 𝑁=⌈𝐷/32⌉ slabs are used, and all slabs are merged into a "sheet buffer" texture. This process is repeated for each of the three axis directions, resulting in three sheet buffers. A final "composed worksheet" texture is created from these buffers, representing the voxelized model.

Voxelization Steps: Rasterization: Determine which voxels intersect with each triangle and compute their 3D coordinates.

  • Texelization: Assign each voxel to the correct sheet buffer and texel, considering the offset within the texel.

  • Synthesis: Combine the three sheet buffers into the composed worksheet.

  • Preprocessing: To optimize the process, geometry is reordered into groups for each axis direction and for each slab. Triangles are sorted based on their projection and intersection with slabs. This sorting is done on the CPU before voxelization.

Rendering: Each axis group is rasterized slab by slab, adjusting clipping planes to slab boundaries. An orthogonal camera is suggested for accurate results. Bit storage in textures is handled using a lookup texture and alpha blending operations.

Final Merge: The three sheet buffers are merged into the composed worksheet, using the z-axis sheet buffer as a reference. This avoids repetition issues since each triangle is only in one axis group.

This method ensures efficient and accurate voxelization by traversing the model more or less once, with special handling for boundary triangles and voxel repetitions and use an orthogonal camera, gurantees linear distribution of depth.

Results

Stanford's Bunny Model, Buddha Model

result result result result result result

Demo.mp4

Getting Started

To get a local copy up and running follow these simple steps.

Prerequisites

  • Basic understanding of CPP
  • OpenGL installed
  • GitHub Account (Sign Up)

Installation

  • Clone the repo
    git clone https://github.com/Talkative-Banana/3D-Mesh-Voxelizer.git
    sudo apt-get install libgl1-mesa-dev freeglut3-dev libglfw3 libglfw3-dev libglm-dev libglew-dev
    chmmod +x build.sh # (For linux users)
    ulimit -s unlimited
    ./build.sh

Roadmap

  • Clone the repo and open it in suitable IDE for complete project source code. You can also fix the issues and hence contribute.

Contributing

Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.

  1. Fork the Project
  2. Create your Feature Branch
  3. Commit your Changes
  4. Push to the Branch
  5. Open a Pull Request

Contact

Email ID - [email protected]

Acknowledgements

Lakshay Bansal [email protected]

A learnt a lot from this cool website Wolfire

About

A 3D Mesh Voxelizer written from scratch which transforms triangular mesh to its voxel counterpart

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages