|
|
@@ -404,15 +404,15 @@ bimg::ImageContainer* convert(bx::AllocatorI* _allocator, const void* _inputData
|
|
|
, bimg::TextureFormat::RGBA32F
|
|
|
);
|
|
|
temp = BX_ALLOC(_allocator, size);
|
|
|
- float* rgba = (float*)temp;
|
|
|
+ float* rgba32f = (float*)temp;
|
|
|
float* rgbaDst = (float*)BX_ALLOC(_allocator, size);
|
|
|
|
|
|
bimg::imageDecodeToRgba32f(_allocator
|
|
|
- , rgba
|
|
|
+ , rgba32f
|
|
|
, mip.m_data
|
|
|
- , dstMip.m_width
|
|
|
- , dstMip.m_height
|
|
|
- , dstMip.m_depth
|
|
|
+ , mip.m_width
|
|
|
+ , mip.m_height
|
|
|
+ , mip.m_depth
|
|
|
, dstMip.m_width*16
|
|
|
, mip.m_format
|
|
|
);
|
|
|
@@ -424,7 +424,7 @@ bimg::ImageContainer* convert(bx::AllocatorI* _allocator, const void* _inputData
|
|
|
for (uint32_t xx = 0; xx < mip.m_width; ++xx)
|
|
|
{
|
|
|
const uint32_t offset = (yy*mip.m_width + xx) * 4;
|
|
|
- float* inout = &rgba[offset];
|
|
|
+ float* inout = &rgba32f[offset];
|
|
|
inout[0] = inout[0] * 2.0f - 1.0f;
|
|
|
inout[1] = inout[1] * 2.0f - 1.0f;
|
|
|
inout[2] = inout[2] * 2.0f - 1.0f;
|
|
|
@@ -433,23 +433,26 @@ bimg::ImageContainer* convert(bx::AllocatorI* _allocator, const void* _inputData
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- imageRgba32fNormalize(rgba
|
|
|
+ imageRgba32fNormalize(
|
|
|
+ rgba32f
|
|
|
, dstMip.m_width
|
|
|
, dstMip.m_height
|
|
|
, dstMip.m_width*16
|
|
|
- , rgba
|
|
|
+ , rgba32f
|
|
|
);
|
|
|
|
|
|
- bimg::imageRgba32f11to01(rgbaDst
|
|
|
+ bimg::imageRgba32f11to01(
|
|
|
+ rgbaDst
|
|
|
, dstMip.m_width
|
|
|
, dstMip.m_height
|
|
|
, dstMip.m_depth
|
|
|
, dstMip.m_width*16
|
|
|
- , rgba
|
|
|
+ , rgba32f
|
|
|
);
|
|
|
|
|
|
bimg::Quality::Enum nmapQuality = bimg::Quality::Enum(_options.quality + bimg::Quality::NormalMapDefault);
|
|
|
- bimg::imageEncodeFromRgba32f(_allocator
|
|
|
+ bimg::imageEncodeFromRgba32f(
|
|
|
+ _allocator
|
|
|
, dstData
|
|
|
, rgbaDst
|
|
|
, dstMip.m_width
|
|
|
@@ -462,26 +465,29 @@ bimg::ImageContainer* convert(bx::AllocatorI* _allocator, const void* _inputData
|
|
|
|
|
|
for (uint8_t lod = 1; lod < numMips && _err->isOk(); ++lod)
|
|
|
{
|
|
|
- bimg::imageRgba32fDownsample2x2NormalMap(rgba
|
|
|
+ bimg::imageRgba32fDownsample2x2NormalMap(
|
|
|
+ rgba32f
|
|
|
, dstMip.m_width
|
|
|
, dstMip.m_height
|
|
|
, dstMip.m_width*16
|
|
|
, bx::strideAlign(dstMip.m_width/2, blockWidth)*16
|
|
|
- , rgba
|
|
|
+ , rgba32f
|
|
|
);
|
|
|
|
|
|
- bimg::imageRgba32f11to01(rgbaDst
|
|
|
+ bimg::imageRgba32f11to01(
|
|
|
+ rgbaDst
|
|
|
, dstMip.m_width
|
|
|
, dstMip.m_height
|
|
|
, dstMip.m_depth
|
|
|
, dstMip.m_width*16
|
|
|
- , rgba
|
|
|
+ , rgba32f
|
|
|
);
|
|
|
|
|
|
bimg::imageGetRawData(*output, side, lod, output->m_data, output->m_size, dstMip);
|
|
|
dstData = const_cast<uint8_t*>(dstMip.m_data);
|
|
|
|
|
|
- bimg::imageEncodeFromRgba32f(_allocator
|
|
|
+ bimg::imageEncodeFromRgba32f(
|
|
|
+ _allocator
|
|
|
, dstData
|
|
|
, rgbaDst
|
|
|
, dstMip.m_width
|
|
|
@@ -515,13 +521,14 @@ bimg::ImageContainer* convert(bx::AllocatorI* _allocator, const void* _inputData
|
|
|
float* rgba32f = (float*)temp;
|
|
|
float* rgbaDst = (float*)BX_ALLOC(_allocator, size);
|
|
|
|
|
|
- bimg::imageDecodeToRgba32f(_allocator
|
|
|
+ bimg::imageDecodeToRgba32f(
|
|
|
+ _allocator
|
|
|
, rgba32f
|
|
|
, mip.m_data
|
|
|
, mip.m_width
|
|
|
, mip.m_height
|
|
|
, mip.m_depth
|
|
|
- , mip.m_width*16
|
|
|
+ , dstMip.m_width*16
|
|
|
, mip.m_format
|
|
|
);
|
|
|
|
|
|
@@ -536,7 +543,8 @@ bimg::ImageContainer* convert(bx::AllocatorI* _allocator, const void* _inputData
|
|
|
);
|
|
|
}
|
|
|
|
|
|
- bimg::imageEncodeFromRgba32f(_allocator
|
|
|
+ bimg::imageEncodeFromRgba32f(
|
|
|
+ _allocator
|
|
|
, dstData
|
|
|
, rgba32f
|
|
|
, dstMip.m_width
|
|
|
@@ -560,7 +568,8 @@ bimg::ImageContainer* convert(bx::AllocatorI* _allocator, const void* _inputData
|
|
|
|
|
|
for (uint8_t lod = 1; lod < numMips && _err->isOk(); ++lod)
|
|
|
{
|
|
|
- bimg::imageRgba32fLinearDownsample2x2(rgba32f
|
|
|
+ bimg::imageRgba32fLinearDownsample2x2(
|
|
|
+ rgba32f
|
|
|
, dstMip.m_width
|
|
|
, dstMip.m_height
|
|
|
, dstMip.m_depth
|
|
|
@@ -582,7 +591,8 @@ bimg::ImageContainer* convert(bx::AllocatorI* _allocator, const void* _inputData
|
|
|
bimg::imageGetRawData(*output, side, lod, output->m_data, output->m_size, dstMip);
|
|
|
dstData = const_cast<uint8_t*>(dstMip.m_data);
|
|
|
|
|
|
- bimg::imageRgba32fToGamma(rgbaDst
|
|
|
+ bimg::imageRgba32fToGamma(
|
|
|
+ rgbaDst
|
|
|
, mip.m_width
|
|
|
, mip.m_height
|
|
|
, mip.m_depth
|
|
|
@@ -590,7 +600,8 @@ bimg::ImageContainer* convert(bx::AllocatorI* _allocator, const void* _inputData
|
|
|
, rgba32f
|
|
|
);
|
|
|
|
|
|
- bimg::imageEncodeFromRgba32f(_allocator
|
|
|
+ bimg::imageEncodeFromRgba32f(
|
|
|
+ _allocator
|
|
|
, dstData
|
|
|
, rgbaDst
|
|
|
, dstMip.m_width
|
|
|
@@ -621,7 +632,8 @@ bimg::ImageContainer* convert(bx::AllocatorI* _allocator, const void* _inputData
|
|
|
temp = BX_ALLOC(_allocator, size);
|
|
|
uint8_t* r8 = (uint8_t*)temp;
|
|
|
|
|
|
- bimg::imageDecodeToR8(_allocator
|
|
|
+ bimg::imageDecodeToR8(
|
|
|
+ _allocator
|
|
|
, r8
|
|
|
, mip.m_data
|
|
|
, mip.m_width
|
|
|
@@ -644,13 +656,14 @@ bimg::ImageContainer* convert(bx::AllocatorI* _allocator, const void* _inputData
|
|
|
|
|
|
if (_options.mips) {
|
|
|
const float alphaRef = 0.5f;
|
|
|
- float coverage = bimg::imageAlphaTestCoverage(bimg::TextureFormat::A8
|
|
|
+ float coverage = bimg::imageAlphaTestCoverage(
|
|
|
+ bimg::TextureFormat::A8
|
|
|
, mip.m_width
|
|
|
, mip.m_height
|
|
|
, mip.m_width
|
|
|
, r8
|
|
|
, alphaRef
|
|
|
- );
|
|
|
+ );
|
|
|
|
|
|
size = bimg::imageGetSize(
|
|
|
NULL
|
|
|
@@ -676,21 +689,23 @@ bimg::ImageContainer* convert(bx::AllocatorI* _allocator, const void* _inputData
|
|
|
);
|
|
|
|
|
|
for (uint8_t lod = 1; lod < numMips && _err->isOk(); ++lod) {
|
|
|
- bimg::imageRgba8Downsample2x2(rgba
|
|
|
+ bimg::imageRgba8Downsample2x2(
|
|
|
+ rgba
|
|
|
, dstMip.m_width
|
|
|
, dstMip.m_height
|
|
|
, dstMip.m_depth
|
|
|
, dstMip.m_width * 4
|
|
|
, bx::strideAlign(dstMip.m_width / 2, blockWidth) * 4
|
|
|
, rgba
|
|
|
- );
|
|
|
+ );
|
|
|
|
|
|
// For each mip, upscale to original size,
|
|
|
// scale image alpha to get same coverage as mip0
|
|
|
uint32_t upsample = 1 << lod;
|
|
|
uint32_t destWidth = dstMip.m_width / 2;
|
|
|
uint32_t destHeight = dstMip.m_height / 2;
|
|
|
- bimg::imageScaleAlphaToCoverage(bimg::TextureFormat::RGBA8
|
|
|
+ bimg::imageScaleAlphaToCoverage(
|
|
|
+ bimg::TextureFormat::RGBA8
|
|
|
, destWidth
|
|
|
, destHeight
|
|
|
, destWidth * 4
|
|
|
@@ -698,7 +713,7 @@ bimg::ImageContainer* convert(bx::AllocatorI* _allocator, const void* _inputData
|
|
|
, coverage
|
|
|
, alphaRef
|
|
|
, upsample
|
|
|
- );
|
|
|
+ );
|
|
|
|
|
|
bimg::imageGetRawData(*output, side, lod, output->m_data, output->m_size, dstMip);
|
|
|
dstData = const_cast<uint8_t*>(dstMip.m_data);
|