Devlog #1.3: Hidden-face Culling
Hidden-face culling is a technique to reduce the number of faces in a voxel mesh by removing those that are completely hidden (adjacent to another voxel). This greatly reduces the total number of vertices and triangles that need to be rendered.
🔶 The Original Approach
When generating the mesh for a voxel, I checked each of its six faces.
- If a neighboring voxel existed on that side → skip the face.
- Otherwise → add the face to the mesh.
While logically correct, this required looping through a huge number of voxels and performing random memory access, which quickly led to very poor performance.
🔶 The Optimized Solution – Binary Hidden-Face Culling
To solve this, I found a faster approach using a bitmask. Each voxel is represented as a bit (1 = solid, 0 = transparent/air). By shifting and applying bitwise operations, I can instantly determine which faces are visible without looping neighbor by neighbor. The result is a mask containing only visible faces, calculated in bulk with simple binary math.
🔶 Example: Culling Left Faces
- Solid voxels:
m = 1101000100111110
- Shift right (neighbor to the left):
m >> 1 = 0110100010011111
- Invert to find air on the left:
~(m >> 1) = 1001011101100000
- Solid & air-left = visible left faces:
m & ~(m >> 1) = 1001000100100000
Similarly, for right faces, you just shift left instead of right. From these masks, you can choose which faces to draw or not.
YNL - Vozel (Devlog)
Minecraft-inspired project with optimized voxels, procedural biomes, and advanced shaders in a fantastical world.
Status | In development |
Author | Yunasawa |
Tags | application, Unity, Voxel |
More posts
- Devlog #2.3: Burst-compatible biome proceducer1 day ago
- Devlog #2.2: Minecraft-like biome generation2 days ago
- Devlog #2.1: Procedural Noise in Action2 days ago
- Devlog #1.4: Voxel-style Ambient Occlusion6 days ago
- Devlog #1.2: Exploring Rendering Methods11 days ago
- Devlog #0.1: Control UIs, ToolTab & ToolViewDec 29, 2024
- Devlog #1.1: Base renderer & Multi-threadingNov 07, 2024
Leave a comment
Log in with itch.io to leave a comment.