but all I get is a black screen.
however, when i add:
Spatial scene = assetManager.loadModel("Models/scene.glb");
Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
scene.scale(2f, 2f, 2f);
scene.setLocalTranslation(0f, -10f, 0f);
I get the shape of the scene, but with a white texture.
I have added the texture(Image) through blender Uv Editing.
Could someone please help.
If you remove these liens of code it should work. Your model will already be using an embedded material when you load it with the assetManager, so this code you had is replacing the embedded material with a blank unshaded material (as Pavl mentioned earlier:)
An unshaded material will render without any lights in the scene, so that is why you got something to appear when you apply that.
But the material embedded in your GLB file by default will use the PBRLighting.j3md material definition, which requires a Directional light and LightProbe to render properly.
Yeah if you’re using the embedded PBR shader and don’t actually want to replace it with the unshaded one, then you do need both of those lights for the PBR shader to work as intended.
Directional Light will simulate the global sun light for an entire scene, and a LightProbe is used to simulate indirect light and has a radius, so you can generate unique light probes to match certain areas of your scene. But there’s also this one in the engine’s jme3-testdata library that you can use for testing
The AmbientLight can also be used to scale a LightProbe’s color/brightness for all Spatials/Materials affected by that AmbientLight, but it is not necessary for PBR like the other two.