Adding a light to lemur gem

Trying to spice up the lemur gem, I’ve added a light. But, only one spatial is lighted, and I wonder why. Code:

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package prototype.appstates;

import com.jme3.app.Application;
import com.jme3.app.state.AppStateManager;
import com.jme3.light.AmbientLight;
import com.jme3.light.DirectionalLight;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector2f;
import com.jme3.math.Vector3f;
import com.jme3.renderer.queue.RenderQueue;
import com.jme3.scene.Geometry;
import com.jme3.scene.shape.Box;
import com.jme3.texture.Texture;
import com.simsilica.lemur.GuiGlobals;
import com.simsilica.lemur.input.FunctionId;
import com.simsilica.lemur.input.InputMapper;
import jme3utilities.SimpleAppState;
import prototype.appstates.lemur.CameraMovementState;

/**
 *
 */
public class MenuAppStateLemur extends SimpleAppState {

    public static final String GROUP_MOVEMENT = "Movement";
    public static final FunctionId F_Y_LOOK = new FunctionId(GROUP_MOVEMENT, "Y Look");
    public static final FunctionId F_X_LOOK = new FunctionId(GROUP_MOVEMENT, "X Look");
    public static final FunctionId F_MOVE = new FunctionId(GROUP_MOVEMENT, "Move");
    public static final FunctionId F_STRAFE = new FunctionId(GROUP_MOVEMENT, "Strafe");
    public static final FunctionId F_ELEVATE = new FunctionId(GROUP_MOVEMENT, "Elevate");
    public static final FunctionId F_RUN = new FunctionId(GROUP_MOVEMENT, "Run");
    /**
     * We capture some input mappings in case they need to be scaled or flipped
     * later. Mouse and joystick input are often configured with sensitivity
     * settings and this is one way to do that built into InputMapper.
     */
    public static InputMapper.Mapping MOUSE_X_LOOK;
    public static InputMapper.Mapping MOUSE_Y_LOOK;
    public static InputMapper.Mapping JOY_X_LOOK;
    public static InputMapper.Mapping JOY_Y_LOOK;

    public static void initializeDefaultMappings(InputMapper inputMapper) {
    }

    @Override
    public void initialize(final AppStateManager sm, Application app) {
        super.initialize(sm, app);



        initializeDefaultMappings(GuiGlobals.getInstance().getInputMapper());

        stateManager.getState(CameraMovementState.class).setEnabled(false);
        flyCam.setDragToRotate(true);
        AmbientLight al = new AmbientLight();
        al.setColor(ColorRGBA.White.mult(0.3f));
        rootNode.addLight(al);
        rootNode.setShadowMode(RenderQueue.ShadowMode.CastAndReceive);

        // Now create the simple test scene
        for (int i = 0; i < 5; i++) {
            Box b = new Box(1, 1, 1);
            Geometry geom = new Geometry("Box", b);

            Material mat = assetManager.loadMaterial("Textures/Terrain/Pond/Pond.j3m");
            mat.getTextureParam("DiffuseMap").getTextureValue().setWrap(Texture.WrapMode.Repeat);
            mat.getTextureParam("NormalMap").getTextureValue().setWrap(Texture.WrapMode.Repeat);
            mat.setBoolean("UseMaterialColors", true);
            mat.setColor("Diffuse", ColorRGBA.White.clone());
            mat.setColor("Ambient", ColorRGBA.White.clone());
            mat.setFloat("Shininess", 0);
            geom.setMaterial(mat);
            geom.setShadowMode(RenderQueue.ShadowMode.CastAndReceive);
            geom.setLocalTranslation(-8 + i * 4, 0, -4);


            rootNode.attachChild(geom);
        }
        Box b = new Box(20, 20, 1);
        Geometry geom = new Geometry("Box", b);

        Material mat = assetManager.loadMaterial("Textures/Terrain/Pond/Pond.j3m");
        mat.getTextureParam("DiffuseMap").getTextureValue().setWrap(Texture.WrapMode.Repeat);
        mat.getTextureParam("NormalMap").getTextureValue().setWrap(Texture.WrapMode.Repeat);
        mat.setBoolean("UseMaterialColors", true);
        mat.setColor("Diffuse", ColorRGBA.White.clone());
        mat.setColor("Ambient", ColorRGBA.White.clone());
        // mat.setColor("Specular", ColorRGBA.White.clone());
        // mat.getTextureParam("ParallaxMap").getTextureValue().setWrap(WrapMode.Repeat);
        mat.setFloat("Shininess", 0);
        geom.setMaterial(mat);
        geom.setLocalTranslation(-8, -1, -7);
        rootNode.attachChild(geom);

        sun = new DirectionalLight();
sun.setColor(ColorRGBA.White);
sun.setDirection(new Vector3f(-.5f,-.5f,-.5f).normalizeLocal());
rootNode.addLight(sun);
    }
    DirectionalLight sun;
    @Override
    public void update(float tpf){
        Vector2f click2d = inputManager.getCursorPosition();
        Vector3f click3d = cam.getWorldCoordinates(new Vector2f(click2d.x, click2d.y), 0f).clone();
        Vector3f dir = cam.getWorldCoordinates(new Vector2f(click2d.x, click2d.y), 1f).subtractLocal(click3d).normalizeLocal();
        sun.setDirection(dir);
    }
}

Not sure. Lemur doesn’t really do anything that would affect lighting.

Update: tried on a different machine with NVIDIA card, works ok.

On Intel HD 2000 only one cube is lighted. :frowning:

So this effectively has nothing to do with lemur.

I would highly recommend avoiding this:

mat.setFloat("Shininess", 0);

It is known to invoke undefined behavior on various GPUs.

Thanks, but didn’t help :frowning:

However now I understand why some jmonkey demos didn’t actually look like I expected… :sweat: