"Flat look" of a particular imported model; doesn't respond to scene lights

I just ran into a weird issue. I created and exported a brick model (.obj + .mtl) from Mecabricks.com to my Babylon project. However, the model seems to have a “flat look” - i.e., it does not react to the scene lights the way my other models (both primitive & imported meshes) do.

Setting receiveShadows to true did not help things either. In any case, I never had to apply that setting to the other meshes.

I have attached a snapshot of the .mtl file as well.

I tried altering the Ks values (read an article somewhere); but that did nothing.

What should I do? How come my other models (BJS cube & the player character) react to the scene light but not the brick model?

P.S. The brick’s colors look the same from all directions - so the direction of light shouldn’t be a factor here.

Are you sure your model has normals?

Look into the .obj file itself and see if normals are defined here.

Also, try to set Ka to 0 0 0. I assume it means “ambient”, and 1/1/1 means full white for the ambient term.

1 Like

I am guessing entries starting with vn stand for vertex normals. Right?
There are no vn entires in my .obj file.

Then how come the same model “looks fine” (i.e., reacts to lights) when imported in Blender, but not in Babylon?

Btw, setting Ka 0.0 0.0 0.0 doesn’t change anything.

You can have BJS compute the normals for you after load.

for (const mesh of scene.meshes) {
    let positions = mesh.getVerticesData(BABYLON.VertexBuffer.PositionKind);
    let normals = new Float32Array(positions.length);
    BABYLON.VertexData.ComputeNormals(positions, mesh.getIndices(), normals);

    mesh.setVerticesData(BABYLON.VertexBuffer.NormalKind, normals);

I did not actually run this.


Thank you so much. It worked perfectly!

Link to an article on normals & shading for future reference -