4.1.0 beta Bug Meshes not visible until turning ambient occlusion off

My meshes are visble properly in the 4.1.0 alpha 20 build of babylonjs with the ambient occlusion and no issues. After updating to the beta version of the babylonjs. My meshes are no longer visible . But after turning the AO off. They are suddenly visible. Dunno why this happening Hope someone can shed a light on it. The console shows no errors.

Hello!
we will need a repro in the playground to help

Ive not have not been able to repro the issue. So essentially I am swapping the materials of the meshes before the scene is visible to the user. If I remove my swapping logic to happen and swap the materials once the scene is visible it works out fine. Second thing is that when it swaps the materials before the scene is visible and I turn off the AO the materials are visible on the meshes with the proper textures on them.

I have isolated the issue in the intial swap down to the line where I am assigning the ambientTexture of the oldMaterial to the newMaterial. Why would this line give me an issue in the beta version while not giving me any issues in any of the earlier versions

  rootMesh.getChildMeshes().forEach((subMesh) => {
  if (subMesh.metadata.swappable) {
    const properMatId = materialOptions[subMesh.metadata.matIndex];
    const properMat = product.materialRef[properMatId];
    // This is the line of issue V
    properMat.ambientTexture = subMesh.material.ambientTexture;
    subMesh.material = properMat;
  }

Could you try to disable parallelShaderCompile in your code ?

engine.getCaps().parallelShaderCompile = null;

Just to see if it could come from this ? and unfortunately we ll probably need some kind of repro for this one :frowning:

parallel shader compilation seems to have errors without even disabling it. It seems to give errors in the alpha build too. Is there any way to check what errors it is giving out.

Please try to recreate the issue in the PG :slight_smile:

I have been unsuccessfull in trying to repro the bug. But I tested something. Instead of passing a reference to the original texture I cloned it. That seems to resolve the issue for now. But is that really how this is supposed to work.

rootMesh.getChildMeshes().forEach((subMesh) => {
  if (subMesh.metadata.swappable) {
    const properMatId = materialOptions[subMesh.metadata.matIndex];
    const properMat = product.materialRef[properMatId];
    // Changing this texture setting line below from passing a reference to the 
    // texture to cloning the original texture ambient texture seems to 
    // resolve the issue for now but it seems to be a really weird one.
    properMat.ambientTexture = subMesh.material.ambientTexture.clone();
    subMesh.material = properMat;
  }

No it should not but it is not a big deal as textures automatically share resources internally