mirror of
https://github.com/microsoft/DirectXTex.git
synced 2025-07-09 19:50:13 +02:00
texconv -reconstructz updated to handle UNORM properly
This commit is contained in:
parent
87e5b0e9fa
commit
610bbbd84e
@ -2792,6 +2792,8 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isunorm = (FormatDataType(info.format) == FORMAT_TYPE_UNORM) != 0;
|
||||||
|
|
||||||
hr = TransformImage(image->GetImages(), image->GetImageCount(), image->GetMetadata(),
|
hr = TransformImage(image->GetImages(), image->GetImageCount(), image->GetMetadata(),
|
||||||
[&](XMVECTOR* outPixels, const XMVECTOR* inPixels, size_t w, size_t y)
|
[&](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 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);
|
outPixels[j] = XMVectorSelect(value, z, s_selectz);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user