I have my first try on threejs recently, attempting to render some gltf2 models in my demo. However, the metal material in my models cannot be rendered properly simply by following examples on GitHub.
There are some websites that can get exactly the same model rendered properly. Here’s the screenshot.
As for the model loading part, I did not do much programming though (the simplest way)
const loader = new GLTFLoader();
loader.load(
this.loadPath,
(gltf) => {
const scene = gltf.scene || gltf.scenes[0];
const clips = gltf.animations || [];
if (!scene) {
// Valid, but not supported by this viewer.
throw new Error(
'This model contains no scene, and cannot be viewed here. However,' +
' it may contain individual 3D resources.'
);
}
this.setContent(scene, clips);
});
setContent (object, clips) {
.........
this.controls.enabled = true;
this.controls.saveState();
this.scene.add(object);
this.content = object;
}
Before you get your hands on MeshPhysicalMaterial, please setup your scene like in this demo.
Meaning you use PMREMGenerator in order to preprocess the environment map before applying it Scene.environment and Scene.background. This is more or less mandatory when using a PBR material.
Can you please describe in more detail what you mean with “does not work”? Are the reflections too dull similar to your screenshot?
It does not make sense to configure clearcoat if you are not using a respective normal map. Besides, you should not add hdr to MeshPhysicalMaterial.envMap if you configure Scene.environment.The texture hdr is wrong in any event since it is not preprocessed with PMREMGenerator. Try it with this material:
const material = new MeshStandardMaterial( {
metalness: 1,
roughness: 0
} );
Yes, I just want my model to be rendered more real like the first image, whose metal part is rendered exactly the way before it was exported from those modeling tools.
And I am trying to solve my problem through reflecting environment on my model. Not sure whether this is the right way through.