--User changes

-Add post_smartcrop.

--Bug fixes
 -Fix bug in crackle.
 -Wrong point assignment in hexaplay3D, hexnix3D.
 -Improper Z assignment in rblur.
 -Fix inconsistency with original in circlecrop.
 -Put EMBER_ROOT bakc to ./../../../ in default.pri. This is TBD.

--Code changes
 -Convert all enums to class enum to be consistent with C++11 style.
 -Convert some if/else statements in filter classes to case statements.
 -Add overloaded stream operators to print various enums.
 -Optimize crob, nBlur.
 -Fix weird assignment statement in falloff3.
 -Cleanup in VarFuncs::SimplexNoise3D().
 -Replace fabs() with std::abs().
 -General cleanup.
This commit is contained in:
mfeemster
2016-01-12 20:42:12 -08:00
parent a8688e87b5
commit a3ecbbf690
22 changed files with 1402 additions and 1546 deletions
+1
View File
@@ -379,6 +379,7 @@ uint Timing::m_ProcessorCount;
EXPORTPREPOSTREGVAR(BubbleT3D, T) \
EXPORTPREPOSTREGVAR(Synth, T) \
EXPORTPREPOSTREGVAR(Crackle, T) \
template EMBER_API class PostSmartcropVariation<T>; /*Only implemented as post.*/ \
EXPORTPREPOSTREGVAR(DCBubble, T) \
EXPORTPREPOSTREGVAR(DCCarpet, T) \
EXPORTPREPOSTREGVAR(DCCube, T) \
+1 -1
View File
@@ -704,7 +704,7 @@ static inline T Spread(T x, T y)
template <typename T>
static inline T Powq4(T x, T y)
{
return std::pow(std::fabs(x), y) * SignNz(x);
return std::pow(std::abs(x), y) * SignNz(x);
}
/// <summary>
+21 -24
View File
@@ -92,11 +92,11 @@ public:
T t; // Temp double
// Convert input co-ordinates ( x, y, z ) to
// integer-based simplex grid ( i, j, k )
T skewIn = (v.x + v.y + v.z) * T(0.3333);
T skewIn = (v.x + v.y + v.z) * T(0.333333);
intmax_t i = Floor<T>(v.x + skewIn);
intmax_t j = Floor<T>(v.y + skewIn);
intmax_t k = Floor<T>(v.z + skewIn);
t = (i + j + k) * T(0.16666);
t = (i + j + k) * T(0.1666666);
// Cell origin co-ordinates in input space (x,y,z)
T x0 = i - t;
T y0 = j - t;
@@ -154,17 +154,17 @@ public:
// A step of 1i in (i,j,k) is a step of (1-T(0.16666), -T(0.16666), -T(0.16666)) in (x,y,z),
// and this is similar for j and k . . .
// Offsets for second corner in (x,y,z) coords
c[1].x = c[0].x - i1 + T(0.16666);
c[1].y = c[0].y - j1 + T(0.16666);
c[1].z = c[0].z - k1 + T(0.16666);
c[1].x = c[0].x - i1 + T(0.1666666);
c[1].y = c[0].y - j1 + T(0.1666666);
c[1].z = c[0].z - k1 + T(0.1666666);
// Offsets for third corner in (x,y,z) coords
c[2].x = c[0].x - i2 + 2 * T(0.16666);
c[2].y = c[0].y - j2 + 2 * T(0.16666);
c[2].z = c[0].z - k2 + 2 * T(0.16666);
c[2].x = c[0].x - i2 + 2 * T(0.1666666);
c[2].y = c[0].y - j2 + 2 * T(0.1666666);
c[2].z = c[0].z - k2 + 2 * T(0.1666666);
// Offsets for last corner in (x,y,z) coords
c[3].x = c[0].x - 1 + 3 * T(0.16666);
c[3].y = c[0].y - 1 + 3 * T(0.16666);
c[3].z = c[0].z - 1 + 3 * T(0.16666);
c[3].x = c[0].x - 1 + 3 * T(0.1666666);
c[3].y = c[0].y - 1 + 3 * T(0.1666666);
c[3].z = c[0].z - 1 + 3 * T(0.1666666);
// Work out the hashed gradient indices of the four simplex corners
int ii = i & 0x3ff;
int jj = j & 0x3ff;
@@ -175,9 +175,9 @@ public:
gi[3] = m_P[ii + 1 + m_P[jj + 1 + m_P[kk + 1]]];
// Calculate the contribution from the four corners, and add to total
for (int corner = 0; corner < 4; corner++)
for (uint corner = 0u; corner < 4u; corner++)
{
t = T(0.6) - c[corner].x * c[corner].x - c[corner].y * c[corner].y - c[corner].z * c[corner].z;
t = T(0.6) - Sqr(c[corner].x) - Sqr(c[corner].y) - Sqr(c[corner].z);
if (t > 0)
{
@@ -202,13 +202,12 @@ public:
/// <returns>T</returns>
T PerlinNoise3D(v3T& v, T aScale, T fScale, int octaves)
{
int i;
T n = 0, a = 1;
v3T u = v;
for (i = 0; i < octaves; i++)
for (int i = 0; i < octaves; i++)
{
n += SimplexNoise3D(u) / a;
n += SimplexNoise3D(u) / Zeps(a);
a *= aScale;
u.x *= fScale;
u.y *= fScale;
@@ -253,22 +252,20 @@ public:
{
v2T pmq = p - q;
if (pmq.x == 0 || pmq.y == 0)
if (pmq.x == 0 && pmq.y == 0)
return 1;
return 2 * ((u.x - q.x) * pmq.x + (u.y - q.y) * pmq.y) / (pmq.x * pmq.x + pmq.y * pmq.y);
return 2 * ((u.x - q.x) * pmq.x + (u.y - q.y) * pmq.y) / (SQR(pmq.x) + SQR(pmq.y));
}
/// <summary>
/// Unsure.
/// </summary>
static T Voronoi(v2T* p, int n, int q, v2T& u)
static T Voronoi(v2T* p, int n, int q, const v2T& u)
{
T ratio;
T ratiomax = TLOW;
int i;
T ratio, ratiomax = TLOW;
for (i = 0; i < n; i++)
for (int i = 0; i < n; i++)
{
if (i != q)
{
@@ -293,7 +290,7 @@ private:
m_P = InitInts();
m_Grad = InitGrad();
m_GlobalMap["NOISE_INDEX"] = make_pair(m_PFloats.data(), m_PFloats.size());
m_GlobalMap["NOISE_POINTS"] = make_pair(static_cast<T*>(&(m_Grad[0].x)), SizeOf(m_Grad) / sizeof(T));
m_GlobalMap["NOISE_POINTS"] = make_pair(static_cast<T*>(&(m_Grad[0].x)), SizeOf(m_Grad) / sizeof(T));
}
/// <summary>
+1 -1
View File
@@ -914,7 +914,7 @@ enum class eVariationId : et
VAR_POST_SINUS_GRID,
VAR_POST_SINUSOIDAL,
VAR_POST_SINUSOIDAL3D,
//VAR_POST_SMARTCROP,
VAR_POST_SMARTCROP,
VAR_POST_SPHERICAL,
VAR_POST_SPHERICAL3D,
VAR_POST_SPHERICALN,
+1
View File
@@ -342,6 +342,7 @@ public:
ADDPREPOSTREGVAR(BubbleT3D)
ADDPREPOSTREGVAR(Synth)
ADDPREPOSTREGVAR(Crackle)
m_Variations.push_back(new PostSmartcropVariation<T>());//Post only
//ADDPREPOSTREGVAR(LinearXZ)
//ADDPREPOSTREGVAR(LinearYZ)
//DC are special.
+12 -12
View File
@@ -1659,7 +1659,7 @@ public:
virtual void Precalc() override
{
m_Power = Zeps(m_Power);
m_Rn = fabs(m_Power);
m_Rn = std::abs(m_Power);
m_Cn = m_Dist / m_Power / 2;
}
@@ -1770,7 +1770,7 @@ public:
virtual void Precalc() override
{
m_Rn = fabs(m_Power);
m_Rn = std::abs(m_Power);
m_Cn = m_Dist / m_Power / 2;
}
@@ -2566,7 +2566,7 @@ public:
virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override
{
T r = m_Weight / Zeps(fabs((helper.In.x - helper.In.y) * (helper.In.x + helper.In.y)));
T r = m_Weight / Zeps(std::abs((helper.In.x - helper.In.y) * (helper.In.x + helper.In.y)));
helper.Out.x = helper.In.x * r;
helper.Out.y = helper.In.y * r;
helper.Out.z = m_Weight * helper.In.z;
@@ -2706,9 +2706,9 @@ public:
virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override
{
T theta = m_Pm4 * helper.m_PrecalcAtanyx + T(M_PI_4);
T t1 = fabs(std::cos(theta));
T t1 = std::abs(std::cos(theta));
t1 = std::pow(t1, m_N2);
T t2 = fabs(std::sin(theta));
T t2 = std::abs(std::sin(theta));
t2 = std::pow(t2, m_N3);
T r = m_Weight * ((m_Rnd * rand.Frand01<T>() + (1 - m_Rnd) * helper.m_PrecalcSqrtSumSquares) - m_Holes)
* std::pow(t1 + t2, m_PNeg1N1) / helper.m_PrecalcSqrtSumSquares;
@@ -3235,7 +3235,7 @@ public:
}
else
{
if (fabs(offsetX) >= fabs(offsetY))
if (std::abs(offsetX) >= std::abs(offsetY))
{
if (offsetX >= 0.0)
{
@@ -3332,7 +3332,7 @@ public:
{
T wx = m_Weight * T(1.3029400317411197908970256609023);//This precision came from the original.
T y2 = helper.In.y * 2;
T r = wx * std::sqrt(fabs(helper.In.y * helper.In.x) / Zeps(SQR(helper.In.x) + SQR(y2)));
T r = wx * std::sqrt(std::abs(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;
helper.Out.z = m_Weight * helper.In.z;
@@ -4263,9 +4263,9 @@ public:
if (m_Damping == 0.0)
t = m_Amplitude * std::cos(m_2PiFreq * helper.In.x) + m_Separation;
else
t = m_Amplitude * std::exp(-fabs(helper.In.x) * m_Damping) * std::cos(m_2PiFreq * helper.In.x) + m_Separation;
t = m_Amplitude * std::exp(-std::abs(helper.In.x) * m_Damping) * std::cos(m_2PiFreq * helper.In.x) + m_Separation;
if (fabs(helper.In.y) <= t)
if (std::abs(helper.In.y) <= t)
{
helper.Out.x = m_Weight * helper.In.x;
helper.Out.y = -(m_Weight * helper.In.y);
@@ -4984,7 +4984,7 @@ public:
virtual void Precalc() override
{
m_Cf = 1 - m_Angle * m_Count * T(M_1_PI) * T(0.5);
m_Rn = fabs(m_Power);
m_Rn = std::abs(m_Power);
m_Cn = m_Dist / m_Power / 2;
}
@@ -5835,8 +5835,8 @@ public:
{
T s = std::sin(m_Freq * helper.In.x);
T t = std::sin(m_Freq * helper.In.y);
T dy = helper.In.y + m_AugerWeight * (m_Scale * s / 2 + fabs(helper.In.y) * s);
T dx = helper.In.x + m_AugerWeight * (m_Scale * t / 2 + fabs(helper.In.x) * t);
T dy = helper.In.y + m_AugerWeight * (m_Scale * s / 2 + std::abs(helper.In.y) * s);
T dx = helper.In.x + m_AugerWeight * (m_Scale * t / 2 + std::abs(helper.In.x) * t);
helper.Out.x = m_Weight * (helper.In.x + m_Symmetry * (dx - helper.In.x));
helper.Out.y = m_Weight * dy;
helper.Out.z = m_Weight * helper.In.z;
File diff suppressed because it is too large Load Diff
+18 -18
View File
@@ -428,7 +428,7 @@ public:
}
else
{
T alpha = fabs(m_Radius / Zeps(helper.m_PrecalcSqrtSumSquares));//Original did not fabs().
T alpha = std::abs(m_Radius / Zeps(helper.m_PrecalcSqrtSumSquares));//Original did not std::abs().
if (rand.Frand01<T>() > m_Contrast * std::pow(alpha, m_Pow))
{
@@ -543,7 +543,7 @@ public:
T val = DEG_2_RAD_T * m_Phi1;
T sinPhi1 = std::sin(val);
T cosPhi1 = std::cos(val);
m_Pow = fabs(m_Pow);
m_Pow = std::abs(m_Pow);
m_X1 = m_Radius * cosPhi1;
m_Y1 = m_Radius * sinPhi1;
}
@@ -610,7 +610,7 @@ public:
}
else
{
T alpha = fabs(m_Radius / Zeps(helper.m_PrecalcSqrtSumSquares));//Original did not fabs().
T alpha = std::abs(m_Radius / Zeps(helper.m_PrecalcSqrtSumSquares));//Original did not std::abs().
if (rand.Frand01<T>() > m_Contrast * std::pow(alpha, m_Pow))
{
@@ -696,7 +696,7 @@ public:
virtual void Precalc() override
{
m_Pow = fabs(m_Pow);
m_Pow = std::abs(m_Pow);
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);
@@ -769,7 +769,7 @@ public:
}
else
{
T alpha = fabs(m_Radius / Zeps(helper.m_PrecalcSqrtSumSquares));//Original did not fabs().
T alpha = std::abs(m_Radius / Zeps(helper.m_PrecalcSqrtSumSquares));//Original did not std::abs().
if (rand.Frand01<T>() > m_Contrast * std::pow(alpha, m_Pow))
{
@@ -1108,7 +1108,7 @@ public:
virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override
{
T coeff = fabs(helper.In.z);
T coeff = std::abs(helper.In.z);
if (coeff != 0 && m_Power != 1)
coeff = std::exp(log(coeff) * m_Power);
@@ -1492,7 +1492,7 @@ public:
virtual void Precalc() override
{
m_AbsN = fabs(m_N);
m_AbsN = std::abs(m_N);
m_Cn = (1 / m_N - 1) / 2;
}
@@ -1565,7 +1565,7 @@ public:
virtual void Precalc() override
{
m_AbsN = fabs(m_N);
m_AbsN = std::abs(m_N);
m_Cn = 1 / m_N / 2;
}
@@ -1609,8 +1609,8 @@ public:
virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override
{
helper.Out.x = SignNz<T>(helper.In.x) * std::pow(fabs(helper.In.x), m_PowX) * m_Weight;
helper.Out.y = SignNz<T>(helper.In.y) * std::pow(fabs(helper.In.y), m_PowY) * m_Weight;
helper.Out.x = SignNz<T>(helper.In.x) * std::pow(std::abs(helper.In.x), m_PowX) * m_Weight;
helper.Out.y = SignNz<T>(helper.In.y) * std::pow(std::abs(helper.In.y), m_PowY) * m_Weight;
helper.Out.z = (m_VarType == eVariationType::VARTYPE_REG) ? 0 : helper.In.z;
}
@@ -1665,9 +1665,9 @@ public:
virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override
{
helper.Out.x = T(helper.In.x < 0 ? -1 : 1) * std::pow(fabs(helper.In.x), m_PowX) * m_Weight;
helper.Out.y = T(helper.In.y < 0 ? -1 : 1) * std::pow(fabs(helper.In.y), m_PowY) * m_Weight;
helper.Out.z = T(helper.In.z < 0 ? -1 : 1) * std::pow(fabs(helper.In.z), m_PowZ) * m_Weight;
helper.Out.x = T(helper.In.x < 0 ? -1 : 1) * std::pow(std::abs(helper.In.x), m_PowX) * m_Weight;
helper.Out.y = T(helper.In.y < 0 ? -1 : 1) * std::pow(std::abs(helper.In.y), m_PowY) * m_Weight;
helper.Out.z = T(helper.In.z < 0 ? -1 : 1) * std::pow(std::abs(helper.In.z), m_PowZ) * m_Weight;
}
virtual string OpenCLString() const override
@@ -2592,7 +2592,7 @@ public:
virtual void Precalc() override
{
if (fabs(m_Power) < 1)
if (std::abs(m_Power) < 1)
m_Power = 1;
}
@@ -2951,7 +2951,7 @@ public:
if (t < 0)
t -= m_SizeDiv2;
t = fmod(fabs(t), m_Size);
t = fmod(std::abs(t), m_Size);
if (t < m_SizeDiv2)
a += m_Even;
@@ -3556,15 +3556,15 @@ public:
{
T x, c2;
if (fabs(helper.In.y) <= m_Weight)
if (std::abs(helper.In.y) <= m_Weight)
{
c2 = std::sqrt(SQR(m_Weight) - SQR(helper.In.y));
if (fabs(helper.In.x) <= c2)
if (std::abs(helper.In.x) <= c2)
{
x = helper.In.x + m_Shift * m_Weight;
if (fabs(x) >= c2)
if (std::abs(x) >= c2)
helper.Out.x = -(m_Weight * helper.In.x);
else
helper.Out.x = m_Weight * x;
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+5 -5
View File
@@ -42,7 +42,7 @@ public:
T tempX = helper.Out.x + sumX;
T tempY = helper.Out.y + sumY;
outPoint.m_ColorX = fmod(fabs(m_Bdcs * (Sqr<T>(tempX + m_CenterX) + Sqr<T>(tempY + m_CenterY))), T(1.0));
outPoint.m_ColorX = fmod(std::abs(m_Bdcs * (Sqr<T>(tempX + m_CenterX) + Sqr<T>(tempY + m_CenterY))), T(1.0));
}
virtual string OpenCLString() const override
@@ -141,7 +141,7 @@ public:
helper.Out.x = m_Weight * (m_Xform->m_Affine.A() * x + m_Xform->m_Affine.B() * y + m_Xform->m_Affine.E());
helper.Out.y = m_Weight * (m_Xform->m_Affine.C() * x + m_Xform->m_Affine.D() * y + m_Xform->m_Affine.F());
helper.Out.z = (m_VarType == eVariationType::VARTYPE_REG) ? 0 : helper.In.z;
outPoint.m_ColorX = fmod(fabs(outPoint.m_ColorX * T(0.5) * (1 + h) + x0_xor_y0 * (1 - h) * T(0.5)), T(1.0));
outPoint.m_ColorX = fmod(std::abs(outPoint.m_ColorX * T(0.5) * (1 + h) + x0_xor_y0 * (1 - h) * T(0.5)), T(1.0));
}
virtual string OpenCLString() const override
@@ -415,7 +415,7 @@ public:
T tempX = helper.Out.x + sumX;
T tempY = helper.Out.y + sumY;
outPoint.m_ColorX = fmod(fabs(T(0.5) * (m_Ldcs * ((m_Cosa * tempX + m_Sina * tempY + m_Offset)) + 1)), T(1.0));
outPoint.m_ColorX = fmod(std::abs(T(0.5) * (m_Ldcs * ((m_Cosa * tempX + m_Sina * tempY + m_Offset)) + 1)), T(1.0));
}
virtual string OpenCLString() const override
@@ -715,7 +715,7 @@ public:
T tempX = helper.Out.x + sumX;
T tempY = helper.Out.y + sumY;
outPoint.m_ColorX = fmod(fabs(T(0.5) * (m_Ldcs * ((m_Cosa * tempX + m_Sina * tempY + m_Offset)) + T(1.0))), T(1.0));
outPoint.m_ColorX = fmod(std::abs(T(0.5) * (m_Ldcs * ((m_Cosa * tempX + m_Sina * tempY + m_Offset)) + T(1.0))), T(1.0));
}
virtual string OpenCLString() const override
@@ -885,7 +885,7 @@ public:
helper.Out.x = m_Weight * (ox + u * xx + v * yx);
helper.Out.y = m_Weight * (oy + u * xy + v * yy);
helper.Out.z = m_Weight * helper.In.z;
outPoint.m_ColorX = fmod(fabs(u + v), T(1.0));
outPoint.m_ColorX = fmod(std::abs(u + v), T(1.0));
}
virtual string OpenCLString() const override
+25 -1
View File
@@ -174,6 +174,17 @@ public:
m_BadParamNames["exponentZ"] = "bubbleT3D_exponentZ";
m_BadParamNames["_symmetryZ"] = "bubbleT3D_symmetryZ";
m_BadParamNames["_modusBlur"] = "bubbleT3D_modusBlur";
m_BadParamNames["post_scrop_power"] = "post_smartcrop_power";
m_BadParamNames["post_scrop_radius"] = "post_smartcrop_radius";
m_BadParamNames["post_scrop_roundstr"] = "post_smartcrop_roundstr";
m_BadParamNames["post_scrop_roundwidth"] = "post_smartcrop_roundwidth";
m_BadParamNames["post_scrop_distortion"] = "post_smartcrop_distortion";
m_BadParamNames["post_scrop_edge"] = "post_smartcrop_edge";
m_BadParamNames["post_scrop_scatter"] = "post_smartcrop_scatter";
m_BadParamNames["post_scrop_offset"] = "post_smartcrop_offset";
m_BadParamNames["post_scrop_rotation"] = "post_smartcrop_rotation";
m_BadParamNames["post_scrop_cropmode"] = "post_smartcrop_cropmode";
m_BadParamNames["post_scrop_static"] = "post_smartcrop_static";
m_FlattenNames.reserve(24);
m_FlattenNames.push_back("pre_crop");
m_FlattenNames.push_back("pre_falloff2");
@@ -201,7 +212,7 @@ public:
m_FlattenNames.push_back("curl3D_cz");
//This is a vector of the param names as they are in the legacy, badly named flam3/Apophysis code.
vector<string> badParams;
badParams.reserve(6);
badParams.reserve(11);
badParams.push_back("bwraps7_cellsize");
badParams.push_back("bwraps7_space");
badParams.push_back("bwraps7_gain");
@@ -245,6 +256,19 @@ public:
badParams.push_back("post_dcztransl_clamp");
m_BadVariationNames.push_back(make_pair(make_pair(string("post_dcztransl"), string("post_dc_ztransl")), badParams));
badParams.clear();
badParams.push_back("post_scrop_power");
badParams.push_back("post_scrop_radius");
badParams.push_back("post_scrop_roundstr");
badParams.push_back("post_scrop_roundwidth");
badParams.push_back("post_scrop_distortion");
badParams.push_back("post_scrop_edge");
badParams.push_back("post_scrop_scatter");
badParams.push_back("post_scrop_offset");
badParams.push_back("post_scrop_rotation");
badParams.push_back("post_scrop_cropmode");
badParams.push_back("post_scrop_static");
m_BadVariationNames.push_back(make_pair(make_pair(string("post_scrop"), string("post_smartcrop")), badParams));
badParams.clear();
m_BadVariationNames.push_back(make_pair(make_pair(string("pre_blur"), string("pre_gaussian_blur")), badParams));//No other special params for these.
m_BadVariationNames.push_back(make_pair(make_pair(string("pre_spin_z"), string("pre_rotate_z")), badParams));
m_BadVariationNames.push_back(make_pair(make_pair(string("post_spin_z"), string("post_rotate_z")), badParams));