diff --git a/DDSTextureLoader/DDSTextureLoader11.cpp b/DDSTextureLoader/DDSTextureLoader11.cpp index d182494..b4f3864 100644 --- a/DDSTextureLoader/DDSTextureLoader11.cpp +++ b/DDSTextureLoader/DDSTextureLoader11.cpp @@ -701,6 +701,11 @@ namespace return DXGI_FORMAT_B4G4R4A4_UNORM; } + if (ISBITMASK(0x00ff, 0, 0, 0xff00)) + { + return DXGI_FORMAT_R8G8_UNORM; // NVTT versions 1.x wrote this as RGB instead of LUMINANCE + } + // No DXGI format maps to ISBITMASK(0x0f00,0x00f0,0x000f,0) aka D3DFMT_X4R4G4B4 // No 3:3:2, 3:3:2:8, or paletted DXGI formats aka D3DFMT_A8R3G3B2, D3DFMT_R3G3B2, D3DFMT_P8, D3DFMT_A8P8, etc. diff --git a/DDSTextureLoader/DDSTextureLoader12.cpp b/DDSTextureLoader/DDSTextureLoader12.cpp index 58edc63..4489eb6 100644 --- a/DDSTextureLoader/DDSTextureLoader12.cpp +++ b/DDSTextureLoader/DDSTextureLoader12.cpp @@ -781,6 +781,11 @@ namespace return DXGI_FORMAT_B4G4R4A4_UNORM; } + if (ISBITMASK(0x00ff, 0, 0, 0xff00)) + { + return DXGI_FORMAT_R8G8_UNORM; // NVTT versions 1.x wrote this as RGB instead of LUMINANCE + } + // No DXGI format maps to ISBITMASK(0x0f00,0x00f0,0x000f,0) aka D3DFMT_X4R4G4B4 // No 3:3:2, 3:3:2:8, or paletted DXGI formats aka D3DFMT_A8R3G3B2, D3DFMT_R3G3B2, D3DFMT_P8, D3DFMT_A8P8, etc. diff --git a/DDSTextureLoader/DDSTextureLoader9.cpp b/DDSTextureLoader/DDSTextureLoader9.cpp index 19aa12d..2c1e0da 100644 --- a/DDSTextureLoader/DDSTextureLoader9.cpp +++ b/DDSTextureLoader/DDSTextureLoader9.cpp @@ -585,6 +585,10 @@ namespace { return D3DFMT_A8R3G3B2; } + if (ISBITMASK(0x00ff, 0, 0, 0xff00)) + { + return D3DFMT_A8L8; // NVTT versions 1.x wrote this as RGB instead of LUMINANCE + } break; case 8: @@ -609,6 +613,10 @@ namespace { return D3DFMT_L8; } + if (ISBITMASK(0x00ff, 0, 0, 0xff00)) + { + return D3DFMT_A8L8; // Some DDS writers assume the bitcount should be 8 instead of 16 + } } if (16 == ddpf.RGBBitCount) diff --git a/DirectXTex/DDS.h b/DirectXTex/DDS.h index 8dc4f8e..4d715cc 100644 --- a/DirectXTex/DDS.h +++ b/DirectXTex/DDS.h @@ -160,6 +160,9 @@ DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_A8L8 = DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_A8L8_ALT = { sizeof(DDS_PIXELFORMAT), DDS_LUMINANCEA, 0, 8, 0x00ff, 0, 0, 0xff00 }; +DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_A8L8_NVTT1 = + { sizeof(DDS_PIXELFORMAT), DDS_RGBA, 0, 16, 0x00ff, 0, 0, 0xff00 }; + DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_A8 = { sizeof(DDS_PIXELFORMAT), DDS_ALPHA, 0, 8, 0, 0, 0, 0xff }; diff --git a/DirectXTex/DirectXTexDDS.cpp b/DirectXTex/DirectXTexDDS.cpp index fda9333..9779284 100644 --- a/DirectXTex/DirectXTexDDS.cpp +++ b/DirectXTex/DirectXTexDDS.cpp @@ -104,6 +104,7 @@ namespace { DXGI_FORMAT_R16_UNORM, CONV_FLAGS_NONE, DDSPF_L16 }, // D3DFMT_L16 { DXGI_FORMAT_R8G8_UNORM, CONV_FLAGS_NONE, DDSPF_A8L8 }, // D3DFMT_A8L8 { DXGI_FORMAT_R8G8_UNORM, CONV_FLAGS_NONE, DDSPF_A8L8_ALT }, // D3DFMT_A8L8 (alternative bitcount) + { DXGI_FORMAT_R8G8_UNORM, CONV_FLAGS_NONE, DDSPF_A8L8_NVTT1 }, // D3DFMT_A8L8 (NVTT v1 wrote it with RGB instead of LUMINANCE) { DXGI_FORMAT_A8_UNORM, CONV_FLAGS_NONE, DDSPF_A8 }, // D3DFMT_A8