Normals reversed imported glTF

Hi,
I’ve created a glTF model with Cinema 4D.
But the normals are reversed when I import it into BabylonJS.
Is there an easy way to invert the normals in Babylon?
thanks

Can you share the model? or even better a repro in the PG?

Did you try to load your model into Sandbox?

As for normals, you may try this (for specific material or all materials)
material.invertNormalMapX = true; material.invertNormalMapY = true;

Maybe there is another problem - reversed textures; in this case you may use texture.uScale = -1;

Would be easier if you recreate your problem in the Playground or at least share the model to have a look a it.

Thank you for your reply.

test model

This is the gltf. If I open it in sandbox it looks good (aside from the metallic look. But materials have to be adjusted.)

Here is the file when I import it and display like I Always do with babylon models.
http://flomotion.nl/tmp/

Your solution for reversing the normals will be good enough. But would be nice if I can somehow import it differently.

Well, as for me, I never had any problems when exporting from C4D, usually everything seems correct.
There is the option in exporter - “Flip Z” - you may check how it works for you…


Here is Playground example with your model, seems OK…
https://playground.babylonjs.com/#U5SSCN#37
(on photo with some roughness texture applied)

You also may notice that at your example in the file http://flomotion.nl/tmp/EB.js you are loading some textures which don’t exist (error 404).
pbrCardboad.albedoTexture = new BABYLON.Texture("assets/image.jpg", scene); and more.

thank you for your answers. Since the PG and sandbox work good it must be something different. And I found it!
I used:
https://preview.babylonjs.com/loaders/babylonjs.loaders.min.js
as loader plugin. And that is inverting the model normals.
When I used:
https://cdn.babylonjs.com/loaders/babylon.glTFFileLoader.min.js

it works as expected.

1 Like