Game Mesh Voxel Conversion
Use this skill when the game should do an operation in one representation and
ship or render the result in another. Make conversion an explicit workflow with
resolution, error, and attribute rules.
Primary source: Geometry for Programmers by Oleksandr Kaleniuk
(https://www.manning.com/books/geometry-for-programmers), transformed and
paraphrased, especially chapters 10-12. Additional sources: "Marching Cubes"
by Lorensen and Cline (https://dl.acm.org/doi/10.1145/37402.37422), and
"Dual Contouring of Hermite Data" by Ju, Losasso, Schaefer, and Warren
(https://dl.acm.org/doi/10.1145/566654.566586).
Core Workflow
- State the source representation and target representation.
- State why conversion is needed: repair, render, collide, edit, Boolean,
offset, destruct, simplify, smooth, or export.
- Choose the working grid or sampling resolution from visible error, gameplay
tolerance, memory, and streaming constraints.
- Preserve or regenerate attributes deliberately: normals, UVs, materials,
skinning, collision layers, gameplay tags, and LOD metadata.
- Pick the extraction algorithm based on shape needs: marching cubes/squares
for smooth organic fields, dual contouring for sharper features, or custom
contouring when curve output matters.
- Validate geometry and gameplay behavior after conversion.
Conversion Patterns
Mesh To SDF To Mesh
Use when mesh operations are brittle but approximate output is acceptable:
- Fix holes, cracks, folds, or inverted triangles.
- Hollow or offset a model approximately.
- Merge or subtract complex shapes.
- Generate clean collision or render meshes from an implicit design step.
Expect loss of exact topology and possible loss of original UVs/materials.
Field To Mesh
Use marching cubes/squares when:
- The field is smooth and organic.
- Corners do not need to be preserved exactly.
- Linear interpolation on grid edges is good enough.
Use dual contouring when:
- Sharp features matter.
- Hermite data, gradients, or normals are available.
- One vertex per active cell is a useful output shape.
Voxel Operations
Use voxels or image masks when robustness matters more than exact surface detail:
- Dilation grows filled regions.
- Erosion removes boundary material.
- Erode then dilate to remove small noise.
- Dilate then erode to close thin cracks.
- Boolean union, intersection, and subtraction are simple on aligned grids.
- Connected-component labeling counts separate pieces.
Resolution And Error Rules
- Every grid conversion has an error budget. Name it before implementation.
- More resolution improves visual detail but increases memory and processing
cost quickly, especially in 3D.
- Anisotropic voxels or nonuniform world scale must be accounted for in
distance and neighbor rules.
- Store grid origin, cell size, axis order, and sign convention with the data.
- Use multiresolution or chunking when worlds are large.
Attribute Preservation Checklist
- Normals: recompute, transfer, or preserve?
- UVs: project, bake, discard, or regenerate?
- Materials: transfer by nearest surface, volume labels, or procedural rules?
- Gameplay tags: transfer by source primitive, volume region, or query?
- LODs: generate now or later?
- Collision: same mesh as rendering, simplified mesh, SDF, or voxel proxy?
Common Mistakes
- Converting only positions and discovering later that materials or gameplay
labels were the real asset.
- Using marching cubes for shapes whose main value is sharp edges.
- Treating a voxel grid as exact geometry instead of sampled occupancy.
- Running a mesh repair workflow with no before/after validity tests.
- Picking resolution from screenshots rather than gameplay tolerance and memory.
Source: hashgraph-online/awesome-codex-plugins → plugins/LVTD-LLC/skills/skills/game-mesh-voxel-conversion/SKILL.md
1---2name: game-mesh-voxel-conversion3description: Plan and implement conversions between game meshes, SDFs, voxels, images, contours, and smooth curves while preserving enough gameplay and rendering data. Use when repairing meshes, extracting meshes from fields, voxelizing geometry, contouring, denoising voxel data, generating LODs, or moving geometry between representations.4---567# Game Mesh Voxel Conversion89Use this skill when the game should do an operation in one representation and10ship or render the result in another. Make conversion an explicit workflow with11resolution, error, and attribute rules.1213Primary source: Geometry for Programmers by Oleksandr Kaleniuk14(https://www.manning.com/books/geometry-for-programmers), transformed and15paraphrased, especially chapters 10-12. Additional sources: "Marching Cubes"16by Lorensen and Cline (https://dl.acm.org/doi/10.1145/37402.37422), and17"Dual Contouring of Hermite Data" by Ju, Losasso, Schaefer, and Warren18(https://dl.acm.org/doi/10.1145/566654.566586).1920## Core Workflow21221. State the source representation and target representation.232. State why conversion is needed: repair, render, collide, edit, Boolean,24 offset, destruct, simplify, smooth, or export.253. Choose the working grid or sampling resolution from visible error, gameplay26 tolerance, memory, and streaming constraints.274. Preserve or regenerate attributes deliberately: normals, UVs, materials,28 skinning, collision layers, gameplay tags, and LOD metadata.295. Pick the extraction algorithm based on shape needs: marching cubes/squares30 for smooth organic fields, dual contouring for sharper features, or custom31 contouring when curve output matters.326. Validate geometry and gameplay behavior after conversion.3334## Conversion Patterns3536### Mesh To SDF To Mesh3738Use when mesh operations are brittle but approximate output is acceptable:3940- Fix holes, cracks, folds, or inverted triangles.41- Hollow or offset a model approximately.42- Merge or subtract complex shapes.43- Generate clean collision or render meshes from an implicit design step.4445Expect loss of exact topology and possible loss of original UVs/materials.4647### Field To Mesh4849Use marching cubes/squares when:5051- The field is smooth and organic.52- Corners do not need to be preserved exactly.53- Linear interpolation on grid edges is good enough.5455Use dual contouring when:5657- Sharp features matter.58- Hermite data, gradients, or normals are available.59- One vertex per active cell is a useful output shape.6061### Voxel Operations6263Use voxels or image masks when robustness matters more than exact surface detail:6465- Dilation grows filled regions.66- Erosion removes boundary material.67- Erode then dilate to remove small noise.68- Dilate then erode to close thin cracks.69- Boolean union, intersection, and subtraction are simple on aligned grids.70- Connected-component labeling counts separate pieces.7172## Resolution And Error Rules7374- Every grid conversion has an error budget. Name it before implementation.75- More resolution improves visual detail but increases memory and processing76 cost quickly, especially in 3D.77- Anisotropic voxels or nonuniform world scale must be accounted for in78 distance and neighbor rules.79- Store grid origin, cell size, axis order, and sign convention with the data.80- Use multiresolution or chunking when worlds are large.8182## Attribute Preservation Checklist8384- Normals: recompute, transfer, or preserve?85- UVs: project, bake, discard, or regenerate?86- Materials: transfer by nearest surface, volume labels, or procedural rules?87- Gameplay tags: transfer by source primitive, volume region, or query?88- LODs: generate now or later?89- Collision: same mesh as rendering, simplified mesh, SDF, or voxel proxy?9091## Common Mistakes9293- Converting only positions and discovering later that materials or gameplay94 labels were the real asset.95- Using marching cubes for shapes whose main value is sharp edges.96- Treating a voxel grid as exact geometry instead of sampled occupancy.97- Running a mesh repair workflow with no before/after validity tests.98- Picking resolution from screenshots rather than gameplay tolerance and memory.99100---101102**Source:** [`hashgraph-online/awesome-codex-plugins`](https://github.com/hashgraph-online/awesome-codex-plugins) → `plugins/LVTD-LLC/skills/skills/game-mesh-voxel-conversion/SKILL.md`