mirror of
https://bitbucket.org/mfeemster/fractorium.git
synced 2025-02-01 18:40:12 -05:00
--Bug fixes:
-Qualify sqrt with std:: in Variations06.h
This commit is contained in:
parent
cdcbd409ab
commit
7269d2176a
@ -24,28 +24,23 @@ public:
|
||||
static const T AXhXo = T(1.0 / 3.0);
|
||||
static const T AXhYo = T(1.7320508075688772935 / 3.0);
|
||||
// Now: Xh = ( AXhXo * Xo + AXhYo * Yo ) / l;
|
||||
|
||||
// Yh = (-Xo + sqrt(3) * Yo) / (3 * l)
|
||||
static const T AYhXo = T(-1.0 / 3.0);
|
||||
static const T AYhYo = T(1.7320508075688772935 / 3.0);
|
||||
// Now: Yh = ( AYhXo * Xo + AYhYo * Yo ) / l;
|
||||
|
||||
// Xo = 3/2 * l * (Xh - Yh)
|
||||
static const T AXoXh = T(1.5);
|
||||
static const T AXoYh = T(-1.5);
|
||||
// Now: Xo = ( AXoXh * Xh + AXoYh * Yh ) * l;
|
||||
|
||||
// Yo = sqrt(3)/2 * l * (Xh + Yh)
|
||||
static const T AYoXh = T(1.7320508075688772935 / 2.0);
|
||||
static const T AYoYh = T(1.7320508075688772935 / 2.0);
|
||||
static const v2T offset[4] { { 0, 0 }, { 0, 1 }, { 1, 0 }, { 1, 1 } };
|
||||
|
||||
int i = 0;
|
||||
T di, dj;
|
||||
T XCh, YCh, XCo, YCo, DXo, DYo, L, L1, L2, R, s, trgL, Vx, Vy;
|
||||
v2T U;
|
||||
v2T P[7];
|
||||
|
||||
//For speed/convenience.
|
||||
s = m_Cellsize;
|
||||
|
||||
@ -56,7 +51,6 @@ public:
|
||||
//Get co-ordinates, and convert to hex co-ordinates.
|
||||
U.x = helper.In.x;
|
||||
U.y = helper.In.y;
|
||||
|
||||
XCh = T(Floor((AXhXo * U.x + AXhYo * U.y) / s));
|
||||
YCh = T(Floor((AYhXo * U.x + AYhYo * U.y) / s));
|
||||
|
||||
@ -72,22 +66,17 @@ public:
|
||||
}
|
||||
|
||||
int q = Closest(&P[0], 4, U);
|
||||
|
||||
//Remake list starting from chosen hex, ensure it is completely surrounded (total 7 points).
|
||||
|
||||
//First adjust centers according to which one was found to be closest.
|
||||
XCh += offset[q].x;
|
||||
YCh += offset[q].y;
|
||||
|
||||
//First point is central/closest.
|
||||
XCo = (AXoXh * XCh + AXoYh * YCh) * s;
|
||||
YCo = (AYoXh * XCh + AYoYh * YCh) * s;
|
||||
P[0].x = XCo;
|
||||
P[0].y = YCo;
|
||||
|
||||
//Next six points are based on hex graph (6 hexes around center). As long as
|
||||
//center points are not too distorted from simple hex, this defines all possible edges.
|
||||
|
||||
//In hex co-ords, offsets are: (0,1) (1,1) (1,0) (0,-1) (-1,-1) (-1, 0).
|
||||
P[1].x = XCo + (AXoYh) * s;
|
||||
P[1].y = YCo + (AYoYh) * s;
|
||||
@ -101,33 +90,24 @@ public:
|
||||
P[5].y = YCo - (AYoXh + AYoYh) * s;
|
||||
P[6].x = XCo - AXoXh * s;
|
||||
P[6].y = YCo - AYoXh * s;
|
||||
|
||||
L1 = Voronoi(&P[0], 7, 0, U);
|
||||
|
||||
//Delta vector from center of hex.
|
||||
DXo = U.x - P[0].x;
|
||||
DYo = U.y - P[0].y;
|
||||
|
||||
//Apply "interesting bit" to cell's DXo and DYo co-ordinates.
|
||||
|
||||
//trgL is the defined value of l, independent of any rotation.
|
||||
trgL = std::pow(Zeps(L1), m_Power) * m_Scale;//Original added 1e-100, use Zeps to be more precise.
|
||||
|
||||
//Rotate.
|
||||
Vx = DXo * m_RotCos + DYo * m_RotSin;
|
||||
Vy = -DXo * m_RotSin + DYo * m_RotCos;
|
||||
|
||||
//Measure voronoi distance again.
|
||||
U.x = Vx + P[0].x;
|
||||
U.y = Vy + P[0].y;
|
||||
L2 = Voronoi(&P[0], 7, 0, U);
|
||||
|
||||
//Scale to meet target size . . . adjust according to how close
|
||||
//we are to the edge.
|
||||
|
||||
//Code here attempts to remove the "rosette" effect caused by
|
||||
//scaling between.
|
||||
|
||||
//L is maximum of L1 or L2 . . .
|
||||
//When L = 0.8 or higher . . . match trgL/L2 exactly.
|
||||
//When L = T(0.5) or less . . . match trgL/L1 exactly.
|
||||
@ -147,11 +127,9 @@ public:
|
||||
|
||||
Vx *= R;
|
||||
Vy *= R;
|
||||
|
||||
//Add cell center co-ordinates back in.
|
||||
Vx += P[0].x;
|
||||
Vy += P[0].y;
|
||||
|
||||
//Finally add values in.
|
||||
helper.Out.x = m_Weight * Vx;
|
||||
helper.Out.y = m_Weight * Vy;
|
||||
@ -170,7 +148,6 @@ public:
|
||||
string scale = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
string rotsin = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
string rotcos = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
|
||||
ss << "\t{\n"
|
||||
<< "\t\tint i = 0;\n"
|
||||
<< "\t\treal_t di, dj;\n"
|
||||
@ -260,7 +237,6 @@ public:
|
||||
<< "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * Vy;\n"
|
||||
<< "\t\tvOut.z = " << ((m_VarType == VARTYPE_REG) ? "0" : "vIn.z") << ";\n"
|
||||
<< "\t}\n";
|
||||
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
@ -347,7 +323,6 @@ protected:
|
||||
void Init()
|
||||
{
|
||||
string prefix = Prefix();
|
||||
|
||||
m_Params.clear();
|
||||
m_Params.push_back(ParamWithName<T>(&m_Cellsize, prefix + "hexes_cellsize", 1));
|
||||
m_Params.push_back(ParamWithName<T>(&m_Power, prefix + "hexes_power", 1));
|
||||
@ -361,7 +336,6 @@ private:
|
||||
static T Vratio(v2T& p, v2T& q, v2T& u)
|
||||
{
|
||||
T pmQx, pmQy;
|
||||
|
||||
pmQx = p.x - q.x;
|
||||
pmQy = p.y - q.y;
|
||||
|
||||
@ -464,7 +438,6 @@ public:
|
||||
{
|
||||
T xTmp, yTmp;
|
||||
RandXyParams params;
|
||||
|
||||
params.NumEdges = m_NumEdges;
|
||||
params.RatioHole = m_RatioHole;
|
||||
params.CircumCircle = m_CircumCircle;
|
||||
@ -483,7 +456,6 @@ public:
|
||||
params.RatioComplement = m_RatioComplement;
|
||||
params.SpeedCalc1 = m_SpeedCalc1;
|
||||
params.SpeedCalc2 = m_SpeedCalc2;
|
||||
|
||||
RandXY(params, rand);
|
||||
|
||||
if ((m_ExactCalc == 1) && (m_CircumCircle == 0))
|
||||
@ -496,10 +468,8 @@ public:
|
||||
|
||||
xTmp = params.X;
|
||||
yTmp = params.Y;
|
||||
|
||||
params.X = m_Cosa * xTmp - m_Sina * yTmp;
|
||||
params.Y = m_Sina * xTmp + m_Cosa * yTmp;
|
||||
|
||||
helper.Out.x = m_AdjustedWeight * params.X;
|
||||
helper.Out.y = m_AdjustedWeight * params.Y;
|
||||
helper.Out.z = (m_VarType == VARTYPE_REG) ? 0 : helper.In.z;
|
||||
@ -536,7 +506,6 @@ public:
|
||||
string speedCalc1 = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
string speedCalc2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
string adjustedWeight = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
|
||||
ss << "\t{\n"
|
||||
<< "\t\treal_t xTmp, yTmp;\n"
|
||||
<< "\t\tRandXyParams params;\n"
|
||||
@ -580,7 +549,6 @@ public:
|
||||
<< "\t\tvOut.y = " << adjustedWeight << " * params.Y;\n"
|
||||
<< "\t\tvOut.z = " << ((m_VarType == VARTYPE_REG) ? "0" : "vIn.z") << ";\n"
|
||||
<< "\t}\n";
|
||||
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
@ -957,7 +925,6 @@ protected:
|
||||
void Init()
|
||||
{
|
||||
string prefix = Prefix();
|
||||
|
||||
m_Params.clear();
|
||||
m_Params.reserve(25);
|
||||
m_Params.push_back(ParamWithName<T>(&m_NumEdges, prefix + "nBlur_numEdges", 3, INTEGER));
|
||||
@ -1292,7 +1259,6 @@ public:
|
||||
{
|
||||
T rd = std::log(Sqr(r / m_TempRad));
|
||||
T phi = std::atan2(y, x);
|
||||
|
||||
tempOut.x = m_Weight * Lerp(x, phi, rd * m_Polarweight);
|
||||
tempOut.y = m_Weight * Lerp(y, r, rd * m_Polarweight);
|
||||
}
|
||||
@ -1360,7 +1326,6 @@ public:
|
||||
string jxStartIndex = ToUpper(m_Params[i].Name()) + stateIndex; i += 2;
|
||||
string kxStartIndex = ToUpper(m_Params[i].Name()) + stateIndex; i += 2;
|
||||
string lxStartIndex = ToUpper(m_Params[i].Name()) + stateIndex;
|
||||
|
||||
ss << "\t{\n"
|
||||
<< "\t\tbool clear = false;\n"
|
||||
<< "\t\treal_t x = vIn.x * 0.15, y = vIn.y * 0.15, z = vIn.z, r = 0, u = 0, v = 0, x2 = 0, y2 = 0;\n"
|
||||
@ -1428,7 +1393,6 @@ public:
|
||||
<< "\t\tvOut.y = tempOut.y + (xform->m_VariationWeights[" << varIndex << "] * y);\n"
|
||||
<< "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * z;\n"
|
||||
<< "\t}\n";
|
||||
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
@ -1486,12 +1450,10 @@ public:
|
||||
virtual void Precalc() override
|
||||
{
|
||||
static const T DENOM_SQRT2 = T(0.707106781);
|
||||
|
||||
m_AbsS = std::fabs(m_S);
|
||||
m_AbsT = std::fabs(m_T);
|
||||
m_St = m_AbsS * T(0.5) + m_AbsT;
|
||||
m_TempRad = DENOM_SQRT2 * m_AbsS * std::fabs(m_Radius);
|
||||
|
||||
m_A = { -T(0.5)* m_AbsS, T(0.5)* m_AbsS + m_AbsT };
|
||||
m_B = { T(0.5)* m_AbsS, T(0.5)* m_AbsS + m_AbsT };
|
||||
m_C = { m_AbsT, T(0.5)* m_AbsS };
|
||||
@ -1510,7 +1472,6 @@ protected:
|
||||
void Init()
|
||||
{
|
||||
string prefix = Prefix();
|
||||
|
||||
m_Params.clear();
|
||||
m_Params.push_back(ParamWithName<T>(&m_Polarweight, prefix + "octapol_polarweight"));
|
||||
m_Params.push_back(ParamWithName<T>(&m_Radius, prefix + "octapol_radius", 1));
|
||||
@ -1562,7 +1523,7 @@ private:
|
||||
if (radius == 0)
|
||||
return 1;
|
||||
|
||||
r = sqrt(SQR(p.x) + SQR(p.y));
|
||||
r = std::sqrt(SQR(p.x) + SQR(p.y));
|
||||
return (r <= radius);
|
||||
}
|
||||
|
||||
@ -1660,7 +1621,8 @@ public:
|
||||
{
|
||||
yTmp = m_Top + rand.Frand01<T>() * m_YInt2;
|
||||
xTmp = m_Right - pow(rand.Frand01<T>(), m_DirectBlur) * m_RatioBlur * m_MinInt2;
|
||||
} while ((yTmp - m_Y0c) / (xTmp - m_X0c) < -1);
|
||||
}
|
||||
while ((yTmp - m_Y0c) / (xTmp - m_X0c) < -1);
|
||||
|
||||
if (secTmp < m_SetProbH)
|
||||
xTmp = m_Left + m_Right - xTmp;
|
||||
@ -1675,7 +1637,8 @@ public:
|
||||
xTmp = m_Right - rand.Frand01<T>() * m_XInt2;
|
||||
yTmp = m_Top + std::pow(rand.Frand01<T>(), m_DirectBlur) * m_RatioBlur * m_MinInt2;
|
||||
gradTmp = (yTmp - m_Y0c) / (xTmp - m_X0c);
|
||||
} while ((gradTmp <= 0) && (gradTmp > -1));
|
||||
}
|
||||
while ((gradTmp <= 0) && (gradTmp > -1));
|
||||
|
||||
if (secTmp > m_SetProbH)
|
||||
yTmp = m_Bottom + m_Top - yTmp;
|
||||
@ -1755,7 +1718,6 @@ public:
|
||||
string bottomBorder = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
string leftBorder = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
string rightBorder = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
|
||||
ss << "\t{\n"
|
||||
<< "\t\treal_t gradTmp, secTmp, xTmp, yTmp;\n"
|
||||
<< "\n"
|
||||
@ -1866,7 +1828,6 @@ public:
|
||||
ss
|
||||
<< "\t\tvOut.z = " << ((m_VarType == VARTYPE_REG) ? "0" : "vIn.z") << ";\n"
|
||||
<< "\t}\n";
|
||||
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
@ -1954,9 +1915,7 @@ protected:
|
||||
void Init()
|
||||
{
|
||||
string prefix = Prefix();
|
||||
|
||||
m_Params.clear();
|
||||
|
||||
m_Params.push_back(ParamWithName<T>(&m_Top, prefix + "crob_top", -1));
|
||||
m_Params.push_back(ParamWithName<T>(&m_Bottom, prefix + "crob_bottom", 1));
|
||||
m_Params.push_back(ParamWithName<T>(&m_Left, prefix + "crob_left", -1));
|
||||
@ -2039,7 +1998,6 @@ public:
|
||||
T rad = helper.m_PrecalcSumSquares / 4 + 1;
|
||||
T angXY, angZ;
|
||||
T c, s;
|
||||
|
||||
angXY = std::atan2(x, y);
|
||||
|
||||
if (angXY < 0)
|
||||
@ -2220,7 +2178,6 @@ public:
|
||||
intmax_t i = 0, varIndex = IndexInXform();
|
||||
ss2 << "_" << XformIndexInEmber();
|
||||
string index = ss2.str() + "]";
|
||||
|
||||
string numberStripes = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
string ratioStripes = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
string angleHole = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
@ -2237,7 +2194,6 @@ public:
|
||||
string invHole = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
string c = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
string s = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
|
||||
ss << "\t{\n"
|
||||
"\t\treal_t x = vIn.x, y = vIn.y, z = vIn.z;\n"
|
||||
"\t\treal_t xTmp, yTmp, angTmp, angRot, fac;\n"
|
||||
@ -2418,7 +2374,6 @@ public:
|
||||
"\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * y;\n"
|
||||
"\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * z;\n"
|
||||
"\t}\n";
|
||||
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
@ -2480,7 +2435,6 @@ protected:
|
||||
void Init()
|
||||
{
|
||||
string prefix = Prefix();
|
||||
|
||||
m_Params.clear();
|
||||
m_Params.reserve(14);
|
||||
m_Params.push_back(ParamWithName<T>(&m_NumberStripes, prefix + "bubbleT3D_number_of_stripes", 0, INTEGER));
|
||||
@ -2499,7 +2453,6 @@ protected:
|
||||
m_Params.push_back(ParamWithName<T>(true, &m_InvHole, prefix + "bubbleT3D_inv_hole"));
|
||||
m_Params.push_back(ParamWithName<T>(true, &m_C, prefix + "bubbleT3D_c"));
|
||||
m_Params.push_back(ParamWithName<T>(true, &m_S, prefix + "bubbleT3D_s"));
|
||||
|
||||
}
|
||||
|
||||
private:
|
||||
@ -2599,7 +2552,6 @@ public:
|
||||
T s, c, mu; // Handy temp variables, s & c => sine & cosine, mu = generic temp param
|
||||
int synthMode = int(m_SynthMode);
|
||||
SynthStruct synth;
|
||||
|
||||
synth.SynthA = m_SynthA;
|
||||
synth.SynthB = m_SynthB;
|
||||
synth.SynthBPhs = m_SynthBPhs;
|
||||
@ -2640,13 +2592,11 @@ public:
|
||||
Vx = helper.In.x;
|
||||
Vy = helper.In.y;
|
||||
radius = std::pow(Zeps<T>(helper.m_PrecalcSumSquares), (m_SynthPower + 1) / 2);
|
||||
|
||||
// Get angle and angular factor
|
||||
theta = helper.m_PrecalcAtanxy;
|
||||
thetaFactor = SynthValue(synth, theta);
|
||||
radius = Interpolate(radius, thetaFactor, synthMode);
|
||||
sincos(theta, &s, &c);
|
||||
|
||||
// Write to running totals for transform
|
||||
helper.Out.x = m_Weight * radius * s;
|
||||
helper.Out.y = m_Weight * radius * c;
|
||||
@ -2657,13 +2607,11 @@ public:
|
||||
Vx = helper.In.x;
|
||||
Vy = helper.In.y;
|
||||
radius = helper.m_PrecalcSqrtSumSquares / (helper.m_PrecalcSumSquares / 4 + 1);
|
||||
|
||||
// Get angle and angular factor
|
||||
theta = helper.m_PrecalcAtanxy;
|
||||
thetaFactor = SynthValue(synth, theta);
|
||||
radius = Interpolate(radius, thetaFactor, synthMode);
|
||||
sincos(theta, &s, &c);
|
||||
|
||||
// Write to running totals for transform
|
||||
helper.Out.x = m_Weight * radius * s;
|
||||
helper.Out.y = m_Weight * radius * c;
|
||||
@ -2676,11 +2624,9 @@ public:
|
||||
Vx = radius * std::sin(theta);
|
||||
Vy = radius * std::cos(theta);
|
||||
radius = std::pow(Zeps<T>(radius * radius), m_SynthPower / 2);
|
||||
|
||||
// Get angle and angular factor
|
||||
thetaFactor = SynthValue(synth, theta);
|
||||
radius = m_Weight * Interpolate(radius, thetaFactor, synthMode);
|
||||
|
||||
// Write back to running totals for new vector
|
||||
helper.Out.x = Vx * radius;
|
||||
helper.Out.y = Vy * radius;
|
||||
@ -2692,14 +2638,11 @@ public:
|
||||
radius = T(0.5) * (rand.Frand01<T>() + rand.Frand01<T>());
|
||||
theta = M_2PI * rand.Frand01<T>() - T(M_PI);
|
||||
radius = std::pow(Zeps<T>(SQR(radius)), -m_SynthPower / 2);
|
||||
|
||||
// Get angular factor defining the shape
|
||||
thetaFactor = SynthValue(synth, theta);
|
||||
|
||||
// Get final radius after synth applied
|
||||
radius = Interpolate(radius, thetaFactor, synthMode);
|
||||
sincos(theta, &s, &c);
|
||||
|
||||
// Write to running totals for transform
|
||||
helper.Out.x = m_Weight * radius * s;
|
||||
helper.Out.y = m_Weight * radius * c;
|
||||
@ -2711,13 +2654,10 @@ public:
|
||||
// Vy is y value
|
||||
Vy = 1 + T(0.1) * (rand.Frand01<T>() + rand.Frand01<T>() - 1) * m_SynthPower;
|
||||
theta = 2 * std::asin((rand.Frand01<T>() - T(0.5)) * 2);
|
||||
|
||||
// Get angular factor defining the shape
|
||||
thetaFactor = SynthValue(synth, theta);
|
||||
|
||||
// Get new location
|
||||
Vy = Interpolate(Vy, thetaFactor, synthMode);
|
||||
|
||||
// Write to running totals for transform
|
||||
helper.Out.x = m_Weight * (theta / T(M_PI));
|
||||
helper.Out.y = m_Weight * (Vy - 1);
|
||||
@ -2727,12 +2667,10 @@ public:
|
||||
// Get current radius and angle
|
||||
radius = helper.m_PrecalcSqrtSumSquares;
|
||||
theta = helper.m_PrecalcAtanxy;
|
||||
|
||||
// Calculate new radius
|
||||
thetaFactor = SynthValue(synth, theta);
|
||||
radius = Interpolate(radius, thetaFactor, synthMode);
|
||||
sincos(theta, &s, &c);
|
||||
|
||||
// Write to running totals for transform
|
||||
helper.Out.x = m_Weight * radius * s;
|
||||
helper.Out.y = m_Weight * radius * c;
|
||||
@ -2742,10 +2680,8 @@ public:
|
||||
// Use x and y values directly
|
||||
Vx = helper.In.x;
|
||||
Vy = helper.In.y;
|
||||
|
||||
// x value will be mapped according to synth(y) value
|
||||
thetaFactor = SynthValue(synth, Vy);
|
||||
|
||||
// Write to running totals for transform
|
||||
helper.Out.x = m_Weight * Interpolate(Vx, thetaFactor, synthMode);
|
||||
helper.Out.y = m_Weight * Vy;
|
||||
@ -2755,10 +2691,8 @@ public:
|
||||
// Use x and y values directly
|
||||
Vx = helper.In.x;
|
||||
Vy = helper.In.y;
|
||||
|
||||
// y value will be mapped according to synth(x) value
|
||||
thetaFactor = SynthValue(synth, Vx);
|
||||
|
||||
// Write to running totals for transform
|
||||
helper.Out.x = m_Weight * Vx;
|
||||
helper.Out.y = m_Weight * Interpolate(Vy, thetaFactor, synthMode);
|
||||
@ -2768,11 +2702,9 @@ public:
|
||||
// Use x and y values directly
|
||||
Vx = helper.In.x;
|
||||
Vy = helper.In.y;
|
||||
|
||||
// x value will be mapped according to synth(y) value
|
||||
thetaFactor = SynthValue(synth, Vy);
|
||||
helper.Out.x = m_Weight * Interpolate(Vx, thetaFactor, synthMode);
|
||||
|
||||
// y value will be mapped according to synth(x) value
|
||||
thetaFactor = SynthValue(synth, Vx);
|
||||
helper.Out.y = m_Weight * Interpolate(Vy, thetaFactor, synthMode);
|
||||
@ -2782,7 +2714,6 @@ public:
|
||||
// Use x and y values directly
|
||||
Vx = helper.In.x;
|
||||
Vy = helper.In.y;
|
||||
|
||||
// Write to running totals for transform
|
||||
helper.Out.x = m_Weight * (Vx + SynthValue(synth, Vy) - 1);
|
||||
helper.Out.y = m_Weight * Vy;
|
||||
@ -2792,7 +2723,6 @@ public:
|
||||
// Use x and y values directly
|
||||
Vx = helper.In.x;
|
||||
Vy = helper.In.y;
|
||||
|
||||
// Write to running totals for transform
|
||||
helper.Out.x = m_Weight * Vx;
|
||||
helper.Out.y = m_Weight * (Vy + SynthValue(synth, Vx) - 1);
|
||||
@ -2802,7 +2732,6 @@ public:
|
||||
// Use x and y values directly
|
||||
Vx = helper.In.x;
|
||||
Vy = helper.In.y;
|
||||
|
||||
// Write to running totals for transform
|
||||
helper.Out.x = m_Weight * (Vx + SynthValue(synth, Vy) - 1);
|
||||
helper.Out.y = m_Weight * (Vy + SynthValue(synth, Vx) - 1);
|
||||
@ -2811,7 +2740,6 @@ public:
|
||||
case MODE_SINUSOIDAL: // Power NO, Smooth NO
|
||||
Vx = helper.In.x;
|
||||
Vy = helper.In.y;
|
||||
|
||||
// The default mix=0 is same as normal sin
|
||||
helper.Out.x = m_Weight * (SynthValue(synth, Vx) - 1 + (1 - m_SynthMix) * std::sin(Vx));
|
||||
helper.Out.y = m_Weight * (SynthValue(synth, Vy) - 1 + (1 - m_SynthMix) * std::sin(Vy));
|
||||
@ -2820,12 +2748,9 @@ public:
|
||||
case MODE_SWIRL: // Power YES, Smooth WAVE
|
||||
Vx = helper.In.x;
|
||||
Vy = helper.In.y;
|
||||
|
||||
radius = std::pow(Zeps<T>(helper.m_PrecalcSumSquares), m_SynthPower / 2);
|
||||
|
||||
// Synth-modified sine & cosine
|
||||
SynthSinCos(synth, radius, s, c, synthMode);
|
||||
|
||||
helper.Out.x = m_Weight * (s * Vx - c * Vy);
|
||||
helper.Out.y = m_Weight * (c * Vx + s * Vy);
|
||||
break;
|
||||
@ -2833,13 +2758,10 @@ public:
|
||||
case MODE_HYPERBOLIC: // Power YES, Smooth WAVE
|
||||
Vx = helper.In.x;
|
||||
Vy = helper.In.y;
|
||||
|
||||
radius = std::pow(Zeps<T>(helper.m_PrecalcSumSquares), m_SynthPower / 2);
|
||||
theta = helper.m_PrecalcAtanxy;
|
||||
|
||||
// Synth-modified sine & cosine
|
||||
SynthSinCos(synth, theta, s, c, synthMode);
|
||||
|
||||
helper.Out.x = m_Weight * s / radius;
|
||||
helper.Out.y = m_Weight * c * radius;
|
||||
break;
|
||||
@ -2847,7 +2769,6 @@ public:
|
||||
case MODE_JULIA: // Power YES, Smooth WAVE
|
||||
Vx = helper.In.x;
|
||||
Vy = helper.In.y;
|
||||
|
||||
radius = std::pow(Zeps<T>(helper.m_PrecalcSumSquares), m_SynthPower / 4);
|
||||
theta = helper.m_PrecalcAtanxy / 2;
|
||||
|
||||
@ -2856,7 +2777,6 @@ public:
|
||||
|
||||
// Synth-modified sine & cosine
|
||||
SynthSinCos(synth, theta, s, c, synthMode);
|
||||
|
||||
helper.Out.x = m_Weight * radius * c;
|
||||
helper.Out.y = m_Weight * radius * s;
|
||||
break;
|
||||
@ -2864,13 +2784,10 @@ public:
|
||||
case MODE_DISC: // Power YES, Smooth WAVE
|
||||
Vx = helper.In.x;
|
||||
Vy = helper.In.y;
|
||||
|
||||
theta = helper.m_PrecalcAtanxy / T(M_PI);
|
||||
radius = T(M_PI) * std::pow(Zeps<T>(helper.m_PrecalcSumSquares), m_SynthPower / 2);
|
||||
|
||||
// Synth-modified sine & cosine
|
||||
SynthSinCos(synth, radius, s, c, synthMode);
|
||||
|
||||
helper.Out.x = m_Weight * s * theta;
|
||||
helper.Out.y = m_Weight * c * theta;
|
||||
break;
|
||||
@ -2882,9 +2799,7 @@ public:
|
||||
theta = helper.m_PrecalcAtanxy;
|
||||
mu = Zeps<T>(SQR(m_SynthPower));
|
||||
radius += -2 * mu * int((radius + mu) / (2 * mu)) + radius * (1 - mu);
|
||||
|
||||
SynthSinCos(synth, radius, s, c, synthMode);
|
||||
|
||||
helper.Out.x = m_Weight * s * theta;
|
||||
helper.Out.y = m_Weight * c * theta;
|
||||
break;
|
||||
@ -2893,27 +2808,21 @@ public:
|
||||
Vx = helper.In.x;
|
||||
Vy = helper.In.y;
|
||||
radius = std::pow(Zeps<T>(helper.m_PrecalcSumSquares), m_SynthPower / 2);
|
||||
|
||||
// Modified sine only used here
|
||||
SynthSinCos(synth, Vx, s, c, synthMode);
|
||||
|
||||
helper.Out.x = m_Weight * radius * s;
|
||||
helper.Out.y = m_Weight * radius * Vy;
|
||||
break;
|
||||
|
||||
case MODE_BLUR_RING: // Power YES, Smooth YES
|
||||
// Blur style, with normal smoothing function
|
||||
|
||||
radius = 1 + T(0.1) * (rand.Frand01<T>() + rand.Frand01<T>() - 1) * m_SynthPower;
|
||||
theta = M_2PI * rand.Frand01<T>() - T(M_PI);
|
||||
|
||||
// Get angular factor defining the shape
|
||||
thetaFactor = SynthValue(synth, theta);
|
||||
|
||||
// Get final radius after synth applied
|
||||
radius = Interpolate(radius, thetaFactor, synthMode);
|
||||
sincos(theta, &s, &c);
|
||||
|
||||
// Write to running totals for transform
|
||||
helper.Out.x = m_Weight * radius * s;
|
||||
helper.Out.y = m_Weight * radius * c;
|
||||
@ -2921,15 +2830,12 @@ public:
|
||||
|
||||
case MODE_BLUR_RING2: // Power YES, Smooth NO
|
||||
// Simple, same-thickness ring
|
||||
|
||||
// Choose radius randomly, then adjust distribution using pow
|
||||
theta = M_2PI * rand.Frand01<T>() - T(M_PI);
|
||||
radius = std::pow(Zeps<T>(rand.Frand01<T>()), m_SynthPower);
|
||||
|
||||
// Get final radius after synth applied
|
||||
radius = SynthValue(synth, theta) + T(0.1) * radius;
|
||||
sincos(theta, &s, &c);
|
||||
|
||||
// Write to running totals for transform
|
||||
helper.Out.x = m_Weight * radius * s;
|
||||
helper.Out.y = m_Weight * radius * c;
|
||||
@ -2940,11 +2846,9 @@ public:
|
||||
// Use (adjusted) radius to move point around circle
|
||||
Vx = helper.In.x;
|
||||
Vy = helper.In.y;
|
||||
|
||||
radius = std::pow(Zeps<T>(helper.m_PrecalcSumSquares), m_SynthPower / 2);
|
||||
theta = helper.m_PrecalcAtanxy - 1 + SynthValue(synth, radius);
|
||||
sincos(theta, &s, &c);
|
||||
|
||||
// Write to running totals for transform
|
||||
helper.Out.x = m_Weight * radius * s;
|
||||
helper.Out.y = m_Weight * radius * c;
|
||||
@ -2960,7 +2864,6 @@ public:
|
||||
intmax_t i = 0, varIndex = IndexInXform();
|
||||
ss2 << "_" << XformIndexInEmber();
|
||||
string index = ss2.str() + "]";
|
||||
|
||||
string synthA = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
string synthMode = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
string synthPower = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
@ -2996,7 +2899,6 @@ public:
|
||||
string synthFFrq = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
string synthFPhs = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
string synthFLayer = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
|
||||
ss << "\t{\n"
|
||||
<< "\t\treal_t Vx, Vy, radius, theta;\n"
|
||||
<< "\t\treal_t thetaFactor;\n"
|
||||
@ -3254,7 +3156,6 @@ public:
|
||||
<< "\n"
|
||||
<< "\t\tvOut.z = " << ((m_VarType == VARTYPE_REG) ? "0" : "vIn.z") << ";\n"
|
||||
<< "\t}\n";
|
||||
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
@ -3516,7 +3417,6 @@ protected:
|
||||
void Init()
|
||||
{
|
||||
string prefix = Prefix();
|
||||
|
||||
m_Params.clear();
|
||||
m_Params.reserve(34);
|
||||
m_Params.push_back(ParamWithName<T>(&m_SynthA, prefix + "synth_a"));
|
||||
@ -3617,29 +3517,37 @@ private:
|
||||
case WAVE_SIN:
|
||||
x = std::sin(y * M_2PI);
|
||||
break;
|
||||
|
||||
case WAVE_COS:
|
||||
x = std::cos(y * M_2PI);
|
||||
break;
|
||||
|
||||
case WAVE_SQUARE:
|
||||
x = y > T(0.5) ? T(1) : T(-1);
|
||||
break;
|
||||
|
||||
case WAVE_SAW:
|
||||
x = 1 - 2 * y;
|
||||
break;
|
||||
|
||||
case WAVE_TRIANGLE:
|
||||
x = y > T(0.5) ? 3 - 4 * y : 2 * y - 1;
|
||||
break;
|
||||
|
||||
case WAVE_CONCAVE:
|
||||
x = 8 * (y - T(0.5)) * (y - T(0.5)) - 1;
|
||||
break;
|
||||
|
||||
case WAVE_CONVEX:
|
||||
x = 2 * std::sqrt(y) - 1;
|
||||
break;
|
||||
|
||||
case WAVE_NGON:
|
||||
y -= T(0.5);
|
||||
y *= M_2PI / frq;
|
||||
x = 1 / Zeps<T>(std::cos(y)) - 1;
|
||||
break;
|
||||
|
||||
default:
|
||||
case WAVE_INGON:
|
||||
y -= T(0.5);
|
||||
@ -3654,13 +3562,16 @@ private:
|
||||
case LAYER_ADD:
|
||||
thetaFactor += synth * x;
|
||||
break;
|
||||
|
||||
case LAYER_MULT:
|
||||
thetaFactor *= (1 + synth * x);
|
||||
break;
|
||||
|
||||
case LAYER_MAX:
|
||||
z = synthA + synth * x;
|
||||
thetaFactor = (thetaFactor > z ? thetaFactor : z);
|
||||
break;
|
||||
|
||||
default:
|
||||
case LAYER_MIN:
|
||||
z = synthA + synth * x;
|
||||
@ -3674,13 +3585,11 @@ private:
|
||||
{
|
||||
T x, y, z;
|
||||
T thetaFactor = s.SynthA;
|
||||
|
||||
SynthValueProc(s.SynthA, thetaFactor, theta, s.SynthB, s.SynthBPhs, s.SynthBFrq, s.SynthBSkew, x, y, z, s.SynthBType, s.SynthBLayer);
|
||||
SynthValueProc(s.SynthA, thetaFactor, theta, s.SynthC, s.SynthCPhs, s.SynthCFrq, s.SynthCSkew, x, y, z, s.SynthCType, s.SynthCLayer);
|
||||
SynthValueProc(s.SynthA, thetaFactor, theta, s.SynthD, s.SynthDPhs, s.SynthDFrq, s.SynthDSkew, x, y, z, s.SynthDType, s.SynthDLayer);
|
||||
SynthValueProc(s.SynthA, thetaFactor, theta, s.SynthE, s.SynthEPhs, s.SynthEFrq, s.SynthESkew, x, y, z, s.SynthEType, s.SynthELayer);
|
||||
SynthValueProc(s.SynthA, thetaFactor, theta, s.SynthF, s.SynthFPhs, s.SynthFFrq, s.SynthFSkew, x, y, z, s.SynthFType, s.SynthFLayer);
|
||||
|
||||
// Mix is applied here, assuming 1.0 to be the "flat" line for legacy support
|
||||
return thetaFactor * s.SynthMix + (1 - s.SynthMix);
|
||||
}
|
||||
@ -3692,6 +3601,7 @@ private:
|
||||
|
||||
// Simply reflect in the y axis for negative values
|
||||
if (m < 0) { m = -m; a = -1; }
|
||||
|
||||
if (x < 0) { x = -x; a = -a; }
|
||||
|
||||
// iM is "inverse m" used in a few places below
|
||||
@ -3714,11 +3624,10 @@ private:
|
||||
// Bezier Curve #1
|
||||
// Covers 0 <= $m <= 1.0, 0 <= $x <= 1.0
|
||||
// Control points are (0,0), (m,m) and (1,m)
|
||||
|
||||
t = x; // Special case when m == 0.5
|
||||
|
||||
if (std::fabs(m - T(0.5)) > 1e-10)
|
||||
t = (-1 * m + sqrt(m * m + (1 - 2 * m) * x)) / (1 - 2 * m);
|
||||
t = (-1 * m + std::sqrt(m * m + (1 - 2 * m) * x)) / (1 - 2 * m);
|
||||
|
||||
return a * (x + (m - 1) * t * t);
|
||||
}
|
||||
@ -3728,11 +3637,10 @@ private:
|
||||
// Bezier Curve #2
|
||||
// Covers m >= 1.0, 0 <= x <= 1.0
|
||||
// Control points are (0,0), (iM,iM) and (1,m)
|
||||
|
||||
t = x; // Special case when m == 2
|
||||
|
||||
if (std::fabs(m - 2) > 1e-10)
|
||||
t = (-1 * iM + sqrt(iM * iM + (1 - 2 * iM) * x)) / (1 - 2 * iM);
|
||||
t = (-1 * iM + std::sqrt(iM * iM + (1 - 2 * iM) * x)) / (1 - 2 * iM);
|
||||
|
||||
return a * (x + (m - 1) * t * t);
|
||||
}
|
||||
@ -3743,7 +3651,6 @@ private:
|
||||
// Covers 0 <= m <= 1.0, 1 <= x <= L
|
||||
// Control points are (1,m), (1,1) and (L,L)
|
||||
// (L is x value (>1) where we re-join y = x line, and is maximum( iM, 2 * m )
|
||||
|
||||
t = std::sqrt((x - 1) / (L - 1));
|
||||
return a * (x + (m - 1) * t * t + 2 * (1 - m) * t + (m - 1));
|
||||
}
|
||||
@ -3752,7 +3659,6 @@ private:
|
||||
// Covers 1.0 <= m, 1 <= x <= L
|
||||
// Control points are (1,m), (m,m) and (L,L)
|
||||
// (L is x value (>1) where we re-join y = x line, and is maximum( iM, 2 * m )
|
||||
|
||||
t = (1 - m) + std::sqrt((m - 1) * (m - 1) + (x - 1));
|
||||
return a * (x + (m - 1) * t * t - 2 * (m - 1) * t + (m - 1));
|
||||
}
|
||||
@ -3763,6 +3669,7 @@ private:
|
||||
{
|
||||
case LERP_LINEAR:
|
||||
return x * m;
|
||||
|
||||
default:
|
||||
case LERP_BEZIER:
|
||||
return BezierQuadMap(x, m);
|
||||
@ -3781,6 +3688,7 @@ private:
|
||||
s = s * SynthValue(synth, theta);
|
||||
c = c * SynthValue(synth, theta + T(M_PI) / 2);
|
||||
break;
|
||||
|
||||
default:
|
||||
case SINCOS_MIXIN:
|
||||
s = (1 - m_SynthMix) * s + (SynthValue(synth, theta) - 1);
|
||||
|
Loading…
Reference in New Issue
Block a user