- Home /
Mesh from MagicaVoxel cast a strange holed shadow
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.
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.
Answer by Octopoid · May 09, 2017 at 09:09 PM
I'm pretty sure it's because the vertices aren't shared on the left hand model, on the right the normals look to be smoothed which would indicate they are.
There's no absolute fix but fiddling with the bias on the light should help reduce the gaps.
As a (less than ideal) workaround you can also change the shadow casting mode to two sided, which generally means the back face will cover up any seams - it's not perfect but it makes it much more rare.
Adjusting bias did the trick. Thank you. Out of curiosity, if the vertices were shared ins$$anonymous$$d, the model will consequently look smoothed (which obviously I want not), or there's a possibility to make it look straight however?
No, as each vertex only has a single normal, as soon as you share them you cause the faces to be smoothed.
You can mock up smooth shading with non-shared vertices, but not the other way around.
Your answer
Follow this Question
Related Questions
Light creates distortion on mesh? 1 Answer
Why are my shadows on my meshes, flat? 1 Answer
Voxel engine lighting 1 Answer
No shadows. 2 Answers
Spotlights refuse to cast shadows. 0 Answers