subMeshes, MultiMaterial, and DOUBLESIDE rendering

I’m not seeing the back faces when using double-side rendering on sub-meshes.

https://www.babylonjs-playground.com/#2Q4S2S#194

Am I missing any setup required to make this work properly or is this a bug?

Setting .backFaceCulling = false on the materials does work.

It seems the BABYLON.Mesh.DOUBLESIDE parameter is used only when no material is applied on the sphere.

BABYLON.Mesh.DOUBLESIDE is a parameter used at construction time on some provided BJS meshes. It adds twice more indices and vertices (so facets or triangles) in the mesh geometry, whatever the material used then.

backFaceCulling = false is a material property. It forces a triangle to be rendered even if the camera is facing its back face, regarding its vertices drawing rotation order (clockwise or not).

Let’s try your example, with no multimaterials : https://www.babylonjs-playground.com/#2Q4S2S#196

Now, the same with multimaterials AND double sided sphere (note that I changed the start/count of indices in the submeshes) : https://www.babylonjs-playground.com/#2Q4S2S#197

The same, with no DOUBLESIDE, but with backFaceCulling disabled : https://www.babylonjs-playground.com/#2Q4S2S#198

Depending on your need, it may be simpler to use the material backFaceCulling property then.

2 Likes