MaterialX texture colorspace

Importing a .mtlx document using the Interchange materialX Pipeline, a Standard Surface comes in with its base color set to Linear Color in the material, and sRGB=false in the texture. This is despite the fact that the image in the .mtlx file is set to colorspace=“sRGB”.

What would be the best way to modify this? The ideal would be to have the color space set on the image in the MaterialX file to determine how to translate the image. colorspace=“sRGB” would result in sRGB=true in the texture, and Color as the Param2D sampler type. colorspace=“raw” would result in sRGB=false and sampler type Linear Color. However, I suspect that the UE translator may not be looking at the color space of the .mtlx file.

As a workaround, I’d like the have it default to reading in textures as sRGB, with the exception of detected normal maps. Could someone point me to where/how I can change that? Would this be done by creating a custom MX_standardSurface material instance, or would it involve changing the C++ of the Interchange MaterialX Translator and/or the Default MaterialX Pipeline?

I think I found a workaround, sharing it here for anyone else with the same question. I created a copy of the material function MX_StandardSurface that I then used that new material function in Project Settings > Interchange MaterialX.

For the custom MX_StandardSurface I inserted an inverse gamma into the base color input (and for any other inputs you want to use sRGB) like this:

I had to build the 0.455 gamma as shown because, AFAIK, there is no gamma, and the sRGB to Linear and linear to sRGB were giving odd results.

UE support sRGB colorspace.
Which version Unreal are you using?

Can you confirm that your materialX files uses colorspace="srgb_texture" and not colorspace="sRGB"?

Do you have a sample mtlx file and textures to share with us?

Yes, this works with srgb_texture. Thanks!

When creating materials via LookdevX in Maya, an sRGB texture’s color space is written as “sRGB” in the .mtlx file, instead of “srgb_texture.” So, I have to manually edit each .mtlx file in Notepad. This is quite tedious. Is there any solution for this? I’m using UE 5.3.2.

You can edit your OpenColorIO config to use srgb_texture instead of sRGB. Generally you want to have a config that is set up to work with all your DCCs.

I’d recommend using the CG config here as a starting point: https://github.com/AcademySoftwareFoundation/OpenColorIO-Config-ACES/

This already has srgb_texture as an alias, so you would just need to use that alias in the roles.

If you don’t want to modify the config, I have one here that is ready to go:
https://sharktacos.github.io/OpenColorIO-configs/

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.