1
0
mirror of https://github.com/microsoft/DirectXTex synced 2024-11-21 20:10:05 +00:00

texconv -reconstructz updated to handle UNORM properly

This commit is contained in:
Chuck Walbourn 2021-02-24 00:20:48 -08:00
parent 87e5b0e9fa
commit 610bbbd84e

View File

@ -2792,6 +2792,8 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
return 1;
}
bool isunorm = (FormatDataType(info.format) == FORMAT_TYPE_UNORM) != 0;
hr = TransformImage(image->GetImages(), image->GetImageCount(), image->GetMetadata(),
[&](XMVECTOR* outPixels, const XMVECTOR* inPixels, size_t w, size_t y)
{
@ -2803,7 +2805,17 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
{
XMVECTOR value = inPixels[j];
XMVECTOR z = XMVectorSqrt(XMVectorSubtract(g_XMOne, XMVector2Dot(value, value)));
XMVECTOR z;
if (isunorm)
{
XMVECTOR x2 = XMVectorMultiplyAdd(value, g_XMTwo, g_XMNegativeOne);
x2 = XMVectorSqrt(XMVectorSubtract(g_XMOne, XMVector2Dot(x2, x2)));
z = XMVectorMultiplyAdd(x2, g_XMOneHalf, g_XMOneHalf);
}
else
{
z = XMVectorSqrt(XMVectorSubtract(g_XMOne, XMVector2Dot(value, value)));
}
outPixels[j] = XMVectorSelect(value, z, s_selectz);
}