Basic NormalMap troubles

Hi all, I’ve been stuck for about a week now trying to create a simple cube with a normalmap and have it display properly in JME3. I’m fairly new to both Blender and JME3, but I’ve followed three different video tutorials for UV-unwrapping a cube, creating a normalmap for it, then applying the normalmap and successfully rendering the cube in Blender.

When I bring everything over to JME3 though, it just goes haywire. At first the entire cube was turning black when I added a normal to the material. Now it’s a little better – two sides of the cube show a correct normalmap, while the other four are blank (and the object appears to ignore all ambient light, but that’s a secondary concern). I’ve gotten better results using code-generated primitive shapes, but I want to get it working perfectly with a Blender-created shape so I can do more complicated models later on.

Any help would be highly appreciated! Here’s the files involved in this ongoing travesty of mine:

.blend cube, which I converted into a .j3o – dropbox link
texture PNG file, which I generated from a UV-unwrapping + baked normalmap tutorial thing – dropbox link
material I created in JME3, has that texture as the normalmap – dropbox link

Here’s the entirety of my code:

public void simpleInitApp() {
Spatial geom = assetManager.loadModel(“Models/normalCube.j3o”);

DirectionalLight sun = new DirectionalLight();
sun.setDirection(new Vector3f(1,1,-2).normalizeLocal());


And here’s a picture of what it looks like when I run the program; as you can see, one of the sides is fine, but the other is just blank.

And here’s what it looks like in Blender, all nice and normal-mapped everywhere it ought to be, with the now-visible face expressing my current emotions.

Any ideas? =) Thanks!

Your model seems fine to me:

This is how I load my models myNode = (Node)assetManager.loadModel(“Models/myModel.j3o”);
If you converted the model to .j3o correctly you don’t have to set the material. It’s already set on the .j3o. Also, “TangentBinormalGenerator.generate(geom);” is not needed for this.

Also try triangulate your mesh before you export. Mesh->Faces->Triangulate Faces. Or just in edit mode with all faces selected press CTRL+ t.

To OP, what version of JME are you running?

I’m running jMonkeyEngine SDK 3.0RC2

Hmm, that screenshot is what you get when you do Import Model on my blend file? It just gives me a white cube in the preview model window when I do that, even when the texture’s in the same folder. Except for this time, when I tried it again and got a black cube. =\ Did you alter any of the settings on the Import Model page?

I’ll try the Triangulate Faces things tomorrow, but it’s weird that the file I provided works, for people who are not me. =P

So you are running a fresh download and have never let the auto-updates run? That could be your problem.

Variants to solve:

  • you need to smooth faces of the lowpoly model before baking. Just switch to EditMode and press smooth faces. Then bake.
  • you need UV islands has some distance between each other. about 10 pixels distance is ok…

Sorry… not here i posted…

Got it! I ran the auto updater again just to be safe, and Triangulated the Faces, and deleted the extra material that I’d made, just letting the .j3o use its own material. Then I realized the texture needed to be in the same directory as the j3o for the Blender material to work properly; once I copied it there, I see normalmaps on all sides. Hooray :smiley:

Still having problems getting ambient light to affect the cube, but I think that must be unrelated to normalmap problems, so I’ll keep digging. Thanks everyone; hopefully I can replicate this success on future meshes. :slight_smile:

I’ve seen something before about the materials that get imported from blender - something means ambient light doesn’t effect them.

Never worked out what tho.

I think ambient light won’t affect them if the material has “UseMaterialColors” true and then only a black ambient color. I could imagine the blender importer setting the first by default and I could also imagine it forgetting to set something other than black for the second.

@Berzee be sure to make another thread if you can’t solve your ambient light problem.