Ambient light not working with custom mesh. Directional light works

I made a custom mesh programmatically. Colored the vertices, added normals, and tested with Directional light. Works great, awesome.

Then I tried adding an ambient light to the scene as well, but did not see a difference.
[java]
AmbientLight al = new AmbientLight();
al.setColor(ColorRGBA.Yellow.mult(1.3f));
rootNode.addLight(al);
[/java]

I took out the directional light and the entire scene is black.
Am I missing something?

How is your material defined?

[java]
Material mat = new Material(assetManager, “Common/MatDefs/Light/Lighting.j3md”);

    mat.setBoolean("UseMaterialColors",true); 
    mat.setBoolean("UseVertexColor", true);
    mat.setBoolean("VertexLighting", true);
    mat.setColor("Diffuse",ColorRGBA.White);  // minimum material color
    mat.setColor("Specular",ColorRGBA.White); // for shininess
    mat.setFloat("Shininess", 50f); // [1,128] for shininess
    mat.getAdditionalRenderState().setFaceCullMode(FaceCullMode.Off);
    
    geom.setMaterial(mat);
    
    rootNode.attachChild(geom);

[/java]

1 Like

So… you’ve told it to use material colors but you’ve left Ambient set to “black”. Probably not a coincidence that ambient has no effect.

1 Like

Ah, oops. Didn’t realize default was black. Mucho thanks speederino.