Fix more errors in the use of the color metric.
Remove debug code from compress.cpp
This commit is contained in:
parent
6b016dae96
commit
a76e89d0d7
@ -98,6 +98,7 @@ void ClusterFit::setMetric(float r, float g, float b)
|
||||
#else
|
||||
m_metric = Vec3(r, g, b);
|
||||
#endif
|
||||
m_metricSqr = m_metric * m_metric;
|
||||
}
|
||||
|
||||
float ClusterFit::bestError() const
|
||||
@ -401,7 +402,7 @@ Vec4 ClusterFit::SolveLeastSquares( Vec4& start, Vec4& end ) const
|
||||
Vec4 e4 = MultiplyAdd( a*b*alphabeta_sum - e2, two, e3 );
|
||||
|
||||
// apply the metric to the error term
|
||||
Vec4 e5 = e4*m_metric;
|
||||
Vec4 e5 = e4*m_metricSqr;
|
||||
Vec4 error = e5.SplatX() + e5.SplatY() + e5.SplatZ();
|
||||
|
||||
// save the start and end
|
||||
@ -473,7 +474,7 @@ float ClusterFit::SolveLeastSquares( Vec3& start, Vec3& end ) const
|
||||
+ 2.0f*( a*b*alphabeta_sum - a*alphax_sum - b*betax_sum );
|
||||
|
||||
// apply the metric to the error term
|
||||
float error = Dot( e1, m_metric );
|
||||
float error = Dot( e1, m_metricSqr );
|
||||
|
||||
//if (debug) printf(" - %f\n", error);
|
||||
|
||||
|
@ -55,6 +55,7 @@ private:
|
||||
Vec4 m_unweighted[16];
|
||||
Vec4 m_weights[16];
|
||||
Vec4 m_metric;
|
||||
Vec4 m_metricSqr;
|
||||
Vec4 m_alpha[16];
|
||||
Vec4 m_beta[16];
|
||||
Vec4 m_xxsum;
|
||||
@ -66,6 +67,7 @@ private:
|
||||
Vec3 m_unweighted[16];
|
||||
float m_weights[16];
|
||||
Vec3 m_metric;
|
||||
Vec3 m_metricSqr;
|
||||
float m_alpha[16];
|
||||
float m_beta[16];
|
||||
Vec3 m_xxsum;
|
||||
|
@ -184,16 +184,17 @@ void FastClusterFit::setMetric(float r, float g, float b)
|
||||
#else
|
||||
m_metric = Vec3(r, g, b);
|
||||
#endif
|
||||
m_metricSqr = m_metric * m_metric;
|
||||
}
|
||||
|
||||
float FastClusterFit::bestError() const
|
||||
{
|
||||
#if SQUISH_USE_SIMD
|
||||
Vec4 x = m_xxsum * m_metric;
|
||||
Vec4 x = m_xxsum * m_metricSqr;
|
||||
Vec4 error = m_besterror + x.SplatX() + x.SplatY() + x.SplatZ();
|
||||
return error.GetVec3().X();
|
||||
#else
|
||||
return m_besterror + Dot(m_xxsum, m_metric);
|
||||
return m_besterror + Dot(m_xxsum, m_metricSqr);
|
||||
#endif
|
||||
|
||||
}
|
||||
@ -252,7 +253,7 @@ void FastClusterFit::Compress3( void* block )
|
||||
Vec4 e3 = MultiplyAdd( a*b*alphabeta_sum - e1, two, e2 );
|
||||
|
||||
// apply the metric to the error term
|
||||
Vec4 e4 = e3 * m_metric;
|
||||
Vec4 e4 = e3 * m_metricSqr;
|
||||
Vec4 error = e4.SplatX() + e4.SplatY() + e4.SplatZ();
|
||||
|
||||
// keep the solution if it wins
|
||||
@ -369,7 +370,7 @@ void FastClusterFit::Compress4( void* block )
|
||||
Vec4 e3 = MultiplyAdd( a*b*alphabeta_sum - e1, two, e2 );
|
||||
|
||||
// apply the metric to the error term
|
||||
Vec4 e4 = e3 * m_metric;
|
||||
Vec4 e4 = e3 * m_metricSqr;
|
||||
Vec4 error = e4.SplatX() + e4.SplatY() + e4.SplatZ();
|
||||
|
||||
// keep the solution if it wins
|
||||
@ -489,7 +490,7 @@ void FastClusterFit::Compress3( void* block )
|
||||
Vec3 e1 = a*a*alpha2_sum + b*b*beta2_sum + 2.0f*( a*b*alphabeta_sum - a*alphax_sum - b*betax_sum );
|
||||
|
||||
// apply the metric to the error term
|
||||
float error = Dot( e1, m_metric );
|
||||
float error = Dot( e1, m_metricSqr );
|
||||
|
||||
// keep the solution if it wins
|
||||
if( error < besterror )
|
||||
@ -601,7 +602,7 @@ void FastClusterFit::Compress4( void* block )
|
||||
Vec3 e1 = a*a*alpha2_sum + b*b*beta2_sum + 2.0f*( a*b*alphabeta_sum - a*alphax_sum - b*betax_sum );
|
||||
|
||||
// apply the metric to the error term
|
||||
float error = Dot( e1, m_metric );
|
||||
float error = Dot( e1, m_metricSqr );
|
||||
|
||||
// keep the solution if it wins
|
||||
if( error < besterror )
|
||||
|
@ -55,12 +55,14 @@ private:
|
||||
#if SQUISH_USE_SIMD
|
||||
Vec4 m_unweighted[16];
|
||||
Vec4 m_metric;
|
||||
Vec4 m_metricSqr;
|
||||
Vec4 m_xxsum;
|
||||
Vec4 m_xsum;
|
||||
Vec4 m_besterror;
|
||||
#else
|
||||
Vec3 m_unweighted[16];
|
||||
Vec3 m_metric;
|
||||
Vec3 m_metricSqr;
|
||||
Vec3 m_xxsum;
|
||||
Vec3 m_xsum;
|
||||
float m_besterror;
|
||||
|
@ -107,16 +107,17 @@ void WeightedClusterFit::setMetric(float r, float g, float b)
|
||||
#else
|
||||
m_metric = Vec3(r, g, b);
|
||||
#endif
|
||||
m_metricSqr = m_metric * m_metric;
|
||||
}
|
||||
|
||||
float WeightedClusterFit::bestError() const
|
||||
{
|
||||
#if SQUISH_USE_SIMD
|
||||
Vec4 x = m_xxsum * m_metric;
|
||||
Vec4 x = m_xxsum * m_metricSqr;
|
||||
Vec4 error = m_besterror + x.SplatX() + x.SplatY() + x.SplatZ();
|
||||
return error.GetVec3().X();
|
||||
#else
|
||||
return m_besterror + Dot(m_xxsum, m_metric);
|
||||
return m_besterror + Dot(m_xxsum, m_metricSqr);
|
||||
#endif
|
||||
|
||||
}
|
||||
@ -183,7 +184,7 @@ void WeightedClusterFit::Compress3( void* block )
|
||||
Vec4 e3 = MultiplyAdd( a*b*alphabeta_sum - e1, two, e2 );
|
||||
|
||||
// apply the metric to the error term
|
||||
Vec4 e4 = e3 * m_metric;
|
||||
Vec4 e4 = e3 * m_metricSqr;
|
||||
Vec4 error = e4.SplatX() + e4.SplatY() + e4.SplatZ();
|
||||
|
||||
// keep the solution if it wins
|
||||
@ -298,7 +299,7 @@ void WeightedClusterFit::Compress4( void* block )
|
||||
Vec4 e3 = MultiplyAdd( a*b*alphabeta_sum - e1, two, e2 );
|
||||
|
||||
// apply the metric to the error term
|
||||
Vec4 e4 = e3 * m_metric;
|
||||
Vec4 e4 = e3 * m_metricSqr;
|
||||
Vec4 error = e4.SplatX() + e4.SplatY() + e4.SplatZ();
|
||||
|
||||
// keep the solution if it wins
|
||||
@ -408,7 +409,7 @@ void WeightedClusterFit::Compress3( void* block )
|
||||
Vec3 e1 = a*a*alpha2_sum + b*b*beta2_sum + 2.0f*( a*b*alphabeta_sum - a*alphax_sum - b*betax_sum );
|
||||
|
||||
// apply the metric to the error term
|
||||
float error = Dot( e1, m_metric );
|
||||
float error = Dot( e1, m_metricSqr );
|
||||
|
||||
// keep the solution if it wins
|
||||
if( error < besterror )
|
||||
@ -513,7 +514,7 @@ void WeightedClusterFit::Compress4( void* block )
|
||||
Vec3 e1 = a*a*alpha2_sum + b*b*beta2_sum + 2.0f*( a*b*alphabeta_sum - a*alphax_sum - b*betax_sum );
|
||||
|
||||
// apply the metric to the error term
|
||||
float error = Dot( e1, m_metric );
|
||||
float error = Dot( e1, m_metricSqr );
|
||||
|
||||
// keep the solution if it wins
|
||||
if( error < besterror )
|
||||
|
@ -55,6 +55,7 @@ private:
|
||||
#if SQUISH_USE_SIMD
|
||||
Vec4 m_weighted[16];
|
||||
Vec4 m_metric;
|
||||
Vec4 m_metricSqr;
|
||||
Vec4 m_xxsum;
|
||||
Vec4 m_xsum;
|
||||
Vec4 m_besterror;
|
||||
@ -62,6 +63,7 @@ private:
|
||||
Vec3 m_weighted[16];
|
||||
float m_weights[16];
|
||||
Vec3 m_metric;
|
||||
Vec3 m_metricSqr;
|
||||
Vec3 m_xxsum;
|
||||
Vec3 m_xsum;
|
||||
float m_wsum;
|
||||
|
@ -386,15 +386,7 @@ int main(int argc, char *argv[])
|
||||
//compressionOptions.setQuality(nvtt::Quality_Highest);
|
||||
}
|
||||
compressionOptions.enableHardwareCompression(!nocuda);
|
||||
|
||||
if (normal)
|
||||
{
|
||||
compressionOptions.setColorWeights(4, 4, 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
compressionOptions.setColorWeights(1, 1, 1);
|
||||
}
|
||||
compressionOptions.setColorWeights(1, 1, 1);
|
||||
|
||||
if (externalCompressor != NULL)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user