mirror of
https://github.com/BinomialLLC/basis_universal.git
synced 2026-10-30 20:55:45 +00:00
apply swizzle patch
This commit is contained in:
+18
-8
@@ -70,9 +70,13 @@ namespace basisu
|
||||
PRINT_BOOL_VALUE(m_read_source_images);
|
||||
PRINT_BOOL_VALUE(m_write_output_basis_files);
|
||||
PRINT_BOOL_VALUE(m_compute_stats);
|
||||
PRINT_BOOL_VALUE(m_check_for_alpha)
|
||||
PRINT_BOOL_VALUE(m_force_alpha)
|
||||
PRINT_BOOL_VALUE(m_seperate_rg_to_color_alpha);
|
||||
PRINT_BOOL_VALUE(m_check_for_alpha);
|
||||
PRINT_BOOL_VALUE(m_force_alpha);
|
||||
debug_printf("swizzle: %d,%d,%d,%d\n",
|
||||
m_params.m_swizzle[0],
|
||||
m_params.m_swizzle[1],
|
||||
m_params.m_swizzle[2],
|
||||
m_params.m_swizzle[3]);
|
||||
PRINT_BOOL_VALUE(m_renormalize);
|
||||
PRINT_BOOL_VALUE(m_multithreading);
|
||||
PRINT_BOOL_VALUE(m_disable_hierarchical_endpoint_codebooks);
|
||||
@@ -402,19 +406,25 @@ namespace basisu
|
||||
if (m_params.m_renormalize)
|
||||
file_image.renormalize_normal_map();
|
||||
|
||||
if (m_params.m_seperate_rg_to_color_alpha)
|
||||
bool alpha_swizzled = false;
|
||||
if (m_params.m_swizzle[0] != 0 ||
|
||||
m_params.m_swizzle[1] != 1 ||
|
||||
m_params.m_swizzle[2] != 2 ||
|
||||
m_params.m_swizzle[3] != 3)
|
||||
{
|
||||
// Used for XY normal maps in RG - puts X in color, Y in alpha
|
||||
// Apply swizzle to incoming data
|
||||
for (uint32_t y = 0; y < file_image.get_height(); y++)
|
||||
for (uint32_t x = 0; x < file_image.get_width(); x++)
|
||||
{
|
||||
const color_rgba &c = file_image(x, y);
|
||||
file_image(x, y).set_noclamp_rgba(c.r, c.r, c.r, c.g);
|
||||
file_image(x, y).set_noclamp_rgba(c[m_params.m_swizzle[0]], c[m_params.m_swizzle[1]], c[m_params.m_swizzle[2]], c[m_params.m_swizzle[3]]);
|
||||
}
|
||||
|
||||
alpha_swizzled = m_params.m_swizzle[3] != 3;
|
||||
}
|
||||
|
||||
|
||||
bool has_alpha = false;
|
||||
if ((m_params.m_force_alpha) || (m_params.m_seperate_rg_to_color_alpha))
|
||||
if (m_params.m_force_alpha || alpha_swizzled)
|
||||
has_alpha = true;
|
||||
else if (!m_params.m_check_for_alpha)
|
||||
file_image.set_alpha(255);
|
||||
|
||||
Reference in New Issue
Block a user