Lighting on wrong side of reflected mesh in MirrorTexture

(I tried to create a Playground to show this issue but was running into CORS issues trying to load an external GLB file :upside_down_face:)

ISSUE
The lighting is on the wrong side of the reflected mesh β€” this seems to only happens w/ loaded meshes. Specifically GLB meshes (which is the only type I’m using). When I look at both sides of a GLB mesh I can see that the light source in the reflection is coming from the opposite direction(s). (I’m using a DirectionalLight)

Hopefully the screenshots below explains the issue better!

I also decided to try out a loaded OBJ mesh to see if it was the same issue β€” but it seems the OBJ has no reflection at all? :sweat_smile:

Please let me know if there’s anything I can try, to fix this on my end. Thanks!!

β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”

GLB Front Side View β€” Lighting on wrong side of GLB mesh

GLB Back Side View β€” Lighting on wrong side of GLB mesh

β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”

OBJ Example β€” No reflection

Hey @sebavan, I saw you were helping with another MirrorTexture bug. Do you happen to know anything about this issue I’m running into?

obj are using an additive reflection, so black would not be visible cause not added.

In pbr reflection is controlled with metalness but the highlights would not reflect as a symetrical value. They would only be where the light hits the faces which could be what you are experiencing in the first case.

A repro would really help to ensure it is what is happening.

Thanks for getting back to me! :beers:

Here’s a repro β€” https://playground.babylonjs.com/#B9UHX6
β€’ Small box = Babylon
β€’ Middle / Wood Box = GLB
β€’ Other box = OBJ

The light is coming from one direction. All boxes are lit correctly. The reflection is correct for the Babylon mesh and OBJ mesh but not for the GLB mesh. As you rotate around the scene you’ll see that the light is hitting the opposite side of the OBJ mesh that’s being reflected.

Figured it out :sweat_smile:

I was able to fix it by setting:
material.twoSidedLighting = false

This made me realize that this comes directly from Blender. So if anyone else runs into this you can either modify the twoSidedLightning property in Babylon or in your Blender material turn ON Backface Culling before exporting :+1:

Ohhhh yes this would not help :slight_smile: