[Solved] Ambient Light Gets Rid of Material Colors?

Hi all,

In my game, I created a blender model with materials that specified the colors of the objects contained in the model. When I imported it into jMonkeyEngine with a gray AmbientLight and a DirectionalLight, I found that the sides that were being hit by the DirectionalLight were colored whereas the sides that were only being lit by the AmbientLight were all and only gray even though all sides were the same color. Is this normal behavior? If so, how can I make the ambient light illuminate based on the material color?

Any help is much appreciated!

Debug: Viewing the part of the model lit by the ambient light only
Debug2: The actual blender file
Debug3: Viewing the model from the side lit by the directional (sun) light


package mygame;

import com.jme3.app.SimpleApplication;
import com.jme3.light.AmbientLight;
import com.jme3.light.DirectionalLight;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector3f;
import com.jme3.renderer.RenderManager;
import com.jme3.scene.Spatial;
import com.jme3.scene.plugins.blender.BlenderModelLoader;

public class AmbientTest extends SimpleApplication {

    public static void main(String[] args) {
        AmbientTest app = new AmbientTest();


    public Spatial test;

    public void simpleInitApp() {
        assetManager.registerLoader(BlenderModelLoader.class, "blend");

        test = assetManager.loadModel("Models/Materials.blend");


        /** A white ambient light source. */ 
        AmbientLight ambient = new AmbientLight();

            /** A white, directional light source */ 
    DirectionalLight sun = new DirectionalLight();
    sun.setDirection((new Vector3f(-0.5f, -0.5f, -0.5f)).normalizeLocal());

    public void simpleUpdate(float tpf) {


    public void simpleRender(RenderManager rm) {



Give it an ambient color. It has only a diffuse color so the ambient is black. Black * any color = black.

Hi pspeed,

How would I change the ambient color for the blender model? From what I can tell, the Spatial class has no method to get its children. Also, after I change the ambient color, would I still need an ambient light?
Just to clarify, does the ambient light add its color to all of the colors or does it multiply by the ambient color and then add? If it does the latter why my model is showing up as gray rather than black?


I think Blender doesn’t know anything about ambient color. But you can set it by exporting your material in the SDK, etc…

Hi pspeed,

That worked! But is there a way to do this programmatically? It seems like such a hassle to change the ambient color every time the blender file is exported.

Thank you so much!



Hi pspeed,

Thanks for your advice! I think the problem is solved now.

Code I used to set the ambient color to the diffuse color:

        if(scene instanceof Node){
            Node sceneNode = (Node) scene;
            sceneNode.breadthFirstTraversal(new SceneGraphVisitor(){
                public void visit(Spatial s){
                    if(s instanceof Geometry){
                        Geometry spatialGeometry = (Geometry) s;
                        spatialGeometry.getMaterial().setColor("Ambient", (ColorRGBA)spatialGeometry.getMaterial().getParam("Diffuse").getValue());