Light seems to light up the *opposite* side of mesh

I’m banging my head at this. I have a point light but it seems to light up the other side of an object. It’s like the opposite of the way it lights up the sphere in the examples.

It’s a relatively simple scene, but I can’t put it in the playground due to the side of the materials and i’m not sure how to simplify it down for demo.

Video: Loom | Free Screen & Video Recording Software

Hello and welcome to the Babylon community! That does look weird… are you able to share the model with us, even if not on the playground? A github, dropbox link, anything works! :slightly_smiling_face:

2 Likes

Thanks! GitHub - quorumcontrol/chair: playing with babylonjs should have it - I’m running it with yarn poi --serve src/index.html

1 Like

Thank you for sharing your project! I’m taking a look at it now. The normals do look strange…

(I changed the chair’s materials to the default mesh material to see if it wasn’t anything on the materials side. Also turned off all the lights except one and moved it a bit around)

image

2 Likes

Opened up the model on Blender to take a look and the normals make a lot more sense here! (Vertex normals in dark blue and face normals in light blue). You can mainly see this in the back of the chair, where they’re actually pointing to the opposite direction instead of up. Since Babylon uses a Left-handed, Y-Up coordinate system by default, and Blender uses a Right-handed, Z-Up one, that would be my prime suspect…

1 Like

THank you for this! Is there a way I can specify in babylon to switch it?

Since there is no clear convention for OBJ files, unfortunately we can only read the values as they are passed. Through, if the entire file were using a different coordinate system, I’d expect the chair itself to also be sideways, not only the normals, so it seems there are two different coordinate systems in the file? But Blender is usually good at fixing this stuff automatically, so I exported the model from Blender to a new obj file, using these settings and the lighting makes sense now:

image

image

I forgot to properly import the groups into Blender but I’m going to do that now :smiley:

2 Likes

you are amazing!

1 Like

2 Likes

Ok, I imported and exported the proper groups in Blender and now we have THE CHAIR IN ALL OF ITS GLORY!

(Now I really want a cool chair like that)

But yeah, for issues where the lighting looks “weird”, like in this case where they were lighting the opposite direction, normals are the usual suspects. A good bet for debugging these is checking the “Render Vertex Normals” option in the Inspector, and also simplifying the scene down, like removing materials, turning off all the other lights, etc…

image

If the normals do look weird, it might be an export issue like that. I usually rely on Blender to fix meshes, since it’s free, but I think any big 3D modeling program should let you chose a coordinate system when exporting.

4 Likes

I can’t express my gratitude! Thank you so much! If you ever swing by the Crypto Colosseum I will shower you with tokens :).

Really: so kind and helpful.

2 Likes

Are you using Babylon in Crypto Colosseum ? I might have completely miss the post and my brain is probably pretty close from a gold fish ones :slight_smile:

We are not yet. Stay tuned :slight_smile:

2 Likes

Niiiiiiiiceeeeeeeeeeee I know I will like it :wink:

1 Like