Rotated GLB mesh shaded differently?

I have not produced a reduced example using the playground as I can not yet load a GLB file from GitHub on the playground. The GLB file has multiple meshes. Some of these I have rotated and when given the same material as the other meshes, seems to have some strange inverse lighting / shading. Any thoughts on what could be going on here?

let grey_material: StandardMaterial
function grey_out (mesh: AbstractMesh)
{
    if (!grey_material)
    {
        grey_material = new StandardMaterial("grey_material", mesh.getScene())
        grey_material.diffuseColor = Color3.Gray()
        grey_material.backFaceCulling = false
        grey_material.specularColor = Color3.Gray()
    }

    mesh.material = grey_material
    mesh.getChildMeshes().forEach(mesh => mesh.material = grey_material)
}

And the GLB file with the different meshes is here: sustainability-sims/low_poly_house_3.glb at 7c9b17fde80e9e3db4ed6531686f6bc85a8fbf64 · centerofci/sustainability-sims · GitHub

And some of the triangular meshes rendering strangely are cloned and rotated here: sustainability-sims/draw_roof_walls.ts at 7c9b17fde80e9e3db4ed6531686f6bc85a8fbf64 · centerofci/sustainability-sims · GitHub

Screenshots of “inverted” shading:


Hi.i think you have problems with mesh normals direction after rotate mesh and dont flip normals. Simplest way invert mesh with scale -1 and dont rotate this meshes or you can use backFaceCulling = true but you doubled your meshes and drop performance

1 Like

Hello! A playground will be helpful for us to understand your situation, but this definitely looks like inverted normals for me :slight_smile:

1 Like

Hello @ajp just checking in, are you still having issues? :slight_smile:

1 Like

Thanks for checking in. I think I was able to fix this but I can’t remember how now as not been able to work on it recently.

1 Like

@kvasss @carolhmj yes this was inverted normals! :slight_smile:

Playground showing strange colouring: https://playground.babylonjs.com/#LYUF0J#3

And spot the odd one out in Blender!

Solved it using this: Blender - How To Flip Normals - YouTube

2 Likes