.OBJ / .MTL - Textures visible only with Ambient Light

Dear JMonkey Community,

i’m quite sure, that i’m just making a stupid mistake somewhere in my code, but i don’t know how to get it right. I created a simple model with Maya 2010, including a single texture (File: Test.zip). File format is .obj (including normals) with .mtl material informations and a .png texture. The model is importet with this code, which works fine:

private Spatial loadModel(String pathAndFileName, Node node, Vector3f position, Vector3f scale, Vector3f rotate){
Spatial model = assetManager.loadModel(pathAndFileName);
model.scale(scale.x, scale.y, scale.z);
model.rotate(rotate.x, rotate.y, rotate.z);
return model;

As expected, the model is not visible / rendered black without light source. When adding an AmbientLight to the rootNode, the model becomes visible (slightly, as expected):

AmbientLight ambientLight = new AmbientLight();
ambientLight.setColor(new ColorRGBA(0.1f, 0.1f, 0.1f, 1.0f));


Now the porblems start. When adding other light sources, nothing happens:

DirectionalLight directionalLight = new DirectionalLight();
directionalLight.setDirection(new Vector3f(1.0f, 0.0f, 0.0f));

PointLight pointLight = new PointLight();
pointLight.setPosition(new Vector3f(0.0f, -2.0f, 0.0f));

The model looks exactly the same and becomes invisible again, if the AmbientLight is removed. Model normals look ok in Maya and are exported in the .obj file. I also tried the ogre xml format, but that didn’t solve the problem. As you can see, the model is a simple planet, which will be orbitting around a sun, so one side of the planet should be rendered black (a PointLight is used for the sun).

Question: why is the model only visible when using AmbientLight and does not react to other light sources and what can i do?


You don’t have lights inside of the object by any chance? Can you put one of geometric generated ones from std lib next to it/at the same position and see it is getting illuminated properly ?

Hello abies,

thanks for the fast reply.

No, the light source is not inside the objekt. The model center is at (0.0f, 0.0f, 0.0f) and it’s diameter is only 1.0f. The PointLight position is at (0.0f, -2.0f, 0.0f) with a light radius of 4.0f. As you proposed, i imported the ninja-objekt from the JME turorials. You can see the results here (for better visibility, i slightly moved the PointLight from (0.0f, -2.0f, 0.0f) to (-2.0f, 0.0f, 0.0f):

AmbientLight (color (0.1f, 0.1f, 0.1f)) + Point Light (represented by the tiny yellow sphere, PointLight position is -2.0f, 0.0f, 0.0f, radius is 10.0f, color white):

AmbientLight (color (0.1f, 0.1f, 0.1f)) + Directional Light (DirectionalLight direction is 1.0f, 0.0f, 0.0f, color white):

The ninja is illuminated properly.

Problem solved: Maya 1020 issue.

When exporting an object as .obj / .mtl file with Maya, the .mtl may look like this:

newmtl initialShadingGroup
illum 4
Kd 0.00 0.00 0.00
Ka 1.00 1.00 1.00
Tf 1.00 1.00 1.00
map_Kd Test.png
Ni 1.00

Kd is the parameter for diffuse lighting, which was set to (0.00, 0.00, 0.00). The ambient light parameter (Ka) was set to (1.00, 1.00, 1.00), so the object could only become visible using AmbientLight. Any diffuse light source had no effect. Replacing Kd 0.00 0.00 0.00 with Kd 1.00 1.00 1.00 did the trick.