Imported gltf Model from Blender (+Material) behaves weird with lighting

Hi,

I’m currently working on making the scene look good, so dynamic lighting is what I wanted to implement.

I’ve noticed that meshes imported from blender and their materials are lit up on their own. Only when I use a material from the editor do they become dark like expected with no lights.

This is what it looks like if the scene has no lights.
image

As you can see, the tree is black like it’s supposed to (it uses an editor material)
While the rest is lit up. (straight export from blender)

Setting the emissiveColor to 0,0,0 or any playing around with similar variables causes the mesh to also become dark. But then also not react to lights.

This one is with a spotlight in the sky and a weak ambient light
image

The tree is lit up correctly, but not the rest.
I have not implemented shadows yet.

Any ideas?

Could you repro in the playground ? it looks like you might be missing environment lights ?

I do have a hemispheric light, you can see it in the second screenshot as the tree isn’t completely black when not hit by the spotlight which is above the tree.

Sorry, I can’t share an example, my upload is blocked by cors policy and I have no idea what that is nor how to avoid it.

This is how I set my lights

const light = new BABYLON.HemisphericLight("light", new BABYLON.Vector3(0, 20, 0), scene);
light.intensity = 0.1;
const light2 = new BABYLON.SpotLight("spotlight", new BABYLON.Vector3(12, 200, -5), new BABYLON.Vector3(0, -1, 0), Math.PI * 2, 100, scene);
light2.intensity = 100000.0;

I saw in someone elses post that their model was very big and had to turn up the intensity so that it would light up anything.
The model in question is bigger than the tree, but even setting it to 1000000000 still won’t light up the lab.

To clarify, all things are imported from blender, but some of them have their material replaced in the code to a material from the editor, those ones work correctly, but not the ones left untouched.
They light up on their own, but become completely dark when tampered with.

This would happen on a metallic material. You need this: Using An HDR Environment For PBR | Babylon.js Documentation

The materials aren’t metallic or only a very few of them.

I’ve used the default skybox and now I’m using a env skybox.
This is what you wanted me to do right?
It looks better I guess, but doesn’t have any effect on the lighting.

Can you share a repro ? this is really weird. The playground would be a great place to create the repro.

I want to say that I’ve solved the problem, while not on the actual mesh, while doing another side project I noticed the exact same problem.

It doesn’t have anything to do with Blender materials. While they have emissive Color when exported,
it’s that ‘Color’ isn’t a Vector3. And trying to put a Vector3 on a color type variable will not throw an error, and just make the material black.

When setting emissiveColor like this

mesh.emissiveColor = new BABYLON.Vector3(0,0,0);

will turn the material black.
This is what has to be done

mesh.emissiveColor = new BABYLON.Color3(0,0,0);

yes this would not work indeed, and a repro would have helped catching this in a short time.