Fixing mesh problems in Minetest

     Okay, so that might not be the best title in the world, but in this blog post I'm going to be going over how to fix lighting issues with meshes exported from Blender and then used in the massively popular voxel game, Minetest. The biggest issue I think people have is all because of Normals. Blender is usually pretty good with keeping normals pointed in the right direction but every once in a while you'll get some normals that are a little confused and point backwards. You might not notice it in Blender, but once the mesh is in the game the lighting on it will always look a little goofy. Let me shut up and show you what I mean, first a picture with the bad normals.
Notice the difference in the lighting.
     Now hows about an image showing how it should, and can look.
Notice how all the lighting is the same.
     So maybe you're having this problem with your mod, and you're wondering 'how do I fix this?' Well good luck buddy.....

     JUST KIDDING. Here's how to do it, please note, I purposefully created bad mesh for this example, please don't do things badly just so you can try and automatically fix the problems, 'cause it doesn't always work.
Here are my two meshes.
     In the above image we have two simple slopes, these are the two that we saw in the first picture, the slope on the left has bad normals, notice how it is a little darker than it's counterpart.
     Depending on how familiar you are with Blender you might know about this gem, in the right tool bar, (Show/Hide with N) there is an option under the Mesh Display tab to show normals. (Note you can click on the image to view it full size.) The normals are shown by the aqua blue lines that point out of, or into, the mesh. Generally speaking you'll want all your normals pointing out. The mesh selected in this picture renders correctly within Minetest.
     Here we have the mesh with the bad normals, notice how the sloped face doesn't have a blue line sticking out of it? That is a problem, luckily it's easy to fix.
     By selecting all the faces/edges/vertices, of the mesh (A on the keyboard works wonders) and clicking on the Recalculate button, circled in the image above Blender will try and fix any normals that are pointing the wrong direction. (NOTE: if you don't see the toolbar on the left side try hitting the T key)
     After clicking on the magical Recalculate button we have a blue line flowing out of the sloped face as we want.

     This will work for most things, but what if Blender is setting some faces the wrong way? well then select those faces and click the Flip Direction button located directly below the Recalculate button and Blender will only flip the direction of the selected faces.

     Hopefully this helps somebody out, you know who you are. :D Any questions don't hesitate to leave a comment, hit me up on G+ or send me an email. If you'd like a video version just let me know and I'll see what I can make happen.