0.4.0.9 Beta 07/27/2014

0.4.0.9 Beta 07/27/2014
--User Changes
Properly set tab order on all controls.
Calculate and report iters/second in the final render dialog.
Immediately draw yellow dot on xform mouse down on previously unselected
xform.

--Bug Fixes
Fix GlynnSim1, GlynnSim2, GlynnSim3 and juliaNab by ensuring the first
argument to pow() is >= 0.
Ensure OpenCL platform and device combo boxes in the final render dialog
expand as needed.

--Code Changes
Make VariationTreeSpinbox take its parent VariationTreeWidgetItem as a
constructor argument. This makes SetupVariationTree() and
VariationSpinBoxValueChanged() more efficient.
Make Interference2 and ho use fabs().
This commit is contained in:
mfeemster
2014-07-27 22:25:38 -07:00
parent a5d69c75a2
commit 88a325a5cd
28 changed files with 561 additions and 111 deletions

View File

@ -25,7 +25,7 @@ namespace EmberNs
extern void sincos(double x, double *s, double *c);
#endif
#define EMBER_VERSION "0.4.0.8"
#define EMBER_VERSION "0.4.0.9"
#define EPS6 T(1e-6)
#define EPS std::numeric_limits<T>::epsilon()//Apoplugin.h uses -20, but it's more mathematically correct to do it this way.
#define ISAAC_SIZE 4

View File

@ -3473,7 +3473,7 @@ public:
{
T wx = m_Weight * T(1.3029400317411197908970256609023);//This precision came from the original.
T y2 = helper.In.y * 2;
T r = wx * sqrt(fabs(helper.In.y * helper.In.x) / Zeps(helper.In.x * helper.In.x + y2 * y2));
T r = wx * sqrt(fabs(helper.In.y * helper.In.x) / Zeps(SQR(helper.In.x) + SQR(y2)));
helper.Out.x = r * helper.In.x;
helper.Out.y = r * y2;
@ -3488,7 +3488,7 @@ public:
ss << "\t{\n"
<< "\t\treal_t wx = xform->m_VariationWeights[" << varIndex << "] * 1.3029400317411197908970256609023;\n"
<< "\t\treal_t y2 = vIn.y * 2.0;\n"
<< "\t\treal_t r = wx * sqrt(fabs(vIn.y * vIn.x) / Zeps(vIn.x * vIn.x + y2 * y2));\n"
<< "\t\treal_t r = wx * sqrt(fabs(vIn.y * vIn.x) / Zeps(SQR(vIn.x) + SQR(y2)));\n"
<< "\n"
<< "\t\tvOut.x = r * vIn.x;\n"
<< "\t\tvOut.y = r * y2;\n"

View File

@ -424,7 +424,7 @@ public:
void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand)
{
T x, y, z, alpha = m_Radius / helper.m_PrecalcSqrtSumSquares;
T x, y, z;
if (helper.m_PrecalcSqrtSumSquares < m_Radius)//Object generation.
{
@ -434,6 +434,8 @@ public:
}
else
{
T alpha = fabs(m_Radius / Zeps(helper.m_PrecalcSqrtSumSquares));//Original did not fabs().
if (rand.Frand01<T>() > m_Contrast * pow(alpha, m_Pow))
{
x = helper.In.x;
@ -479,7 +481,7 @@ public:
string y1 = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
ss << "\t{\n"
<< "\t\treal_t x, y, z, alpha = " << radius << " / precalcSqrtSumSquares;\n"
<< "\t\treal_t x, y, z;\n"
<< "\n"
<< "\t\tif (precalcSqrtSumSquares < " << radius << ")\n"
<< "\t\t{\n"
@ -489,6 +491,8 @@ public:
<< "\t\t}\n"
<< "\t\telse\n"
<< "\t\t{\n"
<< "\t\t real_t alpha = fabs(" << radius << " / Zeps(precalcSqrtSumSquares));\n"
<< "\n"
<< "\t\t if (MwcNext01(mwc) > " << contrast << " * pow(alpha, " << pow << "))\n"
<< "\t\t {\n"
<< "\t\t x = vIn.x;\n"
@ -602,7 +606,7 @@ public:
void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand)
{
T x, y, alpha = m_Radius / helper.m_PrecalcSqrtSumSquares;
T x, y;
if (helper.m_PrecalcSqrtSumSquares < m_Radius)
{
@ -612,6 +616,8 @@ public:
}
else
{
T alpha = fabs(m_Radius / Zeps(helper.m_PrecalcSqrtSumSquares));//Original did not fabs().
if (rand.Frand01<T>() > m_Contrast * pow(alpha, m_Pow))
{
helper.Out.x = m_Weight * helper.In.x;
@ -645,7 +651,7 @@ public:
string delta = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
ss << "\t{\n"
<< "\t\treal_t x, y, alpha = " << radius << " / precalcSqrtSumSquares;\n"
<< "\t\treal_t x, y;\n"
<< "\n"
<< "\t\tif (precalcSqrtSumSquares < " << radius << ")\n"
<< "\t\t{\n"
@ -655,6 +661,8 @@ public:
<< "\t\t}\n"
<< "\t\telse\n"
<< "\t\t{\n"
<< "\t\t real_t alpha = fabs(" << radius << " / Zeps(precalcSqrtSumSquares));\n"
<< "\n"
<< "\t\t if (MwcNext01(mwc) > " << contrast << " * pow(alpha, " << pow << "))\n"
<< "\t\t {\n"
<< "\t\t vOut.x = xform->m_VariationWeights[" << varIndex << "] * vIn.x;\n"
@ -692,9 +700,9 @@ public:
virtual void Precalc()
{
m_Pow = fabs(m_Pow);
m_Phi10 = M_2PI * m_Phi1;
m_Phi20 = M_2PI * m_Phi2;
m_Gamma = m_Thickness * (2 * m_Radius + m_Thickness) / (m_Radius + m_Thickness);
m_Phi10 = T(M_PI) * m_Phi1 / 180;
m_Phi20 = T(M_PI) * m_Phi2 / 180;
m_Gamma = m_Thickness * (2 * m_Radius + m_Thickness) / Zeps(m_Radius + m_Thickness);
m_Delta = m_Phi20 - m_Phi10;
}
@ -756,7 +764,7 @@ public:
void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand)
{
T x, y, alpha = m_Radius / helper.m_PrecalcSqrtSumSquares;
T x, y;
if (helper.m_PrecalcSqrtSumSquares < m_Radius1)
{
@ -766,6 +774,8 @@ public:
}
else
{
T alpha = fabs(m_Radius / Zeps(helper.m_PrecalcSqrtSumSquares));//Original did not fabs().
if (rand.Frand01<T>() > m_Contrast * pow(alpha, m_Pow))
{
helper.Out.x = m_Weight * helper.In.x;
@ -797,7 +807,7 @@ public:
string gamma = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
ss << "\t{\n"
<< "\t\treal_t x, y, alpha = " << radius << " / precalcSqrtSumSquares;\n"
<< "\t\treal_t x, y;\n"
<< "\n"
<< "\t\tif (precalcSqrtSumSquares < " << radius1 << ")\n"
<< "\t\t{\n"
@ -807,6 +817,8 @@ public:
<< "\t\t}\n"
<< "\t\telse\n"
<< "\t\t{\n"
<< "\t\t real_t alpha = fabs(" << radius << " / Zeps(precalcSqrtSumSquares));\n"
<< "\n"
<< "\t\t if (MwcNext01(mwc) > " << contrast << " * pow(alpha, " << pow << "))\n"
<< "\t\t {\n"
<< "\t\t vOut.x = xform->m_VariationWeights[" << varIndex << "] * vIn.x;\n"
@ -849,8 +861,8 @@ public:
virtual void Precalc()
{
m_Radius1 = m_Radius + m_Thickness;
m_Radius2 = SQR(m_Radius) / m_Radius1;
m_Gamma = m_Radius1 / (m_Radius1 + m_Radius2);
m_Radius2 = SQR(m_Radius) / Zeps(m_Radius1);
m_Gamma = m_Radius1 / Zeps(m_Radius1 + m_Radius2);
}
protected:
@ -1045,18 +1057,13 @@ public:
return ss.str();
}
virtual void Precalc()
{
ClampGte0Ref<T>(m_Power);
}
protected:
void Init()
{
string prefix = Prefix();
m_Params.clear();
m_Params.push_back(ParamWithName<T>(&m_Power, prefix + "sineblur_power", 1));
m_Params.push_back(ParamWithName<T>(&m_Power, prefix + "sineblur_power", 1, REAL, 0));
}
private:

View File

@ -1231,7 +1231,7 @@ public:
{
T jun = Zeps(fabs(m_N));
T a = (atan2(helper.In.y, pow(helper.In.x, m_Sep)) + M_2PI * Floor<T>(rand.Frand01<T>() * m_AbsN)) / jun;
T a = (atan2(helper.In.y, pow(fabs(helper.In.x), m_Sep)) + M_2PI * Floor<T>(rand.Frand01<T>() * m_AbsN)) / jun;
T r = m_Weight * pow(helper.m_PrecalcSumSquares, m_Cn * m_A);
helper.Out.x = r * cos(a) + m_B;
@ -1255,7 +1255,7 @@ public:
ss << "\t{\n"
<< "\t\treal_t jun = Zeps(fabs(" << n << "));\n"
<< "\n"
<< "\t\treal_t a = (atan2(vIn.y, pow(vIn.x, " << sep << ")) + M_2PI * floor(MwcNext01(mwc) * " << absN << ")) / jun;\n"
<< "\t\treal_t a = (atan2(vIn.y, pow(fabs(vIn.x), " << sep << ")) + M_2PI * floor(MwcNext01(mwc) * " << absN << ")) / jun;\n"
<< "\t\treal_t r = xform->m_VariationWeights[" << varIndex << "] * pow(precalcSumSquares, " << cn << " * " << a << ");\n"
<< "\n"
<< "\t\tvOut.x = r * cos(a) + " << b << ";\n"
@ -1709,8 +1709,8 @@ public:
pr1 = m_An2_1 * pow(fabs(mcosr), m_N2_1) + m_Bn3_1 * pow(fabs(msinr), m_N3_1);
pr2 = m_An2_2 * pow(fabs(mcosp), m_N2_2) + m_Bn3_2 * pow(fabs(msinp), m_N3_2);
r1 = pow(pr1, m_N1_1) + m_Spiral * rho1;
r2 = pow(pr2, m_N1_2);
r1 = pow(fabs(pr1), m_N1_1) + m_Spiral * rho1;
r2 = pow(fabs(pr2), m_N1_2);
if ((int)m_Toroidmap == 1)
{
@ -1784,8 +1784,8 @@ public:
<< "\n"
<< "\t\tpr1 = " << an2_1 << " * pow(fabs(mcosr), " << n2_1 << ") + " << bn3_1 << " * pow(fabs(msinr), " << n3_1 << ");\n"
<< "\t\tpr2 = " << an2_2 << " * pow(fabs(mcosp), " << n2_2 << ") + " << bn3_2 << " * pow(fabs(msinp), " << n3_2 << ");\n"
<< "\t\tr1 = pow(pr1, " << n1_1 << ") + " << spiral << " * rho1;\n"
<< "\t\tr2 = pow(pr2, " << n1_2 << ");\n"
<< "\t\tr1 = pow(fabs(pr1), " << n1_1 << ") + " << spiral << " * rho1;\n"
<< "\t\tr2 = pow(fabs(pr2), " << n1_2 << ");\n"
<< "\n"
<< "\t\tif ((int)" << toroid << " == 1)\n"
<< "\t\t{\n"
@ -3083,12 +3083,12 @@ public:
return
"real_t Interference2Sine(real_t a, real_t b, real_t c, real_t p, real_t x)\n"
"{\n"
" return a * pow(ClampGte(sin(b * x + c), EPS), p);\n"
" return a * pow(fabs(sin(b * x + c)), p);\n"
"}\n"
"\n"
"real_t Interference2Tri(real_t a, real_t b, real_t c, real_t p, real_t x)\n"
"{\n"
" return a * 2 * pow(ClampGte(asin(cos(b * x + c - M_PI_2)), EPS) * M_1_PI, p);\n"
" return a * 2 * pow(fabs(asin(cos(b * x + c - M_PI_2))) * M_1_PI, p);\n"
"}\n"
"\n"
"real_t Interference2Squ(real_t a, real_t b, real_t c, real_t p, real_t x)\n"
@ -3119,12 +3119,12 @@ protected:
private:
inline static T Sine(T a, T b, T c, T p, T x)
{
return a * pow(ClampGte<T>(sin(b * x + c), EPS), p);//Original did not clamp.
return a * pow(fabs(sin(b * x + c)), p);//Original did not fabs().
}
inline static T Tri(T a, T b, T c, T p, T x)
{
return a * 2 * pow(ClampGte<T>(asin(cos(b * x + c - T(M_PI_2))), EPS) * T(M_1_PI), p);//Original did not clamp.
return a * 2 * pow(fabs(asin(cos(b * x + c - T(M_PI_2)))) * T(M_1_PI), p);//Original did not fabs().
}
inline static T Squ(T a, T b, T c, T p, T x)

View File

@ -1085,9 +1085,9 @@ public:
T cv = cos(helper.In.y);
T cucv = cu * cv;
T sucv = su * cv;
T x = pow(ClampGte<T>(cucv, EPS), m_XPow) + (cucv * m_XPow) + (T(0.25) * atOmegaX);//Must clamp first argument to pow, because negative values will return NaN.
T y = pow(ClampGte<T>(sucv, EPS), m_YPow) + (sucv * m_YPow) + (T(0.25) * atOmegaY);//Original did not do this and would frequently return bad values.
T z = pow(ClampGte<T>(sv, EPS), m_ZPow) + sv * m_ZPow;
T x = pow(fabs(cucv), m_XPow) + (cucv * m_XPow) + (T(0.25) * atOmegaX);//Must fabs first argument to pow, because negative values will return NaN.
T y = pow(fabs(sucv), m_YPow) + (sucv * m_YPow) + (T(0.25) * atOmegaY);//Original did not do this and would frequently return bad values.
T z = pow(fabs(sv), m_ZPow) + sv * m_ZPow;
helper.Out.x = m_Weight * x;
helper.Out.y = m_Weight * y;
@ -1117,9 +1117,9 @@ public:
<< "\t\treal_t cv = cos(vIn.y);\n"
<< "\t\treal_t cucv = cu * cv;\n"
<< "\t\treal_t sucv = su * cv;\n"
<< "\t\treal_t x = pow(ClampGte(cucv, EPS), " << xpow << ") + (cucv * " << xpow << ") + (0.25 * atOmegaX);\n"
<< "\t\treal_t y = pow(ClampGte(sucv, EPS), " << ypow << ") + (sucv * " << ypow << ") + (0.25 * atOmegaY);\n"
<< "\t\treal_t z = pow(ClampGte(sv, EPS), " << zpow << ") + sv * " << zpow << ";\n"
<< "\t\treal_t x = pow(fabs(cucv), " << xpow << ") + (cucv * " << xpow << ") + (0.25 * atOmegaX);\n"
<< "\t\treal_t y = pow(fabs(sucv), " << ypow << ") + (sucv * " << ypow << ") + (0.25 * atOmegaY);\n"
<< "\t\treal_t z = pow(fabs(sv), " << zpow << ") + sv * " << zpow << ";\n"
<< "\n"
<< "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * x;\n"
<< "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * y;\n"
@ -2151,8 +2151,8 @@ public:
case 2://Box.
scale = Clamp<T>(rs, 0, T(0.9)) + T(0.1);
denom = 1 / scale;
helper.Out.x = m_Weight * Lerp<T>(helper.In.x, floor(helper.In.x * denom) + scale * ax, m_MulX * rs) + m_MulX * pow(ax, m_BoxPow) * rs * denom;
helper.Out.y = m_Weight * Lerp<T>(helper.In.y, floor(helper.In.y * denom) + scale * ay, m_MulY * rs) + m_MulY * pow(ay, m_BoxPow) * rs * denom;
helper.Out.x = m_Weight * Lerp<T>(helper.In.x, floor(helper.In.x * denom) + scale * ax, m_MulX * rs) + m_MulX * pow(ax, m_BoxPow) * rs * denom;//m_BoxPow should be an integer value held in T,
helper.Out.y = m_Weight * Lerp<T>(helper.In.y, floor(helper.In.y * denom) + scale * ay, m_MulY * rs) + m_MulY * pow(ay, m_BoxPow) * rs * denom;//so fabs() shouldn't be necessary.
helper.Out.z = m_Weight * Lerp<T>(helper.In.z, floor(helper.In.z * denom) + scale * az, m_MulZ * rs) + m_MulZ * pow(az, m_BoxPow) * rs * denom;
break;
}