Texconv question about PNG with sRGB data and BC5_UNORM_SRGB

Jul 9, 2013 at 11:27 AM
I have been using the following command to convert a PNG file to DDS:

texconv -srgbi -srgbo -dx10 -f BC3_UNORM_SRGB foo.png

The PNG is containing sRGB encoded data, so I assume there's no conversion required. Turns out the DDS is becoming brighter, which means the PNG is read as linear input.

After digging into the code, I found that for this kind of output format, the program is only considering input image type (from the image's metadata) and output image format. Since there's no way to tell the PNG file the color space, it is always read as linear colors.

I can easily avoid this by using a TIFF image as input, but my question here is: isn't the -srgbi and -srgbo flags supposed to override the image format? In this case the flags are ignored, which seems strange to me.
Coordinator
Jul 9, 2013 at 6:59 PM
Edited Jul 9, 2013 at 6:59 PM
Which release are you using?

I added support to June 2013 release which will check for the sRGB colorspace in the PNG file. The limitation is that the returned DXGI_FORMAT must have an SRGB equivalent. That means if it loaded as a DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_B8G8R8A8_UNORM, or a DXGI_FORMAT_B8G8R8X8_UNORM and the PNG contains the 'sRGB' tag, the functions will return them as DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, DXGI_FORMAT_B8G8R8A8_UNORM_SRGB, or DXGI_FORMAT_B8G8R8X8_UNORM_SRGB.

The -srgbi switch basically forces the loaded format to an _SRGB equivalent IF AVAILABLE (see the library function MakeSRGB). -srgbo does the same thing for output. Since you are specifying -f BC3_UNORM_SRGB as the output format here, the -srgbo is ignored.

Prior to the June 2013 release, the library did not properly handling sRGB conversions so that is also a possible source of problems. If you have both -srgbi and -srgbo set, it doesn't perform any color space conversion so if the source image is in linear RGB, then rendering as BC3_UNORM_SRGB is going to result in a different color.

I suspect you need to use a newer release and then call it without the -srgb override switches
texconv -dx10 -f BC3_UNORM_SRGB foo.png 
If the foo.png is loaded as an _SRGB format, no conversion takes place and it will store it in the same color space. If it is not in the an _SRGB format -or- there is no equivalent DXGI_FORMAT that explicitly encodes _SRGB (like say a 16bpp PNG that has the 'sRGB' color tag) then you will get a conversion.

Look at the output of the texconv tool to see which format it is loading the foo.png file as...