MtlX Image Color 4 Separation Bug? Use roughness in alpha ch

   1685   5   1
User Avatar
Member
100 posts
Joined: Oct. 2021
Offline
Hey there,

I am building a scene from assets I created for a vr experience last year and I would like to use those textures in Karma XPU. In Unity it is common practice to combine the albedo and roughness for non metal materials. Roughness being stored in the alpha channel.

It seems that the rgb channels are influenced by the alpha channel though. Even after separation. This can be proven by using two different textures wich give the correct result.

If this is no bug, what am I doing wrong?
Edited by Kareeem - Sept. 6, 2024 11:58:04

Attachments:
mtlx_color4_separation_bug.jpg (604.4 KB)

www.rehimi.de
User Avatar
Member
100 posts
Joined: Oct. 2021
Offline
Further testing showed that even if I set the MtlX Image node back to its default Signature "Color" the final result is incorrect if the albedo texture has an alpha channel. It seems that the alpha channel gets multiplied onto the rgb information.
Edited by Kareeem - Sept. 6, 2024 12:13:11
www.rehimi.de
User Avatar
Member
8177 posts
Joined: Sept. 2011
Offline
Kareeem
Further testing showed that even if I set the MtlX Image node back to its default Signature "Color" the final result is incorrect if the albedo texture has an alpha channel. It seems that the alpha channel gets multiplied onto the rgb information.

are you using a png by chance? PNGs are problematic as their spec says to premultiply the color by the alpha channel, but all the realtime applications that use PNG ignore the spec. Houdini's OIIO library always follows the spec for pngs, however there is an environment variable that can control how they are read by the OIIO library. I would recommend avoiding PNGs entirely and using EXR or RAT files for all textures as this avoids the ambiguity of the format.
User Avatar
Member
100 posts
Joined: Oct. 2021
Offline
jsmack
are you using a png by chance? PNGs are problematic as their spec says to premultiply the color by the alpha channel, but all the realtime applications that use PNG ignore the spec. Houdini's OIIO library always follows the spec for pngs, however there is an environment variable that can control how they are read by the OIIO library. I would recommend avoiding PNGs entirely and using EXR or RAT files for all textures as this avoids the ambiguity of the format.

Thanks for taking the time!

I am indeed using png files and am also not familiar with OIIO library.

Houdini automatically creates .rat files when I link a png file. I´ll have to check for a batch conversion process from png to exr then...

I wouldnt know how to change that environment variable but it also doesnt feel right to make a global change for this issue. Although it is quite annoying since many textures I have from other projects are in png.
Edited by Kareeem - Sept. 6, 2024 12:38:28
www.rehimi.de
User Avatar
Member
8177 posts
Joined: Sept. 2011
Offline
Kareeem
jsmack
are you using a png by chance? PNGs are problematic as their spec says to premultiply the color by the alpha channel, but all the realtime applications that use PNG ignore the spec. Houdini's OIIO library always follows the spec for pngs, however there is an environment variable that can control how they are read by the OIIO library. I would recommend avoiding PNGs entirely and using EXR or RAT files for all textures as this avoids the ambiguity of the format.

Thanks for taking the time!

I am indeed using png files and am also not familiar with OIIO library.

Houdini automatically creates .rat files when I link a png file. I´ll have to check for a batch conversion process from png to exr then...

I wouldnt know how to change that environment variable but it also doesnt feel right to make a global change for this issue. Although it is quite annoying since many textures I have from other projects are in png.

be careful what you use for batch conversion, as most tools will treat png as 'unpremultiplied' and subsequently apply the alpha to the color data.

I use this in my houdini.env to allow for use of pngs as textures without corruption:

OPENIMAGEIO_IMAGECACHE_OPTIONS="unassociatedalpha=1"

a file COP can be used to load png file and force the color to load unpremultiplied (when using the old COP2, I haven't seen if the option still exists for Copernicus)
User Avatar
Member
100 posts
Joined: Oct. 2021
Offline
jsmack
be careful what you use for batch conversion, as most tools will treat png as 'unpremultiplied' and subsequently apply the alpha to the color data.

I use this in my houdini.env to allow for use of pngs as textures without corruption:

OPENIMAGEIO_IMAGECACHE_OPTIONS="unassociatedalpha=1"

a file COP can be used to load png file and force the color to load unpremultiplied (when using the old COP2, I haven't seen if the option still exists for Copernicus)

Yeah, I couldnt find any good conversion method quickly, so i grinded through the textures manually.

So you're using environment variable as well. Thats comforting to know.

I will test this and report back.

Thanks again!
www.rehimi.de
  • Quick Links