Hi guys,
Some meshes show backface in my imported model
[GLB] Backface culling issue when cloning mesh | Babylon.js Playground (babylonjs.com)
I tried to copy overrideMaterialSideOrientation
from the original mesh but it didn’t help. I believe I shouldn’t disable backface culling just to bypass this issue.
Any suggestion?
Thanks
Can you explain what part of the scene is wrong? If loading the GLB is showing faces that you are not expecting, the GLB is probably wrong. I don’t see any materials in your GLB that is marked as doubleSided
.
Sorry for the late response, I had some updates in the playground link
[GLB] Backface culling issue when cloning mesh | Babylon.js Playground (babylonjs.com)
The second pipe shows backface after cloned
This is a result when I disabled backface culling
The problem is that the original mesh is an instanced mesh. An instance mesh doesn’t use its overrideMaterialSideOrientation
so the real one comes from sourceMesh
. We should perhaps forward this to the source mesh automatically. @sebavan @Evgeni_Popov Any thoughts?
Here is the fixed PG: https://playground.babylonjs.com/#RH1RMV#2
@thinh.pham Why are you cloning the instanced mesh? If you don’t want the loader to create instanced meshes, you can tell it not to by setting the createInstances property to false: https://playground.babylonjs.com/#RH1RMV#3
1 Like
Indeed, createInstances
property should be the right choice. Thanks for the suggestion.
1 Like
The new mesh is created from scratch in the PG, so I don’t see any other solution than manually copying the value of overrideMaterialSideOrientation
(the name clonedMesh
is a bit misleading, the mesh is not created by calling clone
).
1 Like
What I mean is whether InstancedMesh
should override its overrideMaterialSideOrientation
property like what we do for many other properties (e.g., visibility
or skeleton
, etc., etc.) so that it gets the value from the sourceMesh
. This property is a bit different in the sense that it is only available for Mesh
and not AbstractMesh
so maybe it’s not quite the same.
For instances, overrideMaterialSideOrientation
is already the one from the source mesh, as they are rendered with the same material than their source mesh:
1 Like