reckfellENGINE

VoxelMesherCubes

Generates a cubic voxels mesh from colors.

On this page
class VoxelMesherCubesReckfellSharpInherits VoxelMesher

Generates a cubic voxels mesh from colors.

Builds meshes representing cubic voxels, based on color values stored in the VoxelBuffer.ChannelId.ChannelColor channel. Colors will usually be stored in the COLOR vertex attribute and may require a material with vertex colors enabled, or a custom shader.

Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.

Constructors1

VoxelMesherCubesConstructor
# VoxelMesherCubes
C#
public VoxelMesherCubes();

Properties5

ColorModeProperty
# ColorMode
C#
public VoxelMesherCubes.ColorModeEnum ColorMode { get; set; }

Sets how voxel color is determined when building the mesh.

GreedyMeshingEnabledProperty
# GreedyMeshingEnabled
C#
public bool GreedyMeshingEnabled { get; set; }

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

OpaqueMaterialProperty
# OpaqueMaterial
C#
public Material OpaqueMaterial { get; set; }

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

PaletteProperty
# Palette
C#
public VoxelColorPalette Palette { get; set; }

Palette that will be used when using the VoxelMesherCubes.ColorModeEnum.MesherPalette color mode.

TransparentMaterialProperty
# TransparentMaterial
C#
public Material TransparentMaterial { get; set; }

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

Methods8

GenerateMeshFromImageMesh
# GenerateMeshFromImage
C#
public static Mesh GenerateMeshFromImage(Image image, float voxelSize);

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

Parameters
NameTypeDefault
imageImage—
voxelSizefloat—
Returns Mesh
GetColorModeVoxelMesherCubes.ColorModeEnum
# GetColorMode
C#
public VoxelMesherCubes.ColorModeEnum GetColorMode();
Returns VoxelMesherCubes.ColorModeEnum
GetPaletteVoxelColorPalette
# GetPalette
C#
public VoxelColorPalette GetPalette();
Returns VoxelColorPalette
IsGreedyMeshingEnabledbool
# IsGreedyMeshingEnabled
C#
public bool IsGreedyMeshingEnabled();
Returns bool
SetColorModevoid
# SetColorMode
C#
public void SetColorMode(VoxelMesherCubes.ColorModeEnum mode);
Parameters
NameTypeDefault
modeVoxelMesherCubes.ColorModeEnum—
SetGreedyMeshingEnabledvoid
# SetGreedyMeshingEnabled
C#
public void SetGreedyMeshingEnabled(bool enable);
Parameters
NameTypeDefault
enablebool—
SetMaterialByIndexvoid
# SetMaterialByIndex
C#
public void SetMaterialByIndex(VoxelMesherCubes.Materials id, Material material);

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

Parameters
NameTypeDefault
idVoxelMesherCubes.Materials—
materialMaterial—
SetPalettevoid
# SetPalette
C#
public void SetPalette(VoxelColorPalette palette);
Parameters
NameTypeDefault
paletteVoxelColorPalette—

VoxelMesherCubes.ColorModeEnum

ValueDescription
MesherPalette = 1

Voxel values will be interpreted as indices within the color palette assigned in the VoxelMesherCubes.Palette property.

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.

ShaderPalette = 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 VoxelMesherCubes.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.

VoxelMesherCubes.Materials

ValueDescription
Count = 2

Maximum number of materials.

Opaque = 0

Index of the opaque material.

Transparent = 1

Index of the transparent material.

Reckfell Engine documentationBack to top ↑
QUICK LINKSGetting startedEntity hierarchyC# & .NET 10Scenes and prefabs
Reckfell guides and full API K
reckfellENGINE
RECKFELL ACCOUNT

Sign in

Sign in to your Reckfell account.

One account for the entire Reckfell platform.