Baking two meshes: one has its backfaces flipped

Hi everyone

Please check out this playground: Babylon.js Playground

I was trying to bake away the GLFT root node which worked surprisingly well with Mesh.bakeCurrentTransformIntoVertices.

However, I am getting seemingly arbitrary fails where meshes have their backfaces flipped. See the green mesh in the playground.

That means if you toggle backface culling off, green will render fine.

Alternatively, you can set Mesh.overrideMaterialSideOrientation (tried 0-6) but while this fixes green it breaks red.

I really would like to avoid turning off backface culling in general if possible.

Best wishes

Hello! I took way too much time to realize this, but the issue is that both cubes are sharing the same index buffer. So for the second cube, it ends up flipping its faces twice:

I updated the first cube to use a copy of the index buffer, so each buffer is flipped separately: Babylon.js Playground (


Oh dear, sorry @carolhmj for being a pain :flushed: I swear I did not touch any of this stuff.

Ah, sorry, I didn’t mean to imply you did anything wrong, I was just berating myself because I feel I should have realized it sooner :sweat_smile: I was like mentally “why is this not working this should have been working!” for half an hour until I had the flash of the solution :rofl:

1 Like