From 90a34e9959a3ae402f8d9fe447f5664665f33b1e Mon Sep 17 00:00:00 2001 From: Chuck Walbourn Date: Wed, 18 Apr 2018 00:08:35 -0700 Subject: [PATCH] texconv updated to handle non-pow2 volume textures with mips --- Texconv/texconv.cpp | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/Texconv/texconv.cpp b/Texconv/texconv.cpp index a55a337..0109cbb 100644 --- a/Texconv/texconv.cpp +++ b/Texconv/texconv.cpp @@ -2469,24 +2469,19 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[]) } // --- Generate mips ----------------------------------------------------------- + DWORD dwFilter3D = dwFilter; if (!ispow2(info.width) || !ispow2(info.height) || !ispow2(info.depth)) { - if (info.dimension == TEX_DIMENSION_TEXTURE3D) - { - if (!tMips) - { - tMips = 1; - } - else - { - wprintf(L"\nERROR: Cannot generate mips for non-power-of-2 volume textures\n"); - return 1; - } - } - else if (!tMips || info.mipLevels != 1) + if (!tMips || info.mipLevels != 1) { nonpow2warn = true; } + + if (info.dimension == TEX_DIMENSION_TEXTURE3D) + { + // Must force triangle filter for non-power-of-2 volume textures to get correct results + dwFilter3D = TEX_FILTER_TRIANGLE; + } } if ((!tMips || info.mipLevels != tMips) && (info.mipLevels != 1)) @@ -2590,7 +2585,7 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[]) if (info.dimension == TEX_DIMENSION_TEXTURE3D) { - hr = GenerateMipMaps3D(image->GetImages(), image->GetImageCount(), image->GetMetadata(), dwFilter | dwFilterOpts, tMips, *timage); + hr = GenerateMipMaps3D(image->GetImages(), image->GetImageCount(), image->GetMetadata(), dwFilter3D | dwFilterOpts, tMips, *timage); } else {