Blender Imported Objects Not Showing Ambient Light

In my previous thread, y’all helped me finally get a cube imported from Blender with its normalmap intact. However, it seems that a side effect of importing a material from Blender instead of creating it in JME3, is that the material will not reflect ambient light, and just appears black if the only light in the scene is ambient.

(Files: .blend file | normal map image)

All I’ve done is drop the .blend and .png into the Models folder, convert the .blend to .j3o, and add + an ambient light to the scene (code below). Oh, I also had to go in and delete the Camera, Point Light, and Lamp from the generated .j3o file (because I forgot to delete those from the .blend) to make sure there weren’t extra lights adding confusions.

It was suggested that the Blender Importer doesn’t properly set the “UseMaterialColors” property on the j3o’s built-in material, and I don’t see a way to set that easily (since the Node object doesn’t have a getMaterial() method). I could make a new material and apply it manually, but the fix I found for the normalmap problem was to STOP using custom materials and let the Blender Importer take care of it. =T

So, is there a good way to edit the properties of a pre-existing material on an imported Blender model (or at least get it to default “UserMaterialColors” to true)? Or do I need to go back to the other thread and try to find a way to assign .j3m’s in the code or scene editor without messing up my normalmaps?

Here’s my simple lil’ program:

public void simpleInitApp() {
Node geom = (Node)assetManager.loadModel(“Models/normalCubeTri.j3o”);
TangentBinormalGenerator.generate(geom);

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

    rootNode.attachChild(geom);
rootNode.addLight(sun); //if you comment this out, all is darkness

AmbientLight al = new AmbientLight();
al.setColor(ColorRGBA.White.mult(.4f));
rootNode.addLight(al);
}

Alternatively, is there some other commonly-accepted way of getting .blend models into JME3 aside from converting them directly to j3o’s? If I’m forced to resort to some more venerable approach in order to get both Normal Maps and Ambient Lights working nicely together, I’m willing to look into it. =)

You have to generate the tangents on the geometry. Best watch this video once completely, it explains most hurdles for the model asset workflow by example:

I’ve run into these symptoms myself but as I always use my own materials I’ve never really looked into it.

If you look in the scene explorer you can see the scene graph for your j3o. Using that you can identify the geometries and query them for their material (I’m not sure if there is a way in the SDK to do that or if you need to do it programatically).

@zarch – yep, it’s possible in the SDK – you can expand all the way down to the mesh and then see the material in the properties window. With something imported from Blender there’s no material listed there, though, just an option you can click on that says “Create j3m file” – which will generate a material and place in the same folder as the model. It’s very convenient, unless that material mysteriously muddles up your normals. :wink:

@normen – thanks for the video! It sounds like exactly the sort of this I may be looking for. It sounds like it doesn’t include anything about bump/normal maps (maybe it does) but I will try to shoehorn what I’ve learned about that into the overall process. I feel that there must be a generally successful way of adding complete models with all the graphical bells and whistles to the scene, but some of the bells and whistles always get knocked off at runtime. =P Maybe this video will bring me a true enlightenment, I will watch it this evening, if all goes as planned.

The texture atlas stuff with the Blender “box prepared for uv texturing” looks promising – I’ll try to get that feature set up, and see if it helps me get my asset pipeline sorted out to the point where Ambient Light and Normal Maps are not mutually exclusive! Will report back. =P