VoxelMesherCubes

Inherits: VoxelMesher

Generates a cubic voxels mesh from colors.

Description:

Builds meshes representing cubic voxels, based on color values stored in the VoxelBuffer.CHANNEL_COLOR channel.

Colors will usually be stored in the COLOR vertex attribute and may require a material with vertex colors enabled, or a custom shader.

Properties:

Type Name Default
ColorMode color_mode COLOR_RAW (0)
bool greedy_meshing_enabled true
Material opaque_material
VoxelColorPalette palette
Material transparent_material

Methods:

Return Signature
Mesh generate_mesh_from_image ( Image image, float voxel_size ) static
void set_material_by_index ( Materials id, Material material )

Enumerations:

enum Materials:

  • MATERIAL_OPAQUE = 0 --- Index of the opaque material.
  • MATERIAL_TRANSPARENT = 1 --- Index of the transparent material.
  • MATERIAL_COUNT = 2 --- Maximum number of materials.

enum ColorMode:

  • COLOR_RAW = 0 --- Voxel values will be directly interpreted as colors. 8-bit voxels are interpreted as rrggbbaa (2 bits per component) where the range per component is converted from 0..3 to 0..255. 16-bit voxels are interpreted as rrrrgggg bbbbaaaa (4 bits per component) where the range per component is converted from 0..15 to 0..255. 32-bit voxels are interpreted as rrrrrrrr gggggggg bbbbbbbb aaaaaaaa (8 bits per component) where each component is in 0..255.
  • COLOR_MESHER_PALETTE = 1 --- Voxel values will be interpreted as indices within the color palette assigned in the palette property.
  • COLOR_SHADER_PALETTE = 2 --- Voxel values will be directly written as such in the mesh, instead of colors. They are written in the red component of the COLOR, leaving red and blue to zero. Note, it will be normalized to 0..1 in shader, so if you need the integer value back you may use int(COLOR.r * 255.0). The alpha component will be set to the transparency of the corresponding color in palette (a palette resource is still needed to differenciate transparent parts; RGB values are not used). You are expected to use a ShaderMaterial to read vertex data and choose the actual color with a custom shader. StandardMaterial will not work with this mode.

Property Descriptions

ColorMode color_mode = COLOR_RAW (0)

Sets how voxel color is determined when building the mesh.

bool greedy_meshing_enabled = true

Enables greedy meshing: the mesher will attempt to merge contiguous faces having the same color to reduce the number of polygons.

Material opaque_material

Material that will be used for opaque parts of the mesh.

VoxelColorPalette palette

Palette that will be used when using the COLOR_MESHER_PALETTE color mode.

Material transparent_material

Material that will be used for transparent parts of the mesh (colors where alpha is not set to max).

Method Descriptions

Mesh generate_mesh_from_image( Image image, float voxel_size )

Generates a 1-voxel thick greedy mesh from pixels of an image.

void set_material_by_index( Materials id, Material material )

Sets one of the materials that will be used when building meshes. This is equivalent to using either opaque_material or transparent_material.

Generated on Jan 26, 2026