diff --git a/include/bimg/encode.h b/include/bimg/encode.h index 7e1de03..326728d 100644 --- a/include/bimg/encode.h +++ b/include/bimg/encode.h @@ -87,7 +87,6 @@ namespace bimg , uint32_t _width , uint32_t _height , uint32_t _srcPitch - , float _edge , const void* _src ); diff --git a/src/image_encode.cpp b/src/image_encode.cpp index 5d4feeb..879c3d3 100644 --- a/src/image_encode.cpp +++ b/src/image_encode.cpp @@ -368,7 +368,7 @@ namespace bimg BX_FREE(_allocator, gy); } - void imageMakeDist(bx::AllocatorI* _allocator, void* _dst, uint32_t _width, uint32_t _height, uint32_t _srcPitch, float _edge, const void* _src) + void imageMakeDist(bx::AllocatorI* _allocator, void* _dst, uint32_t _width, uint32_t _height, uint32_t _srcPitch, const void* _src) { const uint32_t numPixels = _width*_height; @@ -399,12 +399,9 @@ namespace bimg uint8_t* dst = (uint8_t*)_dst; - double edgeOffset = _edge*0.5; - double invEdge = 1.0/_edge; - for (uint32_t ii = 0; ii < numPixels; ++ii) { - double dist = bx::clamp( ( (outside[ii] - inside[ii])+edgeOffset) * invEdge, 0.0, 1.0); + double dist = bx::clamp( (outside[ii] - inside[ii]) * 1.0/16.0 + 0.5, 0.0, 1.0); dst[ii] = 255-uint8_t(dist * 255.0); } diff --git a/tools/texturec/texturec.cpp b/tools/texturec/texturec.cpp index 99a8f80..f74671a 100644 --- a/tools/texturec/texturec.cpp +++ b/tools/texturec/texturec.cpp @@ -256,7 +256,8 @@ bimg::ImageContainer* convert(bx::AllocatorI* _allocator, const void* _inputData && (bimg::LightingModel::Count == _options.radiance) ; - if (needResize) + if (!_options.sdf + && needResize) { bimg::ImageContainer* src = bimg::imageConvert(_allocator, bimg::TextureFormat::RGBA32F, *input, false); @@ -630,7 +631,6 @@ bimg::ImageContainer* convert(bx::AllocatorI* _allocator, const void* _inputData , mip.m_width , mip.m_height , mip.m_width - , _options.edge , rgba ); } @@ -848,7 +848,7 @@ void help(const char* _error = NULL, bool _showHelp = true) " -n, --normalmap Input texture is normal map.\n" " --equirect Input texture is equirectangular projection of cubemap.\n" " --strip Input texture is horizontal strip of cubemap.\n" - " --sdf Compute SDF texture.\n" + " --sdf Compute SDF texture.\n" " --ref Alpha reference value.\n" " --iqa Image Quality Assessment\n" " --pma Premultiply alpha into RGB channel.\n" @@ -970,28 +970,17 @@ int main(int _argc, const char* _argv[]) Options options; - const char* edgeOpt = cmdLine.findOption("sdf"); - if (NULL != edgeOpt) + const char* alphaRef = cmdLine.findOption("ref"); + if (NULL != alphaRef) { - options.sdf = true; - if (!bx::fromString(&options.edge, edgeOpt) ) + options.alphaTest = true; + if (!bx::fromString(&options.edge, alphaRef)) { - options.edge = 255.0f; - } - } - else - { - const char* alphaRef = cmdLine.findOption("ref"); - if (NULL != alphaRef) - { - options.alphaTest = true; - if (!bx::fromString(&options.edge, alphaRef)) - { - options.edge = 0.5f; - } + options.edge = 0.5f; } } + options.sdf = cmdLine.hasArg("sdf"); options.mips = cmdLine.hasArg('m', "mips"); options.normalMap = cmdLine.hasArg('n', "normalmap"); options.equirect = cmdLine.hasArg("equirect");