vpenades / SharpGLTF

glTF reader and writer for .NET Standard
MIT License
470 stars 75 forks source link

Is there a way to specify Metallness and Roughness map? #7

Closed Imaver closed 5 years ago

Imaver commented 5 years ago

Hi vpenades, Could you please let me know if there is a way to specify metalness and roughness texture?

I saw that metallic and roughness factor can be specified using code: .WithChannelParam(KnownChannels.MetallicRoughness, metallicFactor, roughnessFactor, 0, 0);

So it looks like I need to programatically combine a special map that has metlalicFactor in R channel and Roughness factor in G channel and then somehow specify it. Is my assumption correct?

You help is very much appreciated

vpenades commented 5 years ago

Yes, if I recall, there's a WithChannelTexture to specify the texture to use.

The texture argument needs to be a byte array representing a PNG or JPG image file.

Imaver commented 5 years ago

Thank you, vpenades, I figured it out after several iterations.

In case somebody has the same question, the map needs to be created with these channels:

Roughness needs to be in G channel Metallness needs to be in B channel Additionally, these maps will not work unless Roughness and Metalness are set to 1.0f value using WithChannelParam method