DDS 8.8 Alpha Luminance - incorrect conversion
Trava715 opened this issue · 3 comments
When trying to convert textures saved as 8.8AL to other formats using texconv the channels are converted incorrectly.
L8A8 to BC7_UNORM (opened in Nvidia Texture Tools, channels look the same as when converting to BC3)
Textures saved as 8 Luminance and 8 Alpha convert correctly.
Attaching test 88AL texture below
88AL_sample.zip
TL;DR: Use the -xlum
texconv switch.
The DirectXTex library 'default conversions' for legacy DDS formats matches those from DDSTextureLoader
. These mappings are based on 'no-conversion' behavior so that the data is directly loaded into memory.
In this case, this means D3DFMT_A8L8
maps to the only DXGI format that exactly matches its bit and channel count DXGI_FORMAT_R8G8_UNORM
. Therefore L8
channel is going to map to the RED channel your target format, and the A8
is going to map to the GREEN channel in the target format. That is why you end up with a "Yellow" shape with an all opaque-alpha channel.
Semantically, these are quite different of course, so there are a number of other ways to map them. The -xlum
switch in texconv (which enables the DDS loader flag DDS_FLAGS_EXPAND_LUMINANCE
) will instead map the L8
channel to RED, GREEN, and BLUE and the A8
channel will end up in the alpha channel of the target format.
If you were trying to render classic
D3DFMT_A8L8
content directly loaded into memory, you'd have the shader do the conversion fromDXGI_FORMAT_R8G8_UNORM
.
I see, very sorry, not sure how I missed that in the documentation. Thanks for the detailed explanation.
Not a problem!
I add tables to these wiki pages to help clarify this behavior in the docs.
https://github.com/microsoft/DirectXTK/wiki/DDSTextureLoader#remarks
https://github.com/microsoft/DirectXTex/wiki/DDS-I-O-Functions#remarks