mirror of
https://github.com/bkaradzic/bimg.git
synced 2026-02-18 04:53:07 +01:00
texturec: Fixed SDF generation.
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user