Change the albedo map in the PBR material on runtime


I am working on a configurator, and I need to apply new material when selected from the UI panel.

I tried a lot changing the texture in the PBR material but failed every time and my mesh turned out to look like chrome plated.

Please suggest which parameter I have to update under PBRMaterial to change the texture.

let netMat = new PBRMaterial('netmat', scene);
 // netMat.albedoTexture = new Texture(materialURL, scene);
netMat.diffuseTexture = new Texture(materialURL, scene);
_mesh.material = netMat;

Nipun David

The property is albedoTexture for the PBRMaterial.

Try to set the metallic and roughness properties of your material.

For eg, netMat.metallic = 0 and netMat.roughness = 0.8;

I guess I still have to learn a lot! :smiley:
Thanks - it worked

You can have a look at these docs for some explanations on the PBR material:

1 Like

@Evgeni_Popov My UV seems to get flipped when I applied the texture, any thought on that?

The screenshot is attached.

There’s a parameter to the Texture construct (the 3rd or 4th I think) that you can set to true or false to invert / not invert the texture: try each value, one should work.

1 Like

Awesome!! it worked :crazy_face:

netMat.albedoTexture = new Texture("matURL", scene, true, false);