Package examples :: Module voxelization
[hide private]
[frames] | no frames]

Module voxelization

source code

Voxelize a mesh.


Author: Stephan Wenger

Date: 2012-02-29

Functions [hide private]
 
voxelize(mesh, size, solid=True)
Voxelize a mesh into a cube of length size.
source code
Variables [hide private]
  vertex_code = '\n#version 400 core\n\nlayout(location=0) in ve...
  fragment_code = '\n#version 400 core\n\nin vec4 ex_position;\n...
  __package__ = 'examples'
Function Details [hide private]

voxelize(mesh, size, solid=True)

source code 

Voxelize a mesh into a cube of length size.

Parameters:
  • mesh (VertexArray) - The mesh to voxelize.
  • size (int) - The length of the resulting cube. Should be a multiple of 128.
  • solid (bool) - Whether to perform solid voxelization instead of boundary voxelization.

Attention: The result of boundary voxelization is likely to have holes. To obtain a watertight volume, you can voxelize the volume from different directions and combine the results, or use the gradient of a solid volume.


Variables Details [hide private]

vertex_code

Value:
'''
#version 400 core

layout(location=0) in vec4 in_position;
out vec4 ex_position;

void main() {
    gl_Position = ex_position = in_position;
...

fragment_code

Value:
'''
#version 400 core

in vec4 ex_position;
uniform bool solid;
layout(location=0) out uvec4 fragmentColor[%d];

uvec4 voxelize(uint z, uint offset, uint fill, uint base) {
...