From e668795fe7bcab0aa379f6302bf51c230d497cdb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= Date: Fri, 6 Jul 2018 18:45:33 -0700 Subject: [PATCH 1/2] texturec: Separated equirect and horizontal strip. --- tools/texturec/texturec.cpp | 37 +++++++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/tools/texturec/texturec.cpp b/tools/texturec/texturec.cpp index 9780381..6d5b4b6 100644 --- a/tools/texturec/texturec.cpp +++ b/tools/texturec/texturec.cpp @@ -44,6 +44,8 @@ struct Options "\t pma: %s\n" "\t sdf: %s\n" "\t radiance: %s\n" + "\t equirect: %s\n" + "\t strip: %s\n" , maxSize , edge , bimg::getName(format) @@ -53,6 +55,8 @@ struct Options , pma ? "true" : "false" , sdf ? "true" : "false" , radiance ? "true" : "false" + , equirect ? "true" : "false" + , strip ? "true" : "false" ); } @@ -64,6 +68,7 @@ struct Options bool mips = false; bool normalMap = false; bool equirect = false; + bool strip = false; bool iqa = false; bool pma = false; bool sdf = false; @@ -169,8 +174,18 @@ bimg::ImageContainer* convert(bx::AllocatorI* _allocator, const void* _inputData outputHeight = _options.maxSize*2; } } - else if (outputDepth == 1 - && outputWidth/6 == outputHeight) + else + { + bimg::imageFree(input); + + BX_ERROR_SET(_err, TEXTRUREC_ERROR, "Input image format is not equirectangular projection."); + return NULL; + } + } + else if (_options.strip) + { + if (outputDepth == 1 + && outputWidth/6 == outputHeight) { if (outputWidth/6 > _options.maxSize) { @@ -182,7 +197,7 @@ bimg::ImageContainer* convert(bx::AllocatorI* _allocator, const void* _inputData { bimg::imageFree(input); - BX_ERROR_SET(_err, TEXTRUREC_ERROR, "Input image format is not equirectangular projection."); + BX_ERROR_SET(_err, TEXTRUREC_ERROR, "Input image format is not horizontal strip."); return NULL; } } @@ -222,7 +237,7 @@ bimg::ImageContainer* convert(bx::AllocatorI* _allocator, const void* _inputData && !_options.sdf && !_options.alphaTest && !_options.normalMap - && !_options.equirect + && !(_options.equirect || _options.strip) && !_options.iqa && !_options.pma && (bimg::LightingModel::Count == _options.radiance) @@ -280,7 +295,8 @@ bimg::ImageContainer* convert(bx::AllocatorI* _allocator, const void* _inputData return output; } - if (_options.equirect) + if (_options.equirect + || _options.strip) { bimg::ImageContainer* src = bimg::imageConvert(_allocator, bimg::TextureFormat::RGBA32F, *input); bimg::imageFree(input); @@ -816,7 +832,8 @@ void help(const char* _error = NULL, bool _showHelp = true) " -q Encoding quality (default, fastest, highest).\n" " -m, --mips Generate mip-maps.\n" " -n, --normalmap Input texture is normal map.\n" - " --equirect Input texture equirectangular projection of cubemap.\n" + " --equirect Input texture is equirectangular projection of cubemap.\n" + " --strip Input texture is horizontal strip of cubemap.\n" " --sdf Compute SDF texture.\n" " --ref Alpha reference value.\n" " --iqa Image Quality Assessment\n" @@ -945,9 +962,17 @@ int main(int _argc, const char* _argv[]) options.mips = cmdLine.hasArg('m', "mips"); options.normalMap = cmdLine.hasArg('n', "normalmap"); options.equirect = cmdLine.hasArg("equirect"); + options.strip = cmdLine.hasArg("strip"); options.iqa = cmdLine.hasArg("iqa"); options.pma = cmdLine.hasArg("pma"); + if (options.equirect + && options.strip) + { + help("Image can't be equirect and strip at the same time."); + return bx::kExitFailure; + } + const char* maxSize = cmdLine.findOption("max"); if (NULL != maxSize) { From 73e4e1deaaed4ecc849fffbb0f7a2a88e4030023 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= Date: Fri, 6 Jul 2018 18:46:00 -0700 Subject: [PATCH 2/2] BC6H: Fixed issues with negative values in texture. --- 3rdparty/nvtt/nvtt.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/3rdparty/nvtt/nvtt.cpp b/3rdparty/nvtt/nvtt.cpp index aa1c2d2..0cc0df4 100644 --- a/3rdparty/nvtt/nvtt.cpp +++ b/3rdparty/nvtt/nvtt.cpp @@ -50,9 +50,9 @@ namespace nvtt for (uint32_t blockX = 0; blockX < ZOH::Tile::TILE_W; ++blockX) { nv::Vector4 color = srcRgba[blockY*srcRgbaStride + blockX]; - zohTile.data[blockY][blockX].x = float(int16_t(bx::halfFromFloat(color.x) ) ); - zohTile.data[blockY][blockX].y = float(int16_t(bx::halfFromFloat(color.y) ) ); - zohTile.data[blockY][blockX].z = float(int16_t(bx::halfFromFloat(color.z) ) ); + zohTile.data[blockY][blockX].x = float(int16_t(bx::halfFromFloat(bx::max(color.x, 0.0f) ) ) ); + zohTile.data[blockY][blockX].y = float(int16_t(bx::halfFromFloat(bx::max(color.y, 0.0f) ) ) ); + zohTile.data[blockY][blockX].z = float(int16_t(bx::halfFromFloat(bx::max(color.z, 0.0f) ) ) ); } }