Closed jseinturier closed 2 months ago
@jseinturier In order for the model's PBR materials to render property, the scene needs a suitable LightProbe
.
Thanks a lot for the quick Answer. I have not been able to find clear examples or documentation regarding the use of LightProbe within JMonkey. I will search a little more.
For tech support questions, you are likely to get deeper/more thorough help on the forum. Also numerous examples of light probe use, both generated and pre-calculated.
I've found informations about LightProbe within the jme3-examples package. Following code:
import com.jme3.app.SimpleApplication;
import com.jme3.asset.plugins.FileLocator;
import com.jme3.environment.EnvironmentCamera;
import com.jme3.environment.LightProbeFactory;
import com.jme3.input.ChaseCamera;
import com.jme3.light.AmbientLight;
import com.jme3.light.DirectionalLight;
import com.jme3.light.LightProbe;
import com.jme3.light.SpotLight;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector3f;
import com.jme3.scene.Spatial;
public class GLBAnimatedModel extends SimpleApplication {
private int frame = 0;
@Override
public void simpleInitApp() {
DirectionalLight sun = new DirectionalLight();
sun.setDirection(new Vector3f(0,0,0).normalizeLocal());
sun.setColor(ColorRGBA.White);
rootNode.addLight(sun);
AmbientLight al = new AmbientLight();
al.setColor(ColorRGBA.White.mult(1.3f));
rootNode.addLight(al);
SpotLight sl = new SpotLight(new Vector3f(0.0f, 0.0f, 0.0f), Vector3f.UNIT_Y);
sl.setColor(ColorRGBA.White.mult(1.3f));
rootNode.addLight(sl);
// Load the GLB model
assetManager.registerLocator("data", FileLocator.class);
Spatial scene = assetManager.loadModel("HoverRocket.glb");
rootNode.attachChild(scene);
// PBR - Environment camera initialization
final EnvironmentCamera envCam = new EnvironmentCamera(256, new Vector3f(0.0f, 0.0f, 0.0f));
stateManager.attach(envCam);
flyCam.setEnabled(false);
ChaseCamera chaseCam = new ChaseCamera(cam, scene, inputManager);
this.getViewPort().setBackgroundColor(ColorRGBA.LightGray);
}
@Override
public void simpleUpdate(float tpf) {
frame++;
// PBR - LightProbe initialization
// Rendering need to be effective before adding LightProbe
if (frame == 2) {
final LightProbe probe = LightProbeFactory.makeProbe(stateManager.getState(EnvironmentCamera.class), rootNode);
probe.getArea().setRadius(100);
rootNode.addLight(probe);
}
}
/**
* The main method.
* @param args the main method arguments
*/
public static void main(String[] args) {
GLBAnimatedModel app = new GLBAnimatedModel();
app.start();
}
}
works fine and display the model with all its textures.
Thanks to all of you..
Hello,
I'm trying to load and display a model that is stored as GLB file within JMonkey.
Here is my code:
The GLB file (HoverRocket.glb) is accessible by downloading the GLB export from SketchFab here: https://sketchfab.com/3d-models/hover-bike-the-rocket-8b2e5bfca78e41c791b4e5b5e8c04512.
Options that i've used for download are:
.glb 4MB Texture size: 1k
When i run the model, only some textures are visible, other ones are just black.
I think that there is a problem within the GLTF loader (or maybe a miss use from myself.
The GLB fine is fine when imported within Blender (all animations and all textures availables).
I also made a validation on the GLB file, using Kronos Tool and the result shows error within animation but not for models or textures: