RoughnessTexture

Hi.

I see that in the inspector you have option to add roughnessTexture

image

But I don’t see this map input in actual code. Can you explain me how that works.
I need to enable this in my app. I know there are options to get roughness from metalicTexture channels, but is it possible to simply add roughnessTexture on it’s own, like the option in inspector seem to suggest.

Thanks

In fact it’s a single “metallic/roughness” texture, there’s no separate channels: those two buttons update the same texture.

You can see this by uploading a texture for “Metallic”: you will see that this texture is used for “Roughness” too. If you now delete the “Roughness” texture, you will see it also deletes the “Metallic” texture (as it is the same).

1 Like

So. Is that roughnessTexture option using those flags to read roughness from metallicTexture channel?

No, those two buttons do exactly the same thing, they update the “metallic/roughness” texture of the material.

The difference is in the debug button:
image

When you click on the icon on the left of the delete icon, it shows a debug view of the material: for metallic, you see the metallic component and for roughness you see the roughness.

2 Likes

Okay. Got it. Thank you for clarification once again. I appreciate it.

Extension of the question.

Would it be possible to create custom shader with the NodeMaterialEditor, which would take single roughnessTexture (an image) as input and then merge it with the metallicTexture in the alpha (or other) channel.

That way user could upload separate roughnessTexture and it would be applied to actual material in the scene.

And If possible how hard would it be to do something like that?

No it’s not possible to do it in the NME neither because the Reflectivity block expects a single texture, with metallic and roughness baked in (as well as an AO channel if you configure it that way).

I think you will need to do the merge yourself after the user has uploaded the roughness texture: update the green component of your current metallic/roughness texture with the uploaded data.

Having a single texture for multiple data has been done to save on the number of texture units used by the PBR material shader, that already uses quite a lot.

[EDIT]
Hum, I’m mistaken here, you can do it in the nme: simply create a merged color as input to the Reflectivity block:


Note that by default (in the default config of the Reflectivity block) the metallic component is in the blue channel, not the red one (but you can change to use the red channel by clicking on the Reflectivity block and changing a switch).
[/EDIT]

2 Likes