#GLB shows up as black even though it has color in the gltf-viewer

4 messages · Page 1 of 1 (latest)

stoic jewel
#

So my glb is black BUT it has color here https://gltf-viewer.donmccurdy.com/ . I have a bunch of other GLBs I am using that have color and I see the color in my scene. It is just one GLB and I can't figure out why. I am not doing anything different with it.

lime star
#

There are some things you could check:

Lighting

In Three.js, materials won't be visible without lights in the scene. Make sure you have added enough lighting. For PBR materials, an environment map can be helpful to reflect light from the surroundings.

Gamma Correction

Three.js used to handle gamma correction by setting renderer.gammaOutput = true and renderer.gammaFactor = 2.2. But since r112, it has introduced renderer.outputEncoding for this purpose. You may need to set this depending on your texture encoding.

Check the Material

When you load the GLB, you can inspect the material on the mesh to make sure it's being loaded correctly.

Tbh this is as far as I can help you without looking at your full code.

queen pilot
#

@stoic jewel The GLTF viewers online add some default lights to the scene to make things visible.

In your threejs app you'll want to add probably an ambient and/or a directional light to get things visible.

let dirLight = new THREE.DirectionalLight("white",1.);
dirLight.position.set(10, 5, 7).multiplyScalar(4);
scene.add(dirLight);
#

let ambient = new THREE.AmbientLight('white',.5);
scene.add(ambient)