Voxel face culling
Hello,
I'm experimenting with a voxel "engine", and I'm trying to cull out the interior faces of the mesh that I'm generating, but it's just not working.
I can't wrap my head around why the below code is not working, to me the logic seems correct...
The code (I'll provide the project if you deem it necessary):
foreach (var voxel in Voxels)
{
if (voxel == null) continue;
var topVoxel = GetAdjacentVoxel(voxel, FaceDirections.Top);
var bottomVoxel = GetAdjacentVoxel(voxel, FaceDirections.Bottom);
var leftVoxel = GetAdjacentVoxel(voxel, FaceDirections.Left);
var rightVoxel = GetAdjacentVoxel(voxel, FaceDirections.Right);
var backVoxel = GetAdjacentVoxel(voxel, FaceDirections.Back);
var frontvoxel = GetAdjacentVoxel(voxel, FaceDirections.Front);
if (topVoxel != null && !topVoxel.IsActive || topVoxel == null) voxel.CreateTopFace(vertices, triangles, colors);
if (bottomVoxel != null && !bottomVoxel.IsActive || bottomVoxel == null) voxel.CreateBottomFace(vertices, triangles, colors);
if (leftVoxel != null && !leftVoxel.IsActive || leftVoxel == null) voxel.CreateLeftFace(vertices, triangles, colors);
if (rightVoxel != null && !rightVoxel.IsActive || rightVoxel == null) voxel.CreateRightFace(vertices, triangles, colors);
if (backVoxel != null && !backVoxel.IsActive || backVoxel == null) voxel.CreateBackFace(vertices, triangles, colors);
if (frontvoxel != null && !frontvoxel.IsActive || frontvoxel == null) voxel.CreateFrontFace(vertices, triangles, colors);
}
Another thing, would greedy meshing nullify the need to cull out the interior faces, or should they be used in conjunction with each other for the best result?
Best regards Marcus
Your answer
Follow this Question
Related Questions
How to make a Tovel like cube (edge smooth?) 2 Answers
Unity3D: Objects destroy automatically 0 Answers
How do i display video when i click on a face of a cube? 0 Answers
Getting face of mesh when you already have one tri 0 Answers
Planar UV mapping in csharp 0 Answers