Problem with MultiMaterial

Hello @all, I am actually experiencing troubles with Babylon.js multimaterial. I try to mix a Material out of one and another texture. If I do so, the engine throws an error Message Back: “TypeError: undefined is not an object (evaluating ‘i.multiMaterials’)”. The error is caused by the Line of Code I try to implement the Mutlimaterial.

//Begin WhiteFacedGreenMat
basicMat = new BABYLON.StandardMaterial('mat', scene);
var texture = new BABYLON.Texture(
  domainExtension + '/images/mytextures/textureBlank.png',
  scene,
);
texture.scale = 1;
basicMat.bumpTexture = texture;
basicMat.diffusecolor = new BABYLON.Color3(0.5, 0.5, 0.5);
  
whitefaceBasisMat  = new BABYLON.StandardMaterial('facewhiteBasisMat', scene);
var texture = new BABYLON.Texture(
  domainExtension + '/images/mytextures/textureFace.png',
  scene,
);

whitefaceBasisMat.bumpTexture = texture;

var multimat = new BABYLON.MultiMaterial("multi", scene);
multimat.subMaterials.push(basicMat);
multimat.subMaterials.push(whitefaceBasisMat);

whiteFacedmat  = new BABYLON.StandardMaterial('whiteFacedmat', scene);
whiteFacedmat.material = multimat;

Hope someone could help me out with this ^^

Could you provide a repro in the PG, as it will be easier to help?

unfortunatley not, it’s part of a local project that I can not share via repo :frowning:

This cannot work:

whiteFacedmat  = new BABYLON.StandardMaterial('whiteFacedmat', scene);
whiteFacedmat.material = multimat;

Materials do not have a material property

To use your multimaterial you have to directly use it on a mesh:
https://playground.babylonjs.com/#2Q4S2S#417

1 Like