Add FlipX to texture tool.

This commit is contained in:
Chandler Cox
2024-10-04 19:31:55 -05:00
parent 2a5de178fa
commit 305d3a6496
3 changed files with 28 additions and 5 deletions

View File

@@ -727,7 +727,8 @@ bool TextureTool::ImportTextureDirectXTex(ImageType type, const StringView& path
}
bool keepAsIs = false;
if (!options.FlipY &&
if (!options.FlipY &&
!options.FlipX &&
!options.InvertGreenChannel &&
!options.ReconstructZChannel &&
options.Compress &&
@@ -788,7 +789,7 @@ bool TextureTool::ImportTextureDirectXTex(ImageType type, const StringView& path
SET_CURRENT_IMG(tmpImg);
}
// Check flip/rotate source image
// Check flip/rotate Y source image
if (!keepAsIs && options.FlipY)
{
auto& tmpImg = GET_TMP_IMG();
@@ -802,6 +803,20 @@ bool TextureTool::ImportTextureDirectXTex(ImageType type, const StringView& path
SET_CURRENT_IMG(tmpImg);
}
// Check flip/rotate X source image
if (!keepAsIs && options.FlipX)
{
auto& tmpImg = GET_TMP_IMG();
DirectX::TEX_FR_FLAGS flags = DirectX::TEX_FR_FLIP_HORIZONTAL;
result = FlipRotate(currentImage->GetImages(), currentImage->GetImageCount(), currentImage->GetMetadata(), flags, tmpImg);
if (FAILED(result))
{
errorMsg = String::Format(TEXT("Cannot rotate/flip texture, error: {0:x}"), static_cast<uint32>(result));
return true;
}
SET_CURRENT_IMG(tmpImg);
}
// Check if invert green channel
if (!keepAsIs && options.InvertGreenChannel)
{