apply swizzle patch

This commit is contained in:
Donovan Hutchence
2020-11-17 09:03:29 +00:00
parent d3fadac767
commit ef7d326654
3 changed files with 60 additions and 14 deletions

View File

@@ -99,6 +99,7 @@ static void print_usage()
" -no_alpha: Always output non-alpha basis files, even if one or more inputs has alpha\n"
" -force_alpha: Always output alpha basis files, even if no inputs has alpha\n"
" -separate_rg_to_color_alpha: Separate input R and G channels to RGB and A (for tangent space XY normal maps)\n"
" -swizzle rgba: Specify swizzle for the 4 input color channels using r, g, b and a (the -separate_rg_to_color_alpha flag is equivalent to rrrg)\n"
" -renorm: Renormalize each input image before any further processing/compression\n"
" -no_multithreading: Disable multithreading\n"
" -no_ktx: Disable KTX writing when unpacking (faster)\n"
@@ -407,8 +408,40 @@ public:
else if (strcasecmp(pArg, "-force_alpha") == 0)
m_comp_params.m_force_alpha = true;
else if ((strcasecmp(pArg, "-separate_rg_to_color_alpha") == 0) ||
(strcasecmp(pArg, "-seperate_rg_to_color_alpha") == 0)) // was mispelled for a while - whoops!
m_comp_params.m_seperate_rg_to_color_alpha = true;
(strcasecmp(pArg, "-seperate_rg_to_color_alpha") == 0)) // was mispelled for a while - whoops!
{
m_comp_params.m_swizzle[0] = 0;
m_comp_params.m_swizzle[1] = 0;
m_comp_params.m_swizzle[2] = 0;
m_comp_params.m_swizzle[3] = 1;
}
else if (strcasecmp(pArg, "-swizzle") == 0)
{
REMAINING_ARGS_CHECK(1);
const char *swizzle = arg_v[arg_index + 1];
if (strlen(swizzle) != 4)
{
error_printf("Swizzle requires exactly 4 characters\n");
return false;
}
for (int i=0; i<4; ++i)
{
if (swizzle[i] == 'r')
m_comp_params.m_swizzle[i] = 0;
else if (swizzle[i] == 'g')
m_comp_params.m_swizzle[i] = 1;
else if (swizzle[i] == 'b')
m_comp_params.m_swizzle[i] = 2;
else if (swizzle[i] == 'a')
m_comp_params.m_swizzle[i] = 3;
else
{
error_printf("Swizzle must be one of [rgba]");
return false;
}
}
arg_count++;
}
else if (strcasecmp(pArg, "-renorm") == 0)
m_comp_params.m_renormalize = true;
else if (strcasecmp(pArg, "-no_multithreading") == 0)