Jump to content

Separating metallic and roughness texture at PBRMaterial


Recommended Posts

Hello everyone.

First of all I would like to say thank you, the posts in this forum often helped me. You guys have a great community!

Now to my Problem. I need to create a PBRMaterial out of 4 different textures. There is a BumpTexture, an AlbedoTexture, a Metallic- AND a RoughnessTexture but I only found a way to create this by using a combination of MetallicRoughness.

Actually I am using the code below:

let pbr = new BABYLON.PBRMaterial("pbr", this._scene);
//Create bumpTexture and flip normal. (DirectX <-> OpenGL)
pbr.bumpTexture = new BABYLON.Texture("materials/" +filePath +"/02_Texturepack/" +materialName+"Normal.png", this._scene);
pbr.bumpTexture.level = -1;
//Create albedoTexture
pbr.albedoTexture = new BABYLON.Texture("materials/" +filePath +"/02_Texturepack/" +materialName+"BaseColor.png", this._scene);
//Create reflectionTexture
pbr.reflectionTexture = BABYLON.CubeTexture.CreateFromPrefilteredData("textures/environment.dds", this._scene);
//Create metallicRoughnessTexture
pbr.metallicTexture = new BABYLON.Texture("materials/" +filePath +"/02_Texturepack/" +materialName+"MetallicRoughness.png", this._scene);
//Set metallic and roughness to 1 to use it from the metallicRoughnessTexture
pbr.metallic = 1.0;
pbr.roughness = 1.0;
//set channel with metallic and roughness
pbr.useRoughnessFromMetallicTextureAlpha = false;
pbr.useRoughnessFromMetallicTextureGreen = true;
pbr.useMetallnessFromMetallicTextureBlue = true;

//set new material to mesh
this._activeMesh.material = pbr;

Is there any possibility to seperate the metallic and roughness informations in two different images?

At the moment I am editing the metallic texture with photoshop and put the information of roughness into the green channel and the metallic information into the blue channel which works pretty well.

unfortunaly thats not a solution, because customer have thousonds of texturepacks I need to show in Babylon without merging metallic and roughness.


Greetings, Chris.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...