textures - 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.
解决方案
Windows 8.1 中引入的内置 WIC DDS 编解码器旨在支持 WebGL。它仅支持 DXT1-5 (BC1-3) 格式的纹理。这记录在Microsoft Docs上。
为了有效加载 DDS 文件(所有 DXGI 格式和复杂的表面构造),请DDSTextureLoader
查看DX11或DX12。该模块可集成到DirectX 工具包中,也可作为DirectXTex项目中的独立版本使用。
如果您需要对旧版 Direct3D 9 时代格式 DDS 文件的支持、格式转换等,请参阅DirectXTex DDS 编解码器。
有关现代 DDS 纹理处理的更多背景信息,请参阅此博客文章。
DDSTextureLoader
如果需要,DirectXTex项目中还有可用的 Direct3D 9 版本。有关详细信息,请参阅此博客文章。
推荐阅读
- java - 如何根据条件在两个附加程序之间进行选择并在 log4j.properties 中定义?
- reactjs - BrowserRouter keyLength 属性无法正常工作
- .net - 如何在 Flutter 中显示从 .NET Core API 加载的 jpeg 图像?
- c# - 如何在 asp.net 核心上使用自定义配置将 Hangfire 添加为服务
- google-bigquery - IS NOT NULL 未在 Big Query 中正确“过滤”
- oracle - java.sql.SQLException:无法在设置了自动提交的情况下提交
- javascript - 尝试从数组访问信息时,React JS 返回未定义
- android - 为什么图像在带有圆角的 ImageButton 中超出边框?
- java - 在 Opta Planner 中添加约束
- gnuradio - 这个 GNUradio 考试题的含义是什么?