首页 > 解决方案 > IWICDdsDecoder 无法加载立方体贴图

问题描述

我使用NVidia 的 Texture Exporter Tool创建了一个 Texture Cube,但我无法使用IWICDdsDecoder.

它失败了0x88982f61 : The image header is unrecognized.

另一方面,Dimension = WICDdsTexture2D使用 NVTET 创建的普通 2D 纹理 ( ) 可以正确加载并且运行良好。

是否IWICDdsLoader支持 Cube Maps,如果不支持,为什么要WICDdsDimension.WICDdsTextureCube指定?

WICDdsTexture2D适用于NVTET 编写的普通纹理的部分加载程序代码。

HRESULT lResult;

WICStream lStream;
lResult = gFactory->CreateStream(&lStream);
if (FAILED(lResult)) return lResult;

lResult = lStream->InitializeFromFilename(aPath, GENERIC_READ);
if (FAILED(lResult)) return lResult;

WICBitmapDecoder lBitmapDecoder;
lResult = gFactory->CreateDecoder(GUID_ContainerFormatDds, nullptr, &lBitmapDecoder);
if (FAILED(lResult)) return lResult;

lResult = lBitmapDecoder->Initialize(lStream, WICDecodeMetadataCacheOnDemand);
if (FAILED(lResult)) return lResult; // <-- it fails here!
// 0x88982f61 : The image header is unrecognized.

WICDdsDecoder lDecoder(lBitmapDecoder);
if (!lDecoder) return E_NOINTERFACE;

WICDdsParameters lParameters{};
lResult = lDecoder->GetParameters(&lParameters);
if (FAILED(lResult)) return lResult;
if (lParameters.Dimension != WICDdsTextureCube) return E_FAIL;

// etc.

标签: texturesdirect3d11wicdds-format

解决方案


Windows 8.1 中引入的内置 WIC DDS 编解码器旨在支持 WebGL。它仅支持 DXT1-5 (BC1-3) 格式的纹理。这记录在Microsoft Docs上。

为了有效加载 DDS 文件(所有 DXGI 格式和复杂的表面构造),请DDSTextureLoader查看DX11DX12。该模块可集成到DirectX 工具包中,也可作为DirectXTex项目中的独立版本使用。

如果您需要对旧版 Direct3D 9 时代格式 DDS 文件的支持、格式转换等,请参阅DirectXTex DDS 编解码器。

有关现代 DDS 纹理处理的更多背景信息,请参阅此博客文章

DDSTextureLoader如果需要,DirectXTex项目中还有可用的 Direct3D 9 版本。有关详细信息,请参阅此博客文章


推荐阅读