Is there any good solution for PBR materials how to use metalness and roughness maps separately (both are separate)?
Example - https://playground.babylonjs.com/#2FDQT5#14
More info - Babylon.js docs
In this PG, metallic and roughness use the same texture. My goal is to separate them. That is, if there are two textures, for example, the following situation
Although it doesn’t have a metalness map, if I want to be compatible with this situation, is there any good solution?
It will be easier to answer if you would provide either textures or PG.
You may try something like
// Set separate metalness map (grayscale)
pbr.metallicTexture = new BABYLON.Texture("textures/metalness.png", scene);
// Set separate roughness map (grayscale)
pbr.roughnessTexture = new BABYLON.Texture("textures/roughness.png", scene);
// Configure material properties / tweak as you need
pbr.useRoughnessFromMetallicTextureAlpha = false;
pbr.useMetallnessFromMetallicTextureBlue = false;
pbr.useRoughnessFromMetallicTextureGreen = false;
I checked the documentation and vscode but it didn’t tell me that PBRMaterial has the property of roughnessTexture. Am I missing something?
here is texture assets:
Marble_Carrara_003_SD.zip (575.1 KB)
Was writing from memory, you are right, there is no roughnessTexture but baseDiffuseRoughnessTexture which is a bit different.
There is no separate metalllic and roughness textures in this pack. I believe one may use it as metallicTexture.
In the texture resource file I provided, ROUGH stands for the roughness map. It does not have a metal map. I have another set of textures that can be used for experimentation. It has both metalness and roughness maps. Is there any good way to deal with this?
door.zip (969.4 KB)
@KallkaGo, the diffuseRoughnessTexture is part of the OpenPBR support we are adding and is an input to a different approach to PBR. It has some similarities to PBR Metallic Roughness, but does more layering where there are roughness textures for both diffuse and specular contributions. As such, your roughness texture was not authored for OpenPBR because there are no paths I can find to author directly to OpenPBR as of yet. The adoption of OpenPBR is a collaboration between Adobe and Autodesk, so support to author for OpenPBR through templates should be coming and authoring for it now would just mean manual assembly of the textures knowing what the shader expects so it is authored correctly.
There are a couple of options for you with what you have. The first is to just export of reformat your texture as a MetallicRoughness texture by placing your roughness in the alpha channel and black in the RGB channels as this is a dielectric material. You can either set up your texturing package to do this channel pack for you on export, or you can manually copy the pixels from the green channel of your texture (higher bit depth than red or blue) and paste it into the alpha channel and then fill the RGB channels with black. This can be done in any image editor like Photoshop or GIMP. The Substance packages also let you manually set up export templates to channel pack however you like if you are creating your textures there. Other texture packages like Quixel should also have the ability to set up whatever channel pack you like.
The second option is to create a node material and use the PBRRoughnessMetallic node to set up your PBR material. You can then load any texture to the node mateiral and pass the green channel to the Roughness input on the node (again, higher bit depth). Then you wire the rest of the node with base color, normal, ao and other textures. You can pass black to the metallic input and connect the reflection input to get the environment light and you will have a duplicate of the PBRMaterial without the need to change your texture. You can also add the other PBR next components like clear color or transmission in the node material if you need them to get true parity.
One other thing I noticed about your material set is that the normal texture is saved as a jpg file. The compression for jpb is lossy, and you get cross-talk between the channels when compressing. This means that the values in R, G, and B contribute to the compression and influence each other. This means that the compression will slightly change the vector represented in the texture so your normal texture will no longer be accurate to what was authored. This could be slight and not amount to a huge visual difference, but if you want to be accurate the png format should be used. The compression used in png is not lossy and does not compress across channels so your vectors should not be changed by the compression. The png format will certainly be larger than jpg, but more accurate.
You can also go to KTX compression to make your textures smaller. You would want to use ETC1S for your color textures like your base color texture and UASTC for non-color data textures like normal textures. This is for the same reasons that ETC1S compresses across channels and UASTC does not. However KTX compressed textures will be smaller than jpg and png. That’s if you are worried about texture size, which may not be a concern with tiling textures like you are using.
In any case, if you want to keep your original roughness texture, I would just use node material, otherwise a quick siwzzle of your channels should get you the correct format for PBRMaterial.
Its called microSurfaceTexture
and not roughnessTexture
for the PBRMaterial
.