Android load glb model

The model looks very black.
DirectionalLight and AmbientLight have been set.

  AmbientLight ambientLight = new AmbientLight(new ColorRGBA(ColorRGBA.LightGray));
  rootNode.addLight(ambientLight);

  DirectionalLight sun = new DirectionalLight();
  sun.setDirection(new Vector3f(-0.5f,-0.5f,-0.5f).normalizeLocal());
  sun.setColor(ColorRGBA.White);
  rootNode.addLight(sun);

Does anyone know how this happened? Do I need to set anything else?

Yes, you need to add a light probe to the scene. You can use a pre-made probe or generate one with LightProbeFactory.

You can use this pre-made one here:https://github.com/jMonkeyEngine/jmonkeyengine/tree/master/jme3-testdata/src/main/resources/Scenes

Node probeNode = (Node) assetManager.loadModel("Scenes/defaultProbe.j3o");
        LightProbe probe = (LightProbe) probeNode.getLocalLightList().iterator().next();
        rootNode.addLight(probe);

See this example for how to generate one for your scene.

Related topics:

1 Like

Note, PBR material might be heavy for Android devices so if you do not require PBR material I would suggest converting them to the Phong material (Lighting.j3md).

There is also an optimized version of PBR developed for mobile in case you want to check:

1 Like

Thank you very much for your help.

2 Likes