I have a problem with any mesh I import from MagicaVoxel into Unity. As you can see from the screenshot below, the mesh on the left cast a shadow that has holes in it. That's a basic 7-voxel mesh exported as OBJ and dragged into Unity. The light is the standard directional light Unity automatically creates in an empty scene. The glitch occurs in scene editor, preview and exported builds, I tried on multiple PCs as well.

Magic Voxel model on bottom left, Blender on top right

The mesh on the right is a cube extruded on all faces created in Blender and exported as 3DS. As you can see from the wireframe, it is basically the same mesh, but its shadow looks good. Note that if I import the MagicaVoxel's OBJ in Blender first, and then I export in 3DS and into Unity, the shadow stays holed, so it's not a problem with the mesh format, but with something in the mesh itself.

What can it be? Can I solve it somehow or try some others approaches? Thank you.

  • \$\begingroup\$ Seems like something wasn't welded properly (yes, that's the correct term). As OBJ files are plaintext, see if you can do a side-by-side comparison and notice anything. \$\endgroup\$ May 7, 2017 at 19:00
  • \$\begingroup\$ In the voxel software... is the center of that shape hollow or filled? By this I mean are there 6 blocks or 7 blocks? If the shape is hollow there will be 4 hidden faces on the inside which might be leading to that odd shadow. \$\endgroup\$
    – Lea Hayes
    May 14, 2017 at 7:32
  • \$\begingroup\$ Here, I made an illustration (showing end cut off so you can peak inside): imgur.com/DeCWDrv \$\endgroup\$
    – Lea Hayes
    May 14, 2017 at 7:40
  • \$\begingroup\$ @LeaHayes I think it's filled, but I'll check it out. \$\endgroup\$
    – lorenzo-s
    May 14, 2017 at 12:32

1 Answer 1


I'd ordinarily make this a comment, but doubt there is a better answer given what you're seeing...

It likely has to do with them building the mesh without always using shared vertices, resulting in various submeshes leading to the artifact you see (if it had been a single manifold, there would have been no such issues). I'd suggest one of the following:

  • Contact the MagicaVoxel team and ask if they've encountered this problem with lighting before. For all we know, it could be a change in Unity's lighting system since they last tested. They may be willing to fix. Or it could be a known "feature" and they may be unwilling to fix.

  • There is also the possibility that there is a switch somewhere (in their code, perhaps) that can be changed to fix this. (It may, however, have performance impacts.)

  • Failing them being willing to fix, you'll need to modify the existing lighting shader to do a screen space pass to remove such artifacts (possibly via edge dilation of shadows). Such edge dilation filters are common among shaders, and pretty trivial to achieve. I have no idea how challenging this would be to integrate with Unity's standard shader pipeline, however.

  • \$\begingroup\$ In order to get the sharp edges the vertices couldn't be welded... right? \$\endgroup\$
    – Lea Hayes
    May 14, 2017 at 7:31
  • \$\begingroup\$ @LeaHayes Welding vertices could lead to UV mapping issues and others to boot. I cannot say for certain with regards to MagicaVoxel's tech; again, best to contact them. It's a possibility, though. Crucially, we have no idea what their code is doing / assuming under the hood, so just trying to weld vertices at some less-than-ideal time is ill-advised. I speak from experience that modifying geometry for a voxel space is almost always time-consuming and has considerable knock-on effects in shaders etc. which must then be addressed. A screen space solution superficially appears to be simpler. \$\endgroup\$
    – Engineer
    May 14, 2017 at 8:08
  • 1
    \$\begingroup\$ Thank you. Changing light "bias" (as Unity calls it) solved the issue. I've tried to contact MagicaVoxel team, but looks harder than expected (still no reply in a week); in case, I'll share their reply here. \$\endgroup\$
    – lorenzo-s
    May 14, 2017 at 12:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .