Adding -renorm option, manually merged from
https://github.com/BinomialLLC/basis_universal/pull/104/commits/29db2936fea77f00d1aecea9610fd94ac3eb60f8
diff --git a/basisu_comp.cpp b/basisu_comp.cpp
index ba66e30..7b5bbe9 100644
--- a/basisu_comp.cpp
+++ b/basisu_comp.cpp
@@ -73,6 +73,7 @@
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_renormalize);
PRINT_BOOL_VALUE(m_multithreading);
PRINT_BOOL_VALUE(m_disable_hierarchical_endpoint_codebooks);
@@ -398,6 +399,9 @@
file_image = m_params.m_source_images[source_file_index];
}
+ if (m_params.m_renormalize)
+ file_image.renormalize_normal_map();
+
if (m_params.m_seperate_rg_to_color_alpha)
{
// Used for XY normal maps in RG - puts X in color, Y in alpha
diff --git a/basisu_comp.h b/basisu_comp.h
index af32655..5672039 100644
--- a/basisu_comp.h
+++ b/basisu_comp.h
@@ -237,6 +237,7 @@
m_force_alpha.clear();
m_multithreading.clear();
m_seperate_rg_to_color_alpha.clear();
+ m_renormalize.clear();
m_hybrid_sel_cb_quality_thresh.clear();
m_global_pal_bits.clear();
m_global_mod_bits.clear();
@@ -339,6 +340,8 @@
// Split the R channel to RGB and the G channel to alpha, then write a basis file with alpha channels
bool_param<false> m_seperate_rg_to_color_alpha;
+ bool_param<false> m_renormalize;
+
bool_param<false> m_disable_hierarchical_endpoint_codebooks;
// Global/hybrid selector codebook parameters
diff --git a/basisu_tool.cpp b/basisu_tool.cpp
index 5e36d0f..b661693 100644
--- a/basisu_tool.cpp
+++ b/basisu_tool.cpp
@@ -99,6 +99,7 @@
" -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"
+ " -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"
" -etc1_only: Only unpack to ETC1, skipping the other texture formats during -unpack\n"
@@ -407,6 +408,8 @@
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;
+ else if (strcasecmp(pArg, "-renorm") == 0)
+ m_comp_params.m_renormalize = true;
else if (strcasecmp(pArg, "-no_multithreading") == 0)
{
m_comp_params.m_multithreading = false;