Material SideOrientation/Normal flipped during glb export

#1

Hello!

I am importing an obj file into my scene. Then I am exporting it using GLTF2Export.GLBAsync.
I am using a right-handed coordinate system. When I re-import the glb file I have the wrong sideOrientation on materials. Is it possibly an issue of converting between standard material and PBR material not taking into account the right handed coordinate system? When I switch to left handed it works fine.

Best Regards,
-Brian

#2

Try…

var theMesh = scene.getMeshByID(“theMeshName”);
theMesh.overrideMaterialSideOrientation = 1;

#3

That would fix the issue but it seems like a band-aid?

#4

This should work as we are taking the useRightHandedSystem in account in the exporter.
Can you repro on the playground?
Pinging @bghgary

#5

Yeah, this sounds like a bug. A PG would be helpful.

#6

I’m working on a playground. I got it to this point:
https://www.babylonjs-playground.com/#95MJI8#15

Unable to import exported glb at the moment.

#7

Okay I can reproduce it now.
Here you go:
https://www.babylonjs-playground.com/#95MJI8#22

When right handed the material orientation is wrong.

#8

@BrianW Thanks for the PG. Do you mind filing a GitHub issue?

#9

Not at all. Here you go:

Thanks!

1 Like
#10

I’m having the same issue with another block. I believe it has something to do with multi-material.

Also the difference in lighting between the direct import vs glb import is strange if anyone could explain it to me I would be very happy.
https://www.babylonjs-playground.com/index.html#95MJI8#32

#11

pinging @bghgary

#12

The root of the problem is that the babylon file is referencing a texture https://dl.dropbox.com/s/oziv24ps27qhel2/basket_texture.jpg that isn’t an image. The handling of this is wrong somewhere in the rendering/export for this edge case, but fixing the asset will probably make it work.

#13

Replaced texture with base64 string. The issue seems to still be there…
https://www.babylonjs-playground.com/index.html#95MJI8#33

#14

I was not adding in the multi-material + sub materials to the scene. This fixed the side-orientation issue.
Texture doesn’t seem to import though.

https://www.babylonjs-playground.com/index.html#95MJI8#34

#15

@bghgary should be able to answer soon (We have a busy week, sorry for the inconvenience )

#16

No problem. Thanks for the help.

#17

Looks like there is an issue with the exporting code. @BrianW Can you file an issue on GitHub? @Drigax Can you look at this? Something is wrong with the way the materials are being exported. I can show you offline.

#18

Sure, I have about 2 weeks worth of backlog to get through before I can give this my full attention, but I’d greatly appreciate any analysis :slight_smile:

1 Like
#19

Heres the issue:

#20

Thanks for creating the issue, I’ll try to take a look at this today.

Created a possible PR to fix this here:

1 Like