Search code examples
directxtkhdrimages

DirectXTex : generateMipmap with HDR RGBA32f texture clamp value to 1.0f


I'm trying to generate mip map chain from an .exr HDR image with the DirectXTex function DirectX::GenerateMipMaps().
But the result have all pixel clamped to 1.0f.

The source image have some to pixel superior to 30.0f, but after the mimap generation there are all clamp to 1.0. it's a knowing issue? i miss a specific flags?


Solution

  • Most of the DirectXTex functions, including GenerateMipMaps, were originally written to use the Windows Imaging Components (WIC) feature of the Windows operating system. This works for many cases, but there are lots of edge-cases for textures where this causes a problem. For example, WIC's resize function will always use 8-bit per channel formats and therefore will lose the HDR range as you have seen.

    Therefore, DirectXTex has custom filtering codepaths as well. Normally these are picked automatically based on the source format but you can provide the filter flag TEX_FILTER_FORCE_NON_WIC to ensure it uses the custom paths.

    See GitHub and the wiki.

    UPDATE: This was a bug in the logic for picking the WIC vs. non-WIC paths. When using FANT/BOX or POINT filtering -AND- > 8pbc formats, it shouldn't have used the WIC bitmap scalar which always uses 8bpc formats. Fixed in this commit.

    This is fixed in the May 2022 release.