Search code examples
javascriptbabylonjs

Back is black when backfaceCulling == false


After importing my mesh I'm making a red standard material, applying it to the mesh and turning off backFaceCulling, but the inside is pitch black. How can I make the interior of my mesh match the outside?

  mesh = newMeshes[0];
      
  var mat = new StandardMaterial("red", scene);

  mat.diffuseColor = new Color3(1,0,0)
  mesh.material = mat;

  mesh.material.backFaceCulling = false;

Material is red on front but black on back


Solution

  • I got a hint from this section of the docs https://doc.babylonjs.com/how_to/custom

    Since a material is no longer being used, backFaceCulling cannot be set and so the camera will have to be rotated for the far facet to be seen. The far facet will remain black despite whatever color is applied as all light is still being absorbed by this facet.

    So I added a second light (another pointlight works, but I ended up using hemisphere to give more of a global illumination.