--User changes

-Update various tooltips.
 -Increase precision of affine and xaos spinners.
 -Increase precision of fields written in Xml files to 8.

--Bug fixes
 -When rendering on the CPU, if the number of threads didn't divide evenly into the number of rows, it would leave a blank spot on the last few rows.
 -Fix numerous parsing bugs when reading .chaos files.
 -Added compatibility fixes and/or optimizations to the following variations: asteria, bcircle, bcollide, bipolar, blob2, btransform, cell, circlecrop, circlecrop2, collideoscope, cpow2, cropn, cross, curl, depth_ngon2, depth_sine2, edisc, eRotate, escher, fan2, hex_rand, hypershift, hypershift2, hypertile1, julia, julian, julian2, juliaq, juliascope, lazyjess, log, loonie2, murl, murl2, npolar, oscilloscope2, perspective, phoenix_julia, sphericaln, squish, starblur, starblur2, truchet, truchet_glyph, waffle, wavesn.
This commit is contained in:
Person 2023-11-29 15:47:31 -07:00
parent b3ad38020e
commit c3078f018a
23 changed files with 1873 additions and 1076 deletions

View File

@ -12,7 +12,7 @@
<!-- <!--
Change this for every release. Change this for every release.
--> -->
<?define ProductCode="{C4B772EF-F8FE-4327-9CE7-22308F363E69}"?> <?define ProductCode="{BAB35746-A149-483E-B3F8-A5FE73E8D407}"?>
<Package Name="$(var.ProductName)" Language="1033" Version="$(var.ProductVersion)" Manufacturer="$(var.Manufacturer)" UpgradeCode="$(var.UpgradeCode)" InstallerVersion="400" Scope="perMachine" ProductCode="$(var.ProductCode)"> <Package Name="$(var.ProductName)" Language="1033" Version="$(var.ProductVersion)" Manufacturer="$(var.Manufacturer)" UpgradeCode="$(var.UpgradeCode)" InstallerVersion="400" Scope="perMachine" ProductCode="$(var.ProductCode)">
<SummaryInformation Keywords="Installer" Description="$(var.Manufacturer)" Manufacturer="$(var.Manufacturer)" /> <SummaryInformation Keywords="Installer" Description="$(var.Manufacturer)" Manufacturer="$(var.Manufacturer)" />

View File

@ -22,14 +22,14 @@ static void parallel_for(size_t start, size_t end, size_t parlevel, std::functio
for (size_t i = 0; i < ct; i++) for (size_t i = 0; i < ct; i++)
{ {
threads.push_back(std::thread([&, i] threads.push_back(std::thread([&](size_t _i, size_t _ct)
{ {
const auto chunkStart = chunkSize* i; const auto chunkStart = chunkSize * _i;
const auto chunkEnd = std::min(chunkStart + chunkSize, end); const auto chunkEnd = _i == _ct - 1 ? end : std::min(chunkStart + chunkSize, end);
for (size_t j = chunkStart; j < chunkEnd; j++) for (size_t j = chunkStart; j < chunkEnd; j++)
func(j); func(j);
})); }, i, ct));
} }
EmberNs::Join(threads); EmberNs::Join(threads);

View File

@ -41,7 +41,7 @@
#include <list> #include <list>
#ifdef __APPLE__ #ifdef __APPLE__
#include <malloc/malloc.h> #include <malloc/malloc.h>
#include <sys/sysctl.h> #include <sys/sysctl.h>
#else #else
#include <malloc.h> #include <malloc.h>
#endif #endif

View File

@ -502,6 +502,7 @@ string EmberToXml<T>::ToString(Xform<T>& xform, size_t xformCount, bool isFinal,
{ {
size_t i, j; size_t i, j;
ostringstream os; ostringstream os;
os << std::fixed << std::setprecision(8);
if (doMotion) if (doMotion)
{ {

View File

@ -224,7 +224,7 @@ public:
#ifdef ISAAC_FLAM3_DEBUG #ifdef ISAAC_FLAM3_DEBUG
return (Rand() & 0xfffffff) / (floatType)0xfffffff; return (Rand() & 0xfffffff) / (floatType)0xfffffff;
#else #else
return Frand<floatType>(static_cast<floatType>(0), static_cast<floatType>(1)); return static_cast<floatType>(Rand()) / static_cast<floatType>(std::numeric_limits<T>::max());
#endif #endif
} }

View File

@ -900,11 +900,17 @@ static bool EndsWith(const std::string& str, const std::string& suffix)
/// </summary> /// </summary>
/// <param name="str">The string to test</param> /// <param name="str">The string to test</param>
/// <param name="suffix">The string to test for</param> /// <param name="suffix">The string to test for</param>
/// <param name="ignoreCase">True to do a case insensitive comparisoin, else case sensitive. Default: false.</param>
/// <returns>True if str starts with suffix, else false.</returns> /// <returns>True if str starts with suffix, else false.</returns>
static bool StartsWith(const std::string& str, const std::string& prefix) static bool StartsWith(const std::string& str, const std::string& prefix, bool ignoreCase = false)
{ {
return str.size() >= prefix.size() && if (ignoreCase)
str.compare(0, prefix.size(), prefix) == 0; {
return str.size() >= prefix.size() &&
(_strnicmp(str.c_str(), prefix.c_str(), std::min(str.length(), prefix.length())) == 0);
}
else
return str.size() >= prefix.size() && str.compare(0, prefix.size(), prefix) == 0;
} }
/// <summary> /// <summary>

View File

@ -1757,7 +1757,7 @@ protected:
eVariationType m_VarType;//The type of variation: regular, pre or post. eVariationType m_VarType;//The type of variation: regular, pre or post.
eVariationAssignType m_PrePostAssignType;//Whether to assign the results for pre/post, or sum them. eVariationAssignType m_PrePostAssignType;//Whether to assign the results for pre/post, or sum them.
private: protected:
bool m_NeedPrecalcSumSquares;//Whether this variation uses the precalc sum squares value in its calculations. bool m_NeedPrecalcSumSquares;//Whether this variation uses the precalc sum squares value in its calculations.
bool m_NeedPrecalcSqrtSumSquares;//Whether it uses the sqrt precalc sum squares value in its calculations. bool m_NeedPrecalcSqrtSumSquares;//Whether it uses the sqrt precalc sum squares value in its calculations.
bool m_NeedPrecalcAngles;//Whether it uses the precalc sin and cos values in its calculations. bool m_NeedPrecalcAngles;//Whether it uses the precalc sin and cos values in its calculations.

View File

@ -726,13 +726,23 @@ template <typename T>
class JuliaVariation : public Variation<T> class JuliaVariation : public Variation<T>
{ {
public: public:
JuliaVariation(T weight = 1.0) : Variation<T>("julia", eVariationId::VAR_JULIA, weight, true, true, false, true) { } using Variation<T>::m_NeedPrecalcSqrtSumSquares;
JuliaVariation(T weight = 1.0) : Variation<T>("julia", eVariationId::VAR_JULIA, weight, true, false, false, true)
{
m_NeedPrecalcSqrtSumSquares = Compat::m_Compat;
}
VARCOPY(JuliaVariation) VARCOPY(JuliaVariation)
virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override
{ {
T r = m_Weight * std::sqrt(helper.m_PrecalcSqrtSumSquares); T r;
if (Compat::m_Compat)
r = m_Weight * std::sqrt(helper.m_PrecalcSqrtSumSquares);
else
r = m_Weight * std::exp(T(0.25) * std::log(helper.m_PrecalcSumSquares));
T a = T(0.5) * helper.m_PrecalcAtanxy; T a = T(0.5) * helper.m_PrecalcAtanxy;
if (rand.RandBit()) if (rand.RandBit())
@ -747,9 +757,14 @@ public:
{ {
ostringstream ss; ostringstream ss;
string weight = WeightDefineString(); string weight = WeightDefineString();
ss << "\t{\n" ss << "\t{\n";
<< "\t\treal_t r = " << weight << " * sqrt(precalcSqrtSumSquares);\n"
<< "\t\treal_t a = (real_t)(0.5) * precalcAtanxy;\n" if (Compat::m_Compat)
ss << "\t\treal_t r = " << weight << " * sqrt(precalcSqrtSumSquares);\n";
else
ss << "\t\treal_t r = " << weight << " * exp((real_t)(0.25) * log(precalcSumSquares));\n";
ss << "\t\treal_t a = (real_t)(0.5) * precalcAtanxy;\n"
<< "\n" << "\n"
<< "\t\tif (MwcNext(mwc) & 1)\n" << "\t\tif (MwcNext(mwc) & 1)\n"
<< "\t\t a += MPI;\n" << "\t\t a += MPI;\n"
@ -760,6 +775,11 @@ public:
<< "\t}\n"; << "\t}\n";
return ss.str(); return ss.str();
} }
virtual void Precalc() override
{
m_NeedPrecalcSqrtSumSquares = Compat::m_Compat;
}
}; };
/// <summary> /// <summary>
@ -1407,15 +1427,23 @@ public:
{ {
T a = helper.m_PrecalcAtanxy; T a = helper.m_PrecalcAtanxy;
T r = m_Weight * helper.m_PrecalcSqrtSumSquares; T r = m_Weight * helper.m_PrecalcSqrtSumSquares;
T t = a + m_Fan2Y - m_Fan2Dx * int((a + m_Fan2Y) / m_Fan2Dx);
if (t > m_Fan2Dx2) if (std::fmod(a + m_Fan2Y, m_Fan2Dx) > m_Fan2Dx2)
a = a - m_Fan2Dx2; a = a - m_Fan2Dx2;
else else
a = a + m_Fan2Dx2; a = a + m_Fan2Dx2;
helper.Out.x = r * std::sin(a); if (Compat::m_Compat)
helper.Out.y = r * std::cos(a); {
helper.Out.x = r * std::sin(a);
helper.Out.y = r * std::cos(a);
}
else
{
helper.Out.x = r * std::cos(a);
helper.Out.y = r * std::sin(a);
}
helper.Out.z = m_Weight * helper.In.z; helper.Out.z = m_Weight * helper.In.z;
} }
@ -1432,18 +1460,27 @@ public:
string dx2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string dx2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
ss << "\t{\n" ss << "\t{\n"
<< "\t\treal_t a = precalcAtanxy;\n" << "\t\treal_t a = precalcAtanxy;\n"
<< "\t\treal_t r = " << weight << " * precalcSqrtSumSquares;\n" << "\t\treal_t weight = " << weight << ";\n"
<< "\t\treal_t t = a + " << fan2Y << " - " << dx << " * (int)((a + " << fan2Y << ") / " << dx << ");\n" << "\t\treal_t r = weight * precalcSqrtSumSquares;\n"
<< "\t\treal_t dx2 = " << dx2 << ";\n"
<< "\n" << "\n"
<< "\t\tif (t > " << dx2 << ")\n" << "\t\tif (fmod(a + " << fan2Y << ", " << dx << ") > dx2)\n"
<< "\t\t a = a - " << dx2 << ";\n" << "\t\t a = a - dx2;\n"
<< "\t\telse\n" << "\t\telse\n"
<< "\t\t a = a + " << dx2 << ";\n" << "\t\t a = a + dx2;\n"
<< "\n" << "\n";
<< "\t\tvOut.x = r * sin(a);\n"
<< "\t\tvOut.y = r * cos(a);\n" if (Compat::m_Compat)
<< "\t\tvOut.z = " << weight << " * vIn.z;\n" ss << "\t\tvOut.x = r * sin(a);\n"
<< "\t}\n"; << "\t\tvOut.y = r * cos(a);\n"
<< "\t\tvOut.z = weight * vIn.z;\n"
<< "\t}\n";
else
ss << "\t\tvOut.x = r * cos(a);\n"
<< "\t\tvOut.y = r * sin(a);\n"
<< "\t\tvOut.z = weight * vIn.z;\n"
<< "\t}\n";
return ss.str(); return ss.str();
} }
@ -1464,8 +1501,8 @@ protected:
{ {
string prefix = Prefix(); string prefix = Prefix();
m_Params.clear(); m_Params.clear();
m_Params.push_back(ParamWithName<T>(&m_Fan2X, prefix + "fan2_x")); m_Params.push_back(ParamWithName<T>(&m_Fan2X, prefix + "fan2_x", T(0.70710678118654752440084436210485)));
m_Params.push_back(ParamWithName<T>(&m_Fan2Y, prefix + "fan2_y")); m_Params.push_back(ParamWithName<T>(&m_Fan2Y, prefix + "fan2_y", T(-0.70710678118654752440084436210485)));
m_Params.push_back(ParamWithName<T>(true, &m_Fan2Dx, prefix + "fan2_dx"));//Precalc. m_Params.push_back(ParamWithName<T>(true, &m_Fan2Dx, prefix + "fan2_dx"));//Precalc.
m_Params.push_back(ParamWithName<T>(true, &m_Fan2Dx2, prefix + "fan2_dx2")); m_Params.push_back(ParamWithName<T>(true, &m_Fan2Dx2, prefix + "fan2_dx2"));
} }
@ -1677,10 +1714,9 @@ public:
virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override
{ {
T d = Zeps(m_Dist - helper.In.y * m_Vsin); T d = m_Weight / Zeps(m_Dist - helper.In.y * m_Vsin);
T t = 1 / d; helper.Out.x = d * m_Dist * helper.In.x;
helper.Out.x = m_Weight * m_Dist * helper.In.x * t; helper.Out.y = d * m_VfCos * helper.In.y;
helper.Out.y = m_Weight * m_VfCos * helper.In.y * t;
helper.Out.z = DefaultZ(helper); helper.Out.z = DefaultZ(helper);
} }
@ -1696,11 +1732,10 @@ public:
string vSin = "parVars[" + ToUpper(m_Params[i++].Name()) + index;//Precalc. string vSin = "parVars[" + ToUpper(m_Params[i++].Name()) + index;//Precalc.
string vfCos = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string vfCos = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
ss << "\t{\n" ss << "\t{\n"
<< "\t\treal_t d = Zeps(" << dist << " - vIn.y * " << vSin << ");\n" << "\t\treal_t d = " << weight << " / Zeps(" << dist << " - vIn.y * " << vSin << "); \n"
<< "\t\treal_t t = (real_t)(1.0) / d;\n"
<< "\n" << "\n"
<< "\t\tvOut.x = (" << weight << " * " << dist << " * vIn.x * t);\n" << "\t\tvOut.x = d * " << dist << " * vIn.x;\n"
<< "\t\tvOut.y = (" << weight << " * " << vfCos << " * vIn.y * t);\n" << "\t\tvOut.y = d * " << vfCos << " * vIn.y;\n"
<< "\t\tvOut.z = " << DefaultZCl() << "\t\tvOut.z = " << DefaultZCl()
<< "\t}\n"; << "\t}\n";
return ss.str(); return ss.str();
@ -1756,7 +1791,7 @@ public:
virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override
{ {
T tempr = rand.Frand01<T>() * M_2PI; T tempr = rand.Frand01<T>() * M_2PI;
T r = m_Weight * rand.Frand01<T>(); T r = rand.Frand01<T>() * m_Weight;
helper.Out.x = helper.In.x * r * std::cos(tempr); helper.Out.x = helper.In.x * r * std::cos(tempr);
helper.Out.y = helper.In.y * r * std::sin(tempr); helper.Out.y = helper.In.y * r * std::sin(tempr);
helper.Out.z = m_Weight * helper.In.z; helper.Out.z = m_Weight * helper.In.z;
@ -1768,7 +1803,7 @@ public:
string weight = WeightDefineString(); string weight = WeightDefineString();
ss << "\t{\n" ss << "\t{\n"
<< "\t\treal_t tempr = MwcNext01(mwc) * M_2PI;\n" << "\t\treal_t tempr = MwcNext01(mwc) * M_2PI;\n"
<< "\t\treal_t r = " << weight << " * MwcNext01(mwc);\n" << "\t\treal_t r = MwcNext01(mwc) * " << weight << ";\n"
<< "\n" << "\n"
<< "\t\tvOut.x = vIn.x * r * cos(tempr);\n" << "\t\tvOut.x = vIn.x * r * cos(tempr);\n"
<< "\t\tvOut.y = vIn.y * r * sin(tempr);\n" << "\t\tvOut.y = vIn.y * r * sin(tempr);\n"
@ -1794,10 +1829,21 @@ public:
virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override
{ {
T tempr = (helper.m_PrecalcAtanyx + M_2PI * rand.Rand(size_t(m_Rn))) / m_Power; T a;
T r = m_Weight * std::pow(helper.m_PrecalcSumSquares, m_Cn); T r = m_Weight * std::pow(helper.m_PrecalcSumSquares, m_Cn);
helper.Out.x = r * std::cos(tempr);
helper.Out.y = r * std::sin(tempr); if (Compat::m_Compat)
{
a = (helper.m_PrecalcAtanyx + M_2PI * rand.Rand(size_t(m_Rn))) / m_Power;
}
else
{
int root = (int)(m_Power * rand.Frand01<T>());
a = (helper.m_PrecalcAtanyx + root * M_2PI) / m_Power;
}
helper.Out.x = r * std::cos(a);
helper.Out.y = r * std::sin(a);
helper.Out.z = m_Weight * helper.In.z; helper.Out.z = m_Weight * helper.In.z;
} }
@ -1813,12 +1859,21 @@ public:
string rn = "parVars[" + ToUpper(m_Params[i++].Name()) + index;//Precalc. string rn = "parVars[" + ToUpper(m_Params[i++].Name()) + index;//Precalc.
string cn = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string cn = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
ss << "\t{\n" ss << "\t{\n"
<< "\t\tint tRnd = (int)(" << rn << " * MwcNext01(mwc));\n" << "\t\treal_t r = " << weight << " * pow(precalcSumSquares, " << cn << ");\n";
<< "\t\treal_t tempr = fma(M_2PI, (real_t)tRnd, precalcAtanyx) / " << power << ";\n"
<< "\t\treal_t r = " << weight << " * pow(precalcSumSquares, " << cn << ");\n" if (Compat::m_Compat)
<< "\n" {
<< "\t\tvOut.x = r * cos(tempr);\n" ss << "\t\treal_t a = (precalcAtanyx + M_2PI * (int)(" << rn << " * MwcNext01(mwc))) / " << power << ";\n";
<< "\t\tvOut.y = r * sin(tempr);\n" }
else
{
ss << "\t\tint root = (int)(" << power << " * MwcNext01(mwc));\n"
<< "\t\treal_t a = (precalcAtanyx + root * M_2PI) / " << power << ";\n";
}
ss << "\n"
<< "\t\tvOut.x = r * cos(a);\n"
<< "\t\tvOut.y = r * sin(a);\n"
<< "\t\tvOut.z = " << weight << " * vIn.z;\n" << "\t\tvOut.z = " << weight << " * vIn.z;\n"
<< "\t}\n"; << "\t}\n";
return ss.str(); return ss.str();
@ -1828,7 +1883,7 @@ public:
{ {
m_Power = Zeps(m_Power); m_Power = Zeps(m_Power);
m_Rn = std::abs(m_Power); m_Rn = std::abs(m_Power);
m_Cn = m_Dist / m_Power / 2; m_Cn = m_Dist / m_Power * T(0.5);
} }
virtual void Random(QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override virtual void Random(QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override
@ -1843,7 +1898,7 @@ protected:
string prefix = Prefix(); string prefix = Prefix();
m_Params.clear(); m_Params.clear();
m_Params.push_back(ParamWithName<T>(&m_Dist, prefix + "julian_dist", 1)); m_Params.push_back(ParamWithName<T>(&m_Dist, prefix + "julian_dist", 1));
m_Params.push_back(ParamWithName<T>(&m_Power, prefix + "julian_power", 1, eParamType::INTEGER_NONZERO)); m_Params.push_back(ParamWithName<T>(&m_Power, prefix + "julian_power", 1));
m_Params.push_back(ParamWithName<T>(true, &m_Rn, prefix + "julian_rn"));//Precalc. m_Params.push_back(ParamWithName<T>(true, &m_Rn, prefix + "julian_rn"));//Precalc.
m_Params.push_back(ParamWithName<T>(true, &m_Cn, prefix + "julian_cn")); m_Params.push_back(ParamWithName<T>(true, &m_Cn, prefix + "julian_cn"));
} }
@ -1871,26 +1926,29 @@ public:
virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override
{ {
int rnd = int(m_Rn * rand.Frand01<T>()); T a, r = m_Weight * std::pow(helper.m_PrecalcSumSquares, m_Cn);
T tempr, r = m_Weight * std::pow(helper.m_PrecalcSumSquares, m_Cn);
if ((rnd & 1) == 0) if (Compat::m_Compat)
tempr = (M_2PI * rnd + helper.m_PrecalcAtanyx) / m_Power; {
int rnd = int(m_Rn * rand.Frand01<T>());
if ((rnd & 1) == 0)
a = (M_2PI * rnd + helper.m_PrecalcAtanyx) / m_Power;
else
a = (M_2PI * rnd - helper.m_PrecalcAtanyx) / m_Power;
}
else else
tempr = (M_2PI * rnd - helper.m_PrecalcAtanyx) / m_Power; {
auto root = Floor(m_Power * rand.Frand01<T>());
auto root_div2 = Floor(root * T(0.5));
auto root_mod2 = root - root_div2 * 2;
T root_scale = T(root_mod2 == 1 ? -1 : 1);
a = (helper.m_PrecalcAtanyx * root_scale + root * M_2PI) / Zeps(m_Power);
}
helper.Out.x = r * std::cos(tempr); helper.Out.x = r * std::cos(a);
helper.Out.y = r * std::sin(tempr); helper.Out.y = r * std::sin(a);
helper.Out.z = m_Weight * helper.In.z; helper.Out.z = m_Weight * helper.In.z;
//int rnd = (int)(m_Rn * rand.Frand01<T>());
//T tempr, r;
//if ((rnd & 1) == 0)
// tempr = (2 * T(M_PI) * (int)(m_Rn * rand.Frand01<T>()) + helper.m_PrecalcAtanyx) / m_Power;//Fixed to get new random rather than use rnd from above.//SMOULDER
//else
// tempr = (2 * T(M_PI) * (int)(m_Rn * rand.Frand01<T>()) - helper.m_PrecalcAtanyx) / m_Power;
//r = m_Weight * pow(helper.m_PrecalcSumSquares, m_Cn);
//helper.Out.x = r * cos(tempr);
//helper.Out.y = r * sin(tempr);
} }
virtual string OpenCLString() const override virtual string OpenCLString() const override
@ -1905,40 +1963,40 @@ public:
string rn = "parVars[" + ToUpper(m_Params[i++].Name()) + index;//Precalc. string rn = "parVars[" + ToUpper(m_Params[i++].Name()) + index;//Precalc.
string cn = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string cn = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
ss << "\t{\n" ss << "\t{\n"
<< "\t\tint rnd = (int)(" << rn << " * MwcNext01(mwc));\n" << "\t\treal_t a;\n"
<< "\t\treal_t tempr, r;\n" << "\t\treal_t r = " << weight << " * pow(precalcSumSquares, " << cn << ");\n"
<< "\n" << "\t\treal_t power = " << power << ";\n"
<< "\t\tif ((rnd & 1) == 0)\n" << "\n";
<< "\t\t tempr = fma(M_2PI, (real_t)rnd, precalcAtanyx) / " << power << ";\n"
<< "\t\telse\n" if (Compat::m_Compat)
<< "\t\t tempr = fma(M_2PI, (real_t)rnd, -precalcAtanyx) / " << power << ";\n" {
<< "\n" ss << "\t\tint rnd = (int)(" << rn << " * MwcNext01(mwc));\n"
<< "\t\tr = " << weight << " * pow(precalcSumSquares, " << cn << ");\n" << "\n"
<< "\n" << "\t\tif ((rnd & 1) == 0)\n"
<< "\t\tvOut.x = r * cos(tempr);\n" << "\t\t a = fma(M_2PI, (real_t)rnd, precalcAtanyx) / power;\n"
<< "\t\tvOut.y = r * sin(tempr);\n" << "\t\telse\n"
<< "\t\t a = fma(M_2PI, (real_t)rnd, -precalcAtanyx) / power;\n"
<< "\n";
}
else
{
ss << "\t\tint root = (int)floor(power * MwcNext01(mwc));\n"
<< "\t\tint root_div2 = (int)floor(root * (real_t)(0.5));\n"
<< "\t\tint root_mod2 = root - root_div2 * 2;\n"
<< "\t\tint root_scale = (real_t)(root_mod2 == 1 ? -1.0 : 1.0);\n"
<< "\t\ta = (precalcAtanyx * root_scale + root * M_2PI) / power;\n";
}
ss << "\t\tvOut.x = r * cos(a);\n"
<< "\t\tvOut.y = r * sin(a);\n"
<< "\t\tvOut.z = " << weight << " * vIn.z;\n" << "\t\tvOut.z = " << weight << " * vIn.z;\n"
<< "\t}\n"; << "\t}\n";
//ss << "\t{\n"
// << "\t\tint rnd = (int)(" << rn << " * MwcNext01(mwc));\n"
// << "\t\treal_t tempr, r;\n"
// << "\n"
// << "\t\tif ((rnd & 1) == 0)\n"
// << "\t\t tempr = (2 * M_PI * (int)(" << rn << " * MwcNext01(mwc)) + precalcAtanyx) / " << power << ";\n"//Fixed to get new random rather than use rnd from above.//SMOULDER
// << "\t\telse\n"
// << "\t\t tempr = (2 * M_PI * (int)(" << rn << " * MwcNext01(mwc)) - precalcAtanyx) / " << power << ";\n"
// << "\n"
// << "\t\tr = " << weight << " * pow(precalcSumSquares, " << cn << ");\n"
// << "\n"
// << "\t\tvOut.x = r * cos(tempr);\n"
// << "\t\tvOut.y = r * sin(tempr);\n"
// << "\t\tvOut.z = " << weight << " * vIn.z;\n"
// << "\t}\n";
return ss.str(); return ss.str();
} }
virtual void Precalc() override virtual void Precalc() override
{ {
m_Power = Zeps(m_Power);
m_Rn = std::abs(m_Power); m_Rn = std::abs(m_Power);
m_Cn = m_Dist / m_Power / 2; m_Cn = m_Dist / m_Power / 2;
} }
@ -2361,7 +2419,7 @@ public:
virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override
{ {
T re = 1 + m_C1 * helper.In.x + m_C2 * (SQR(helper.In.x) - SQR(helper.In.y)); T re = 1 + m_C1 * helper.In.x + m_C2 * (SQR(helper.In.x) - SQR(helper.In.y));
T im = m_C1 * helper.In.y + m_C22 * helper.In.x * helper.In.y; T im = (m_C1 + m_C22 * helper.In.x) * helper.In.y;
T r = m_Weight / Zeps(SQR(re) + SQR(im)); T r = m_Weight / Zeps(SQR(re) + SQR(im));
helper.Out.x = (helper.In.x * re + helper.In.y * im) * r; helper.Out.x = (helper.In.x * re + helper.In.y * im) * r;
helper.Out.y = (helper.In.y * re - helper.In.x * im) * r; helper.Out.y = (helper.In.y * re - helper.In.x * im) * r;
@ -2380,7 +2438,7 @@ public:
string c22 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string c22 = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
ss << "\t{\n" ss << "\t{\n"
<< "\t\treal_t re = (real_t)(1.0) + " << c1 << " * vIn.x + " << c2 << " * fma(vIn.x, vIn.x, -SQR(vIn.y));\n" << "\t\treal_t re = (real_t)(1.0) + " << c1 << " * vIn.x + " << c2 << " * fma(vIn.x, vIn.x, -SQR(vIn.y));\n"
<< "\t\treal_t im = fma(" << c1 << ", vIn.y, " << c22 << " * vIn.x * vIn.y);\n" << "\t\treal_t im = fma(" << c22 << ", vIn.x, " << c1 << ") * vIn.y;\n"
<< "\t\treal_t r = " << weight << " / Zeps(fma(re, re, SQR(im)));\n" << "\t\treal_t r = " << weight << " / Zeps(fma(re, re, SQR(im)));\n"
<< "\n" << "\n"
<< "\t\tvOut.x = fma(vIn.x, re, vIn.y * im) * r;\n" << "\t\tvOut.x = fma(vIn.x, re, vIn.y * im) * r;\n"
@ -2928,7 +2986,18 @@ public:
virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override
{ {
T r = m_Weight / Zeps(std::abs((helper.In.x - helper.In.y) * (helper.In.x + helper.In.y))); T r;
if (Compat::m_Compat)
{
r = m_Weight / Zeps(std::abs((helper.In.x - helper.In.y) * (helper.In.x + helper.In.y)));
}
else
{
T s = Zeps(Sqr(helper.In.x) - Sqr(helper.In.y));
r = m_Weight / s;
}
helper.Out.x = helper.In.x * r; helper.Out.x = helper.In.x * r;
helper.Out.y = helper.In.y * r; helper.Out.y = helper.In.y * r;
helper.Out.z = m_Weight * helper.In.z; helper.Out.z = m_Weight * helper.In.z;
@ -2939,12 +3008,23 @@ public:
ostringstream ss; ostringstream ss;
string weight = WeightDefineString(); string weight = WeightDefineString();
ss << "\t{\n" ss << "\t{\n"
<< "\t\treal_t r = " << weight << " /Zeps(fabs((vIn.x - vIn.y) * (vIn.x + vIn.y)));\n" << "\t\treal_t r;\n";
<< "\n"
<< "\t\tvOut.x = vIn.x * r;\n" if (Compat::m_Compat)
<< "\t\tvOut.y = vIn.y * r;\n" {
<< "\t\tvOut.z = " << weight << " * vIn.z;\n" ss << "\t\tr = " << weight << " / Zeps(fabs((vIn.x - vIn.y) * (vIn.x + vIn.y)));\n";
<< "\t}\n"; }
else
{
ss << "\t\treal_t s = Zeps(SQR(vIn.x) - SQR(vIn.y));\n"
<< "\t\tr = " << weight << " / s;\n";
}
ss << "\n"
<< "\t\tvOut.x = vIn.x * r;\n"
<< "\t\tvOut.y = vIn.y * r;\n"
<< "\t\tvOut.z = " << weight << " * vIn.z;\n"
<< "\t}\n";
return ss.str(); return ss.str();
} }
@ -3534,10 +3614,11 @@ public:
const T f = t + x2; const T f = t + x2;
const T g = t - x2; const T g = t - x2;
const T foverg = f / Zeps(g);
if ((g == 0) || (f / g <= 0)) if ((g == 0) || (foverg <= 0))
{ {
if (m_VarType == eVariationType::VARTYPE_REG) if (Compat::m_Compat && m_VarType == eVariationType::VARTYPE_REG)
{ {
helper.Out.x = 0; helper.Out.x = 0;
helper.Out.y = 0; helper.Out.y = 0;
@ -3552,7 +3633,7 @@ public:
} }
else else
{ {
helper.Out.x = m_V4 * std::log((t + x2) / Zeps(t - x2)); helper.Out.x = m_V4 * std::log(foverg);
helper.Out.y = m_V * y; helper.Out.y = m_V * y;
helper.Out.z = m_Weight * helper.In.z; helper.Out.z = m_Weight * helper.In.z;
} }
@ -3583,11 +3664,12 @@ public:
<< "\n" << "\n"
<< "\t\treal_t f = t + x2;\n" << "\t\treal_t f = t + x2;\n"
<< "\t\treal_t g = t - x2;\n" << "\t\treal_t g = t - x2;\n"
<< "\t\treal_t foverg = f / Zeps(g);\n"
<< "\n"; << "\n";
if (m_VarType == eVariationType::VARTYPE_REG) if (Compat::m_Compat && m_VarType == eVariationType::VARTYPE_REG)
{ {
ss << "\t\tif ((g == 0) || (f / g <= 0))\n" ss << "\t\tif ((g == 0) || (foverg <= 0))\n"
<< "\t\t{\n" << "\t\t{\n"
<< "\t\t vOut.x = 0;\n" << "\t\t vOut.x = 0;\n"
<< "\t\t vOut.y = 0;\n" << "\t\t vOut.y = 0;\n"
@ -3596,7 +3678,7 @@ public:
} }
else else
{ {
ss << "\t\tif ((g == 0) || (f / g <= 0))\n" ss << "\t\tif ((g == 0) || (foverg <= 0))\n"
<< "\t\t{\n" << "\t\t{\n"
<< "\t\t vOut.x = vIn.x;\n" << "\t\t vOut.x = vIn.x;\n"
<< "\t\t vOut.y = vIn.y;\n" << "\t\t vOut.y = vIn.y;\n"
@ -3606,8 +3688,8 @@ public:
ss << "\t\telse\n" ss << "\t\telse\n"
<< "\t\t{\n" << "\t\t{\n"
<< "\t\t vOut.x = (" << v4 << " * log((t + x2) / Zeps(t - x2)));\n" << "\t\t vOut.x = " << v4 << " * log(foverg);\n"
<< "\t\t vOut.y = (" << v << " * y);\n" << "\t\t vOut.y = " << v << " * y;\n"
<< "\t\t vOut.z = " << weight << " * vIn.z;\n" << "\t\t vOut.z = " << weight << " * vIn.z;\n"
<< "\t\t}\n" << "\t\t}\n"
<< "\t}\n"; << "\t}\n";
@ -3616,7 +3698,7 @@ public:
virtual void Precalc() override virtual void Precalc() override
{ {
m_S = -T(M_PI_2) * m_Shift;; m_S = -T(M_PI_2) * m_Shift;
m_V = m_Weight * T(M_2_PI); m_V = m_Weight * T(M_2_PI);
m_V4 = m_Weight * T(0.25) * T(M_2_PI); m_V4 = m_Weight * T(0.25) * T(M_2_PI);
} }
@ -3631,19 +3713,6 @@ public:
return vector<string> { "Zeps" }; return vector<string> { "Zeps" };
} }
virtual bool SetParamVal(const char* name, T val) override
{
if (!_stricmp(name, "bipolar_shift"))
{
T temp = VarFuncs<T>::Fabsmod(T(0.5) * (val + 1));
m_Shift = 2 * temp - 1;
Precalc();
return true;
}
return ParametricVariation<T>::SetParamVal(name, val);
}
protected: protected:
void Init() void Init()
{ {
@ -3829,8 +3898,8 @@ public:
virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override
{ {
T invCellSize = 1 / m_Size; T invCellSize = 1 / m_Size;
T x = std::floor(helper.In.x * invCellSize);//Calculate input cell. Note that int cast is omitted here. See below. T x = T(Floor(helper.In.x * invCellSize));//Calculate input cell. Note that int cast is omitted here. See below.
T y = std::floor(helper.In.y * invCellSize); T y = T(Floor(helper.In.y * invCellSize));
T dx = helper.In.x - x * m_Size;//Offset from cell origin. T dx = helper.In.x - x * m_Size;//Offset from cell origin.
T dy = helper.In.y - y * m_Size; T dy = helper.In.y - y * m_Size;
@ -4135,11 +4204,17 @@ public:
T r1 = std::sqrt(tmp + tmp2); T r1 = std::sqrt(tmp + tmp2);
T r2 = std::sqrt(tmp - tmp2); T r2 = std::sqrt(tmp - tmp2);
T xmax = Zeps((r1 + r2) * T(0.5)); T xmax = Zeps((r1 + r2) * T(0.5));
T a1 = std::log(xmax + std::sqrt(xmax - 1)); T logs = std::log(xmax + std::sqrt(xmax - 1));
T a2 = -std::acos(Clamp<T>(helper.In.x / xmax, -1, 1)); T a2;
T w = m_Weight / T(11.57034632);//This is an interesting magic number.
if (Compat::m_Compat)
a2 = -std::acos(Clamp<T>(helper.In.x / xmax, -1, 1));
else
a2 = std::acos(helper.In.x / xmax);
T w = m_Weight / T(11.57034632);//2 / e^pi.
T snv, csv, snhu, cshu; T snv, csv, snhu, cshu;
sincos(a1, &snv, &csv); sincos(logs, &snv, &csv);
snhu = std::sinh(a2); snhu = std::sinh(a2);
cshu = std::cosh(a2); cshu = std::cosh(a2);
@ -4161,11 +4236,17 @@ public:
<< "\t\treal_t r1 = sqrt(tmp + tmp2);\n" << "\t\treal_t r1 = sqrt(tmp + tmp2);\n"
<< "\t\treal_t r2 = sqrt(tmp - tmp2);\n" << "\t\treal_t r2 = sqrt(tmp - tmp2);\n"
<< "\t\treal_t xmax = Zeps((r1 + r2) * (real_t)(0.5));\n" << "\t\treal_t xmax = Zeps((r1 + r2) * (real_t)(0.5));\n"
<< "\t\treal_t a1 = log(xmax + sqrt(xmax - (real_t)(1.0)));\n" << "\t\treal_t logs = log(xmax + sqrt(xmax - (real_t)(1.0)));\n"
<< "\t\treal_t a2 = -acos(clamp(vIn.x / xmax, -(real_t)(1.0), (real_t)(1.0)));\n" << "\t\treal_t a2;\n";
<< "\t\treal_t w = " << weight << " / (real_t)(11.57034632);\n"
<< "\t\treal_t snv = sin(a1);\n" if (Compat::m_Compat)
<< "\t\treal_t csv = cos(a1);\n" ss << "\t\ta2 = -acos(clamp(vIn.x / xmax, -(real_t)(1.0), (real_t)(1.0)));\n";
else
ss << "\t\ta2 = acos(vIn.x / xmax);\n";
ss << "\t\treal_t w = " << weight << " / (real_t)(11.57034632);\n"
<< "\t\treal_t snv = sin(logs);\n"
<< "\t\treal_t csv = cos(logs);\n"
<< "\t\treal_t snhu = sinh(a2);\n" << "\t\treal_t snhu = sinh(a2);\n"
<< "\t\treal_t cshu = cosh(a2);\n" << "\t\treal_t cshu = cosh(a2);\n"
<< "\t\tif (vIn.y > 0)\n" << "\t\tif (vIn.y > 0)\n"
@ -4197,7 +4278,7 @@ public:
PARVARCOPY(EllipticVariation) PARVARCOPY(EllipticVariation)
//An improved version which was posted in the Discord chat by user Claude which was helps with rounding errors. //An improved version which was posted in the Discord chat by user Claude which helps with rounding errors.
//Note that for this to work, a "bad value" had to be changed from 1e10 and -1e10 to 1e50 and -1e50. //Note that for this to work, a "bad value" had to be changed from 1e10 and -1e10 to 1e50 and -1e50.
//For this to be correct, it must always use double. So there is no point in switching precisions when using this variation. //For this to be correct, it must always use double. So there is no point in switching precisions when using this variation.
virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override
@ -4402,16 +4483,29 @@ template <typename T>
class EscherVariation : public ParametricVariation<T> class EscherVariation : public ParametricVariation<T>
{ {
public: public:
EscherVariation(T weight = 1.0) : ParametricVariation<T>("escher", eVariationId::VAR_ESCHER, weight, true, false, false, false, true) using Variation<T>::m_NeedPrecalcAtanXY;
using Variation<T>::m_NeedPrecalcAtanYX;
EscherVariation(T weight = 1.0) : ParametricVariation<T>("escher", eVariationId::VAR_ESCHER, weight, true, false, false, true, true)
{ {
Init(); Init();
if (Compat::m_Compat)
{
m_NeedPrecalcAtanXY = false;
m_NeedPrecalcAtanYX = true;
}
else
{
m_NeedPrecalcAtanXY = true;
m_NeedPrecalcAtanYX = false;
}
} }
PARVARCOPY(EscherVariation) PARVARCOPY(EscherVariation)
virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override
{ {
T a = helper.m_PrecalcAtanyx; T a = Compat::m_Compat ? helper.m_PrecalcAtanyx : helper.m_PrecalcAtanxy;
T lnr = T(0.5) * std::log(helper.m_PrecalcSumSquares); T lnr = T(0.5) * std::log(helper.m_PrecalcSumSquares);
T m = m_Weight * std::exp(m_C * lnr - m_D * a); T m = m_Weight * std::exp(m_C * lnr - m_D * a);
T n = m_C * a + m_D * lnr; T n = m_C * a + m_D * lnr;
@ -4431,7 +4525,7 @@ public:
string c = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string c = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
string d = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string d = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
ss << "\t{\n" ss << "\t{\n"
<< "\t\treal_t a = precalcAtanyx;\n" << "\t\treal_t a = " << (Compat::m_Compat ? "precalcAtanyx" : "precalcAtanxy") << ";\n"
<< "\t\treal_t lnr = (real_t)(0.5) * log(precalcSumSquares);\n" << "\t\treal_t lnr = (real_t)(0.5) * log(precalcSumSquares);\n"
<< "\t\treal_t m = " << weight << " * exp(fma(" << c << ", lnr, -(" << d << " * a)));\n" << "\t\treal_t m = " << weight << " * exp(fma(" << c << ", lnr, -(" << d << " * a)));\n"
<< "\t\treal_t n = fma(" << c << ", a, " << d << " * lnr);\n" << "\t\treal_t n = fma(" << c << ", a, " << d << " * lnr);\n"
@ -4448,23 +4542,22 @@ public:
sincos(m_Beta, &m_D, &m_C); sincos(m_Beta, &m_D, &m_C);
m_C = T(0.5) * (1 + m_C); m_C = T(0.5) * (1 + m_C);
m_D = T(0.5) * m_D; m_D = T(0.5) * m_D;
if (Compat::m_Compat)
{
m_NeedPrecalcAtanXY = false;
m_NeedPrecalcAtanYX = true;
}
else
{
m_NeedPrecalcAtanXY = true;
m_NeedPrecalcAtanYX = false;
}
} }
virtual void Random(QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override virtual void Random(QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override
{ {
SetParamVal("escher_beta", T(M_PI) * rand.Frand01<T>()); m_Beta = T(M_PI) * rand.Frand01<T>();
}
virtual bool SetParamVal(const char* name, T val) override
{
if (!_stricmp(name, "escher_beta"))
{
m_Beta = VarFuncs<T>::Fabsmod((val + T(M_PI)) / (2 * T(M_PI))) * 2 * T(M_PI) - T(M_PI);
Precalc();
return true;
}
return ParametricVariation<T>::SetParamVal(name, val);
} }
protected: protected:
@ -4472,7 +4565,7 @@ protected:
{ {
string prefix = Prefix(); string prefix = Prefix();
m_Params.clear(); m_Params.clear();
m_Params.push_back(ParamWithName<T>(&m_Beta, prefix + "escher_beta")); m_Params.push_back(ParamWithName<T>(&m_Beta, prefix + "escher_beta", 3));
m_Params.push_back(ParamWithName<T>(true, &m_C, prefix + "escher_beta_c"));//Precalc. m_Params.push_back(ParamWithName<T>(true, &m_C, prefix + "escher_beta_c"));//Precalc.
m_Params.push_back(ParamWithName<T>(true, &m_D, prefix + "escher_beta_d")); m_Params.push_back(ParamWithName<T>(true, &m_D, prefix + "escher_beta_d"));
} }
@ -4610,18 +4703,6 @@ public:
return vector<string> { "Zeps" }; return vector<string> { "Zeps" };
} }
virtual bool SetParamVal(const char* name, T val) override
{
if (!_stricmp(name, "lazysusan_spin"))
{
m_Spin = VarFuncs<T>::Fabsmod(val / T(M_2PI)) * T(M_2PI);
this->Precalc();
return true;
}
return ParametricVariation<T>::SetParamVal(name, val);
}
virtual void Random(QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override virtual void Random(QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override
{ {
m_X = 2 * rand.Frand11<T>(); m_X = 2 * rand.Frand11<T>();
@ -5020,7 +5101,7 @@ protected:
m_Params.push_back(ParamWithName<T>(&m_FrequencyY, prefix + "oscilloscope2_frequencyy", T(M_PI))); m_Params.push_back(ParamWithName<T>(&m_FrequencyY, prefix + "oscilloscope2_frequencyy", T(M_PI)));
m_Params.push_back(ParamWithName<T>(&m_Amplitude, prefix + "oscilloscope2_amplitude", 1)); m_Params.push_back(ParamWithName<T>(&m_Amplitude, prefix + "oscilloscope2_amplitude", 1));
m_Params.push_back(ParamWithName<T>(&m_Perturbation, prefix + "oscilloscope2_perturbation", 1)); m_Params.push_back(ParamWithName<T>(&m_Perturbation, prefix + "oscilloscope2_perturbation", 1));
m_Params.push_back(ParamWithName<T>(&m_Damping, prefix + "oscilloscope2_damping", 0, eParamType::INTEGER, 0, 1)); m_Params.push_back(ParamWithName<T>(&m_Damping, prefix + "oscilloscope2_damping", 0));
m_Params.push_back(ParamWithName<T>(true, &m_Tpf, prefix + "oscilloscope2_tpf"));//Precalc. m_Params.push_back(ParamWithName<T>(true, &m_Tpf, prefix + "oscilloscope2_tpf"));//Precalc.
m_Params.push_back(ParamWithName<T>(true, &m_Tpf2, prefix + "oscilloscope2_tpf2")); m_Params.push_back(ParamWithName<T>(true, &m_Tpf2, prefix + "oscilloscope2_tpf2"));
} }
@ -6142,7 +6223,7 @@ public:
virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override
{ {
helper.Out.x = m_Weight * std::log(helper.m_PrecalcSumSquares) * m_Denom; helper.Out.x = std::log(helper.m_PrecalcSumSquares) * m_Denom;
helper.Out.y = m_Weight * helper.m_PrecalcAtanyx; helper.Out.y = m_Weight * helper.m_PrecalcAtanyx;
helper.Out.z = m_Weight * helper.In.z; helper.Out.z = m_Weight * helper.In.z;
} }
@ -6157,7 +6238,7 @@ public:
string base = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string base = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
string denom = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string denom = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
ss << "\t{\n" ss << "\t{\n"
<< "\t\tvOut.x = " << weight << " * log(precalcSumSquares) * " << denom << ";\n" << "\t\tvOut.x = log(precalcSumSquares) * " << denom << ";\n"
<< "\t\tvOut.y = " << weight << " * precalcAtanyx;\n" << "\t\tvOut.y = " << weight << " * precalcAtanyx;\n"
<< "\t\tvOut.z = " << weight << " * vIn.z;\n" << "\t\tvOut.z = " << weight << " * vIn.z;\n"
<< "\t}\n"; << "\t}\n";
@ -6166,7 +6247,7 @@ public:
virtual void Precalc() override virtual void Precalc() override
{ {
m_Denom = T(0.5) / std::log(m_Base); m_Denom = m_Weight * T(0.5) / std::log(m_Base);
} }
protected: protected:

View File

@ -692,8 +692,9 @@ public:
virtual void Precalc() override virtual void Precalc() override
{ {
m_V = m_Weight * m_BlurPixelizeSize; auto zsize = Zeps(m_BlurPixelizeSize);
m_InvSize = 1 / m_BlurPixelizeSize; m_V = m_Weight * zsize;
m_InvSize = 1 / zsize;
} }
protected: protected:
@ -841,7 +842,7 @@ protected:
m_Params.push_back(ParamWithName<T>(&m_Y0, prefix + "crop_top", -1)); m_Params.push_back(ParamWithName<T>(&m_Y0, prefix + "crop_top", -1));
m_Params.push_back(ParamWithName<T>(&m_X1, prefix + "crop_right", 1)); m_Params.push_back(ParamWithName<T>(&m_X1, prefix + "crop_right", 1));
m_Params.push_back(ParamWithName<T>(&m_Y1, prefix + "crop_bottom", 1)); m_Params.push_back(ParamWithName<T>(&m_Y1, prefix + "crop_bottom", 1));
m_Params.push_back(ParamWithName<T>(&m_S, prefix + "crop_scatter_area", 0, eParamType::REAL, -1, 1)); m_Params.push_back(ParamWithName<T>(&m_S, prefix + "crop_scatter_area", 0, eParamType::REAL));
m_Params.push_back(ParamWithName<T>(&m_Z, prefix + "crop_zero", 0, eParamType::INTEGER, 0, 1)); m_Params.push_back(ParamWithName<T>(&m_Z, prefix + "crop_zero", 0, eParamType::INTEGER, 0, 1));
m_Params.push_back(ParamWithName<T>(true, &m_X0_, prefix + "crop_x0_"));//Precalc. m_Params.push_back(ParamWithName<T>(true, &m_X0_, prefix + "crop_x0_"));//Precalc.
m_Params.push_back(ParamWithName<T>(true, &m_Y0_, prefix + "crop_y0_")); m_Params.push_back(ParamWithName<T>(true, &m_Y0_, prefix + "crop_y0_"));
@ -882,9 +883,6 @@ public:
virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override
{ {
if ((helper.In.x == 0) && (helper.In.y == 0))
return;
T x = helper.In.x * m_Scale; T x = helper.In.x * m_Scale;
T y = helper.In.y * m_Scale; T y = helper.In.y * m_Scale;
T r = std::sqrt(SQR(x) + SQR(y)); T r = std::sqrt(SQR(x) + SQR(y));
@ -899,11 +897,10 @@ public:
if (m_Bcbw != 0) if (m_Bcbw != 0)
{ {
T ang = std::atan2(y, x); T ang = std::atan2(y, x);
T omega = (T(0.2) * m_Bcbw * rand.Frand01<T>()) + 1; T omega = (m_BcbwFifth * rand.Frand01<T>()) + 1;
T px = omega * std::cos(ang); T temp = m_Weight * omega;
T py = omega * std::sin(ang); helper.Out.x = temp * std::cos(ang);
helper.Out.x = m_Weight * px; helper.Out.y = temp * std::sin(ang);
helper.Out.y = m_Weight * py;
} }
else else
{ {
@ -925,30 +922,28 @@ public:
string scale = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string scale = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
string borderWidth = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string borderWidth = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
string bcbw = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string bcbw = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
string bcbwfifth = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
ss << "\t{\n" ss << "\t{\n"
<< "\t\tif ((vIn.x == 0) && (vIn.y == 0))\n" << "\t\treal_t weight = " << weight << ";\n"
<< "\t\t return;\n" << "\t\treal_t scale = " << scale << ";\n"
<< "\n" << "\t\treal_t x = vIn.x * scale;\n"
<< "\t\treal_t x = vIn.x * " << scale << ";\n" << "\t\treal_t y = vIn.y * scale;\n"
<< "\t\treal_t y = vIn.y * " << scale << ";\n"
<< "\t\treal_t r = sqrt(fma(x, x, SQR(y)));\n" << "\t\treal_t r = sqrt(fma(x, x, SQR(y)));\n"
<< "\n" << "\n"
<< "\t\tif (r <= 1)\n" << "\t\tif (r <= 1)\n"
<< "\t\t{\n" << "\t\t{\n"
<< "\t\t vOut.x = " << weight << " * x;\n" << "\t\t vOut.x = weight * x;\n"
<< "\t\t vOut.y = " << weight << " * y;\n" << "\t\t vOut.y = weight * y;\n"
<< "\t\t}\n" << "\t\t}\n"
<< "\t\telse\n" << "\t\telse\n"
<< "\t\t{\n" << "\t\t{\n"
<< "\t\t if (" << bcbw << " != 0)\n" << "\t\t if (" << bcbw << " != 0)\n"
<< "\t\t {\n" << "\t\t {\n"
<< "\t\t real_t ang = atan2(y, x);\n" << "\t\t real_t ang = atan2(y, x);\n"
<< "\t\t real_t omega = fma((real_t)(0.2) * " << bcbw << ", MwcNext01(mwc), (real_t)(1.0));\n" << "\t\t real_t omega = fma(" << bcbwfifth << ", MwcNext01(mwc), (real_t)(1.0));\n"
<< "\t\t real_t px = omega * cos(ang);\n" << "\t\t real_t temp = weight * omega;\n"
<< "\t\t real_t py = omega * sin(ang);\n" << "\t\t vOut.x = temp * cos(ang);\n"
<< "\n" << "\t\t vOut.y = temp * sin(ang);\n"
<< "\t\t vOut.x = " << weight << " * px;\n"
<< "\t\t vOut.y = " << weight << " * py;\n"
<< "\t\t }\n" << "\t\t }\n"
<< "\t\t else\n" << "\t\t else\n"
<< "\t\t {\n" << "\t\t {\n"
@ -965,6 +960,7 @@ public:
virtual void Precalc() override virtual void Precalc() override
{ {
m_Bcbw = std::abs(m_BorderWidth); m_Bcbw = std::abs(m_BorderWidth);
m_BcbwFifth = T(0.2) * m_Bcbw;
} }
protected: protected:
@ -975,12 +971,14 @@ protected:
m_Params.push_back(ParamWithName<T>(&m_Scale, prefix + "bcircle_scale", 1)); m_Params.push_back(ParamWithName<T>(&m_Scale, prefix + "bcircle_scale", 1));
m_Params.push_back(ParamWithName<T>(&m_BorderWidth, prefix + "bcircle_borderwidth")); m_Params.push_back(ParamWithName<T>(&m_BorderWidth, prefix + "bcircle_borderwidth"));
m_Params.push_back(ParamWithName<T>(true, &m_Bcbw, prefix + "bcircle_bcbw"));//Precalc. m_Params.push_back(ParamWithName<T>(true, &m_Bcbw, prefix + "bcircle_bcbw"));//Precalc.
m_Params.push_back(ParamWithName<T>(true, &m_BcbwFifth, prefix + "bcircle_bcbw_fifth"));//Precalc.
} }
private: private:
T m_Scale; T m_Scale;
T m_BorderWidth; T m_BorderWidth;
T m_Bcbw;//Precalc. T m_Bcbw;//Precalc.
T m_BcbwFifth;
}; };
/// <summary> /// <summary>
@ -2584,38 +2582,60 @@ public:
virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override
{ {
T d, r = helper.m_PrecalcSqrtSumSquares; if (Compat::m_Compat)
if (r > 1)
{ {
if (rand.Frand01<T>() > T(0.5)) T d, r = helper.m_PrecalcSqrtSumSquares;
if (r > 1)
{ {
d = std::sqrt(r + helper.In.x); if (rand.Frand01<T>() > T(0.5))
helper.Out.x = m_V2 * d; {
helper.Out.y = -(m_V2 / d * helper.In.y); d = std::sqrt(r + helper.In.x);
helper.Out.x = m_V2 * d;
helper.Out.y = -(m_V2 / d * helper.In.y);
}
else
{
d = r + helper.In.x;
r = m_Weight / std::sqrt(r * (SQR(helper.In.y) + SQR(d)));
helper.Out.x = r * d;
helper.Out.y = r * helper.In.y;
}
} }
else else
{ {
d = r + helper.In.x; if (rand.Frand01<T>() > T(0.5))
r = m_Weight / std::sqrt(r * (SQR(helper.In.y) + SQR(d))); {
helper.Out.x = r * d; d = Zeps(std::sqrt(r + helper.In.x));
helper.Out.y = r * helper.In.y; helper.Out.x = -(m_V2 * d);
helper.Out.y = -(m_V2 / d * helper.In.y);
}
else
{
d = r + helper.In.x;
r = m_Weight / Zeps(std::sqrt(r * (SQR(helper.In.y) + SQR(d))));
helper.Out.x = -(r * d);
helper.Out.y = r * helper.In.y;
}
} }
} }
else else
{ {
if (rand.Frand01<T>() > T(0.5)) T r2 = helper.m_PrecalcSumSquares;
T sr = helper.m_PrecalcSqrtSumSquares;
T aux = r2 > 1 ? T(1) : T(-1);
T temp = std::sqrt(sr + helper.In.x);
if (rand.Frand01<T>() < T(0.5))
{ {
d = Zeps(std::sqrt(r + helper.In.x)); helper.Out.x = m_V2 * aux * temp;
helper.Out.x = -(m_V2 * d); helper.Out.y = m_V2 * (-helper.In.y / Zeps(temp));
helper.Out.y = -(m_V2 / d * helper.In.y);
} }
else else
{ {
d = r + helper.In.x; T tempweight = m_V2 / Zeps(sr);
r = m_Weight / Zeps(std::sqrt(r * (SQR(helper.In.y) + SQR(d)))); helper.Out.x = tempweight * aux * temp;
helper.Out.x = -(r * d); helper.Out.y = tempweight * (helper.In.y / Zeps(temp));
helper.Out.y = r * helper.In.y;
} }
} }
@ -2630,42 +2650,67 @@ public:
string index = ss2.str(); string index = ss2.str();
string weight = WeightDefineString(); string weight = WeightDefineString();
string v2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index;//Precalcs only, no params. string v2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index;//Precalcs only, no params.
ss << "\t{\n"
<< "\t\treal_t d, r = precalcSqrtSumSquares;\n" if (Compat::m_Compat)
<< "\n" {
<< "\t\tif (r > 1)\n" ss << "\t{\n"
<< "\t\t{\n" << "\t\treal_t d, r = precalcSqrtSumSquares;\n"
<< "\t\t if (MwcNext01(mwc) > (real_t)(0.5))\n" << "\n"
<< "\t\t {\n" << "\t\tif (r > 1)\n"
<< "\t\t d = sqrt(r + vIn.x);\n" << "\t\t{\n"
<< "\t\t vOut.x = " << v2 << " * d;\n" << "\t\t if (MwcNext01(mwc) > (real_t)(0.5))\n"
<< "\t\t vOut.y = -(" << v2 << " / d * vIn.y);\n" << "\t\t {\n"
<< "\t\t }\n" << "\t\t d = sqrt(r + vIn.x);\n"
<< "\t\t else\n" << "\t\t vOut.x = " << v2 << " * d;\n"
<< "\t\t {\n" << "\t\t vOut.y = -(" << v2 << " / d * vIn.y);\n"
<< "\t\t d = r + vIn.x;\n" << "\t\t }\n"
<< "\t\t r = " << weight << " / sqrt(r * fma(vIn.y, vIn.y, SQR(d)));\n" << "\t\t else\n"
<< "\t\t vOut.x = r * d;\n" << "\t\t {\n"
<< "\t\t vOut.y = r * vIn.y;\n" << "\t\t d = r + vIn.x;\n"
<< "\t\t }\n" << "\t\t r = " << weight << " / sqrt(r * fma(vIn.y, vIn.y, SQR(d)));\n"
<< "\t\t}\n" << "\t\t vOut.x = r * d;\n"
<< "\t\telse\n" << "\t\t vOut.y = r * vIn.y;\n"
<< "\t\t{\n" << "\t\t }\n"
<< "\t\t if (MwcNext01(mwc) > (real_t)(0.5))\n" << "\t\t}\n"
<< "\t\t {\n" << "\t\telse\n"
<< "\t\t d = Zeps(sqrt(r + vIn.x));\n" << "\t\t{\n"
<< "\t\t vOut.x = -(" << v2 << " * d);\n" << "\t\t if (MwcNext01(mwc) > (real_t)(0.5))\n"
<< "\t\t vOut.y = -(" << v2 << " / d * vIn.y);\n" << "\t\t {\n"
<< "\t\t }\n" << "\t\t d = Zeps(sqrt(r + vIn.x));\n"
<< "\t\t else\n" << "\t\t vOut.x = -(" << v2 << " * d);\n"
<< "\t\t {\n" << "\t\t vOut.y = -(" << v2 << " / d * vIn.y);\n"
<< "\t\t d = r + vIn.x;\n" << "\t\t }\n"
<< "\t\t r = " << weight << " / sqrt(r * fma(vIn.y, vIn.y, SQR(d)));\n" << "\t\t else\n"
<< "\t\t vOut.x = -(r * d);\n" << "\t\t {\n"
<< "\t\t vOut.y = r * vIn.y;\n" << "\t\t d = r + vIn.x;\n"
<< "\t\t }\n" << "\t\t r = " << weight << " / sqrt(r * fma(vIn.y, vIn.y, SQR(d)));\n"
<< "\t\t}\n" << "\t\t vOut.x = -(r * d);\n"
<< "\n" << "\t\t vOut.y = r * vIn.y;\n"
<< "\t\t }\n"
<< "\t\t}\n";
}
else
{
ss << "\t{\n"
<< "\t\treal_t r2 = precalcSumSquares;\n"
<< "\t\treal_t sr = precalcSqrtSumSquares;\n"
<< "\t\treal_t aux = r2 > 1 ? (real_t)(1.0) : (real_t)(-1.0);\n"
<< "\t\treal_t temp = sqrt(sr + vIn.x);\n"
<< "\n"
<< "\t\tif (MwcNext01(mwc) < (real_t)(0.5))\n"
<< "\t\t{\n"
<< "\t\t vOut.x = " << v2 << " * aux * temp;\n"
<< "\t\t vOut.y = " << v2 << " * (-vIn.y / Zeps(temp));\n"
<< "\t\t}\n"
<< "\t\telse\n"
<< "\t\t{\n"
<< "\t\t real_t tempweight = " << v2 << " / Zeps(sr);\n"
<< "\t\t vOut.x = tempweight * aux * temp;\n"
<< "\t\t vOut.y = tempweight * (vIn.y / Zeps(temp));\n"
<< "\t\t}\n";
}
ss << "\n"
<< "\t\tvOut.z = " << DefaultZCl() << "\t\tvOut.z = " << DefaultZCl()
<< "\t}\n"; << "\t}\n";
return ss.str(); return ss.str();
@ -2673,7 +2718,7 @@ public:
virtual void Precalc() override virtual void Precalc() override
{ {
m_V2 = m_Weight * std::sqrt(T(2)) / 2; m_V2 = m_Weight * (std::sqrt(T(2)) / 2);
} }
virtual vector<string> OpenCLGlobalFuncNames() const override virtual vector<string> OpenCLGlobalFuncNames() const override
@ -3109,9 +3154,9 @@ protected:
{ {
string prefix = Prefix(); string prefix = Prefix();
m_Params.clear(); m_Params.clear();
m_Params.push_back(ParamWithName<T>(&m_P, prefix + "hypertile_p", T(3))); m_Params.push_back(ParamWithName<T>(&m_P, prefix + "hypertile_p", 3));
m_Params.push_back(ParamWithName<T>(&m_Q, prefix + "hypertile_q", T(7))); m_Params.push_back(ParamWithName<T>(&m_Q, prefix + "hypertile_q", 7));
m_Params.push_back(ParamWithName<T>(&m_N, prefix + "hypertile_n", T(0))); m_Params.push_back(ParamWithName<T>(&m_N, prefix + "hypertile_n", 0));
m_Params.push_back(ParamWithName<T>(true, &m_Real, prefix + "hypertile_real"));//Precalc. m_Params.push_back(ParamWithName<T>(true, &m_Real, prefix + "hypertile_real"));//Precalc.
m_Params.push_back(ParamWithName<T>(true, &m_Imag, prefix + "hypertile_imag")); m_Params.push_back(ParamWithName<T>(true, &m_Imag, prefix + "hypertile_imag"));
} }
@ -3140,7 +3185,13 @@ public:
virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override
{ {
T temp = rand.Crand() * m_Pa; T temp;
if (Compat::m_Compat)
temp = rand.Crand() * m_Pa;
else
temp = Floor(rand.Frand01<T>() * m_IP) * m_Pa;
T sina = std::sin(temp); T sina = std::sin(temp);
T cosa = std::cos(temp); T cosa = std::cos(temp);
T re = m_R * cosa; T re = m_R * cosa;
@ -3149,7 +3200,7 @@ public:
T b = helper.In.y - im; T b = helper.In.y - im;
T c = re * helper.In.x - im * helper.In.y + 1; T c = re * helper.In.x - im * helper.In.y + 1;
T d = re * helper.In.y + im * helper.In.x; T d = re * helper.In.y + im * helper.In.x;
T vr = m_Weight / (SQR(c) + SQR(d)); T vr = m_Weight / Zeps(SQR(c) + SQR(d));
helper.Out.x = vr * (a * c + b * d); helper.Out.x = vr * (a * c + b * d);
helper.Out.y = vr * (b * c - a * d); helper.Out.y = vr * (b * c - a * d);
helper.Out.z = DefaultZ(helper); helper.Out.z = DefaultZ(helper);
@ -3167,17 +3218,23 @@ public:
string pa = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string pa = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
string r = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string r = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
string ip = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string ip = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
ss << "\t{\n" ss << "\t{\n";
<< "\t\treal_t temp = MwcNextCrand(mwc) * " << pa << ";\n"
<< "\t\treal_t sina = sin(temp);\n" if (Compat::m_Compat)
ss << "\t\treal_t temp = MwcNextCrand(mwc) * " << pa << ";\n";
else
ss << "\t\treal_t temp = floor(MwcNext01(mwc) * " << ip << ") * " << pa << ";\n";
ss << "\t\treal_t sina = sin(temp);\n"
<< "\t\treal_t cosa = cos(temp);\n" << "\t\treal_t cosa = cos(temp);\n"
<< "\t\treal_t re = " << r << " * cosa;\n" << "\t\treal_t r = " << r << ";\n"
<< "\t\treal_t im = " << r << " * sina;\n" << "\t\treal_t re = r * cosa;\n"
<< "\t\treal_t im = r * sina;\n"
<< "\t\treal_t a = vIn.x + re;\n" << "\t\treal_t a = vIn.x + re;\n"
<< "\t\treal_t b = vIn.y - im;\n" << "\t\treal_t b = vIn.y - im;\n"
<< "\t\treal_t c = fma(re, vIn.x, -(im * vIn.y)) + 1;\n" << "\t\treal_t c = fma(re, vIn.x, -(im * vIn.y)) + 1;\n"
<< "\t\treal_t d = fma(re, vIn.y, im * vIn.x);\n" << "\t\treal_t d = fma(re, vIn.y, im * vIn.x);\n"
<< "\t\treal_t vr = " << weight << " / fma(c, c, SQR(d));\n" << "\t\treal_t vr = " << weight << " / Zeps(fma(c, c, SQR(d)));\n"
<< "\n" << "\n"
<< "\t\tvOut.x = vr * fma(a, c, b * d);\n" << "\t\tvOut.x = vr * fma(a, c, b * d);\n"
<< "\t\tvOut.y = vr * fma(b, c, -(a * d));\n" << "\t\tvOut.y = vr * fma(b, c, -(a * d));\n"
@ -3195,13 +3252,18 @@ public:
m_IP = T((int)m_P); m_IP = T((int)m_P);
} }
virtual vector<string> OpenCLGlobalFuncNames() const override
{
return vector<string> { "Zeps" };
}
protected: protected:
void Init() void Init()
{ {
string prefix = Prefix(); string prefix = Prefix();
m_Params.clear(); m_Params.clear();
m_Params.push_back(ParamWithName<T>(&m_P, prefix + "hypertile1_p", T(3))); m_Params.push_back(ParamWithName<T>(&m_P, prefix + "hypertile1_p", 3));
m_Params.push_back(ParamWithName<T>(&m_Q, prefix + "hypertile1_q", T(7))); m_Params.push_back(ParamWithName<T>(&m_Q, prefix + "hypertile1_q", 7));
m_Params.push_back(ParamWithName<T>(true, &m_Pa, prefix + "hypertile1_pa"));//Precalc. m_Params.push_back(ParamWithName<T>(true, &m_Pa, prefix + "hypertile1_pa"));//Precalc.
m_Params.push_back(ParamWithName<T>(true, &m_R, prefix + "hypertile1_r")); m_Params.push_back(ParamWithName<T>(true, &m_R, prefix + "hypertile1_r"));
m_Params.push_back(ParamWithName<T>(true, &m_IP, prefix + "hypertile1_ip")); m_Params.push_back(ParamWithName<T>(true, &m_IP, prefix + "hypertile1_ip"));
@ -3237,7 +3299,7 @@ public:
T d = m_R * helper.In.y; T d = m_R * helper.In.y;
T x = (a * c + b * d); T x = (a * c + b * d);
T y = (b * c - a * d); T y = (b * c - a * d);
T vr = m_Weight / (SQR(c) + SQR(d)); T vr = m_Weight / Zeps(SQR(c) + SQR(d));
T temp = rand.Crand() * m_Pa; T temp = rand.Crand() * m_Pa;
T sina = std::sin(temp); T sina = std::sin(temp);
T cosa = std::cos(temp); T cosa = std::cos(temp);
@ -3258,13 +3320,14 @@ public:
string pa = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string pa = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
string r = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string r = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
ss << "\t{\n" ss << "\t{\n"
<< "\t\treal_t a = vIn.x + " << r << ";\n" << "\t\treal_t r = " << r << ";\n"
<< "\t\treal_t a = vIn.x + r;\n"
<< "\t\treal_t b = vIn.y;\n" << "\t\treal_t b = vIn.y;\n"
<< "\t\treal_t c = fma(" << r << ", vIn.x, (real_t)(1.0));\n" << "\t\treal_t c = fma(r, vIn.x, (real_t)(1.0));\n"
<< "\t\treal_t d = " << r << " * vIn.y;\n" << "\t\treal_t d = r * vIn.y;\n"
<< "\t\treal_t x = fma(a, c, b * d);\n" << "\t\treal_t x = fma(a, c, b * d);\n"
<< "\t\treal_t y = fma(b, c, -(a * d));\n" << "\t\treal_t y = fma(b, c, -(a * d));\n"
<< "\t\treal_t vr = " << weight << " / fma(c, c, SQR(d));\n" << "\t\treal_t vr = " << weight << " / Zeps(fma(c, c, SQR(d)));\n"
<< "\t\treal_t temp = MwcNextCrand(mwc) * " << pa << ";\n" << "\t\treal_t temp = MwcNextCrand(mwc) * " << pa << ";\n"
<< "\t\treal_t sina = sin(temp);\n" << "\t\treal_t sina = sin(temp);\n"
<< "\t\treal_t cosa = cos(temp);\n" << "\t\treal_t cosa = cos(temp);\n"
@ -3284,13 +3347,18 @@ public:
m_R = (r2 > 0) ? T(1) / sqrt(r2) : T(1); m_R = (r2 > 0) ? T(1) / sqrt(r2) : T(1);
} }
virtual vector<string> OpenCLGlobalFuncNames() const override
{
return vector<string> { "Zeps" };
}
protected: protected:
void Init() void Init()
{ {
string prefix = Prefix(); string prefix = Prefix();
m_Params.clear(); m_Params.clear();
m_Params.push_back(ParamWithName<T>(&m_P, prefix + "hypertile2_p", T(3))); m_Params.push_back(ParamWithName<T>(&m_P, prefix + "hypertile2_p", 3));
m_Params.push_back(ParamWithName<T>(&m_Q, prefix + "hypertile2_q", T(7))); m_Params.push_back(ParamWithName<T>(&m_Q, prefix + "hypertile2_q", 7));
m_Params.push_back(ParamWithName<T>(true, &m_Pa, prefix + "hypertile2_pa"));//Precalc. m_Params.push_back(ParamWithName<T>(true, &m_Pa, prefix + "hypertile2_pa"));//Precalc.
m_Params.push_back(ParamWithName<T>(true, &m_R, prefix + "hypertile2_r")); m_Params.push_back(ParamWithName<T>(true, &m_R, prefix + "hypertile2_r"));
} }
@ -3717,14 +3785,23 @@ public:
virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override
{ {
T a;
T x = m_A * helper.In.x + m_B * helper.In.y + m_E; T x = m_A * helper.In.x + m_B * helper.In.y + m_E;
T y = m_C * helper.In.x + m_D * helper.In.y + m_F; T y = m_C * helper.In.x + m_D * helper.In.y + m_F;
T angle = (std::atan2(y, x) + M_2PI * rand.Rand(size_t(m_AbsN))) / m_Power;
T sina = std::sin(angle);
T cosa = std::cos(angle);
T r = m_Weight * std::pow(SQR(x) + SQR(y), m_Cn); T r = m_Weight * std::pow(SQR(x) + SQR(y), m_Cn);
helper.Out.x = r * cosa;
helper.Out.y = r * sina; if (Compat::m_Compat)//You need to implement this on the gpu and make sure this is even what the original does. Also search all julias that use "root".
{
a = (std::atan2(y, x) + M_2PI * rand.Rand(size_t(m_AbsN))) / m_Power;
}
else
{
auto root = (int)(m_AbsN * rand.Frand01<T>());
a = (std::atan2(y, x) + root * M_2PI) / m_Power;
}
helper.Out.x = r * std::cos(a);
helper.Out.y = r * std::sin(a);
helper.Out.z = DefaultZ(helper); helper.Out.z = DefaultZ(helper);
} }
@ -3746,15 +3823,19 @@ public:
string absn = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string absn = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
string cn = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string cn = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
ss << "\t{\n" ss << "\t{\n"
<< "\t\treal_t a;\n"
<< "\t\treal_t x = fma(" << a << ", vIn.x, fma(" << b << ", vIn.y, " << e << "));\n" << "\t\treal_t x = fma(" << a << ", vIn.x, fma(" << b << ", vIn.y, " << e << "));\n"
<< "\t\treal_t y = fma(" << c << ", vIn.x, fma(" << d << ", vIn.y, " << f << "));\n" << "\t\treal_t y = fma(" << c << ", vIn.x, fma(" << d << ", vIn.y, " << f << "));\n"
<< "\t\treal_t angle = fma(M_2PI, (real_t)MwcNextRange(mwc, (uint)" << absn << "), atan2(y, x)) / " << power << ";\n" << "\t\treal_t r = " << weight << " * pow(fma(x, x, SQR(y)), " << cn << ");\n";
<< "\t\treal_t sina = sin(angle);\n"
<< "\t\treal_t cosa = cos(angle);\n" if (Compat::m_Compat)
<< "\t\treal_t r = " << weight << " * pow(fma(x, x, SQR(y)), " << cn << ");\n" ss << "\t\ta = fma(M_2PI, (real_t)MwcNextRange(mwc, (uint)" << absn << "), atan2(y, x)) / " << power << ";\n";
<< "\n" else
<< "\t\tvOut.x = r * cosa;\n" ss << "\t\tint root = (int)(" << absn << " * MwcNext01(mwc));\n"
<< "\t\tvOut.y = r * sina;\n" << "\t\ta = (atan2(y, x) + root + M_2PI) / " << power << ";\n";
ss << "\t\tvOut.x = r * cos(a);\n"
<< "\t\tvOut.y = r * sin(a);\n"
<< "\t\tvOut.z = " << DefaultZCl() << "\t\tvOut.z = " << DefaultZCl()
<< "\t}\n"; << "\t}\n";
return ss.str(); return ss.str();
@ -3765,7 +3846,11 @@ public:
if (m_Power == 0) if (m_Power == 0)
m_Power = 2; m_Power = 2;
m_AbsN = T(int(abs(m_Power))); if (Compat::m_Compat)
m_AbsN = T(int(abs(m_Power)));
else
m_AbsN = std::abs(m_Power);
m_Cn = m_Dist / m_Power / 2; m_Cn = m_Dist / m_Power / 2;
} }
@ -3780,7 +3865,7 @@ protected:
m_Params.push_back(ParamWithName<T>(&m_D, prefix + "julian2_d", 1)); m_Params.push_back(ParamWithName<T>(&m_D, prefix + "julian2_d", 1));
m_Params.push_back(ParamWithName<T>(&m_E, prefix + "julian2_e")); m_Params.push_back(ParamWithName<T>(&m_E, prefix + "julian2_e"));
m_Params.push_back(ParamWithName<T>(&m_F, prefix + "julian2_f")); m_Params.push_back(ParamWithName<T>(&m_F, prefix + "julian2_f"));
m_Params.push_back(ParamWithName<T>(&m_Power, prefix + "julian2_power", 2, eParamType::INTEGER_NONZERO)); m_Params.push_back(ParamWithName<T>(&m_Power, prefix + "julian2_power", 2, eParamType::REAL_NONZERO));
m_Params.push_back(ParamWithName<T>(&m_Dist, prefix + "julian2_dist", 1)); m_Params.push_back(ParamWithName<T>(&m_Dist, prefix + "julian2_dist", 1));
m_Params.push_back(ParamWithName<T>(true, &m_AbsN, prefix + "julian2_absn"));//Precalc. m_Params.push_back(ParamWithName<T>(true, &m_AbsN, prefix + "julian2_absn"));//Precalc.
m_Params.push_back(ParamWithName<T>(true, &m_Cn, prefix + "julian2_cn")); m_Params.push_back(ParamWithName<T>(true, &m_Cn, prefix + "julian2_cn"));
@ -3851,9 +3936,10 @@ public:
virtual void Precalc() override virtual void Precalc() override
{ {
m_HalfInvPower = T(0.5) * m_Divisor / m_Power; auto p = Zeps(m_Power);
m_InvPower = m_Divisor / m_Power; m_HalfInvPower = T(0.5) * (m_Divisor / p);
m_InvPower2pi = M_2PI / m_Power; m_InvPower = m_Divisor / p;
m_InvPower2pi = M_2PI / p;
} }
protected: protected:
@ -3861,8 +3947,8 @@ protected:
{ {
string prefix = Prefix(); string prefix = Prefix();
m_Params.clear(); m_Params.clear();
m_Params.push_back(ParamWithName<T>(&m_Power, prefix + "juliaq_power", 3, eParamType::INTEGER_NONZERO)); m_Params.push_back(ParamWithName<T>(&m_Power, prefix + "juliaq_power", 3, eParamType::REAL_NONZERO));
m_Params.push_back(ParamWithName<T>(&m_Divisor, prefix + "juliaq_divisor", 2, eParamType::INTEGER_NONZERO)); m_Params.push_back(ParamWithName<T>(&m_Divisor, prefix + "juliaq_divisor", 2, eParamType::REAL_NONZERO));
m_Params.push_back(ParamWithName<T>(true, &m_HalfInvPower, prefix + "juliaq_half_inv_power"));//Precalc. m_Params.push_back(ParamWithName<T>(true, &m_HalfInvPower, prefix + "juliaq_half_inv_power"));//Precalc.
m_Params.push_back(ParamWithName<T>(true, &m_InvPower, prefix + "juliaq_inv_power")); m_Params.push_back(ParamWithName<T>(true, &m_InvPower, prefix + "juliaq_inv_power"));
m_Params.push_back(ParamWithName<T>(true, &m_InvPower2pi, prefix + "juliaq_inv_power_2pi")); m_Params.push_back(ParamWithName<T>(true, &m_InvPower2pi, prefix + "juliaq_inv_power_2pi"));
@ -3949,7 +4035,7 @@ protected:
string prefix = Prefix(); string prefix = Prefix();
m_Params.clear(); m_Params.clear();
m_Params.push_back(ParamWithName<T>(&m_C, prefix + "murl_c")); m_Params.push_back(ParamWithName<T>(&m_C, prefix + "murl_c"));
m_Params.push_back(ParamWithName<T>(&m_Power, prefix + "murl_power", 2, eParamType::INTEGER, 2, T(0x7fffffff))); m_Params.push_back(ParamWithName<T>(&m_Power, prefix + "murl_power", 2, eParamType::REAL, 2));
m_Params.push_back(ParamWithName<T>(true, &m_Cp, prefix + "murl_cp"));//Precalc. m_Params.push_back(ParamWithName<T>(true, &m_Cp, prefix + "murl_cp"));//Precalc.
m_Params.push_back(ParamWithName<T>(true, &m_P2, prefix + "murl_p2")); m_Params.push_back(ParamWithName<T>(true, &m_P2, prefix + "murl_p2"));
m_Params.push_back(ParamWithName<T>(true, &m_Vp, prefix + "murl_vp")); m_Params.push_back(ParamWithName<T>(true, &m_Vp, prefix + "murl_vp"));
@ -4052,7 +4138,7 @@ protected:
string prefix = Prefix(); string prefix = Prefix();
m_Params.clear(); m_Params.clear();
m_Params.push_back(ParamWithName<T>(&m_C, prefix + "murl2_c", 0, eParamType::REAL, -1, 1)); m_Params.push_back(ParamWithName<T>(&m_C, prefix + "murl2_c", 0, eParamType::REAL, -1, 1));
m_Params.push_back(ParamWithName<T>(&m_Power, prefix + "murl2_power", 1, eParamType::INTEGER_NONZERO)); m_Params.push_back(ParamWithName<T>(&m_Power, prefix + "murl2_power", 1));
m_Params.push_back(ParamWithName<T>(true, &m_P2, prefix + "murl2_p2"));//Precalc. m_Params.push_back(ParamWithName<T>(true, &m_P2, prefix + "murl2_p2"));//Precalc.
m_Params.push_back(ParamWithName<T>(true, &m_InvP, prefix + "murl2_invp")); m_Params.push_back(ParamWithName<T>(true, &m_InvP, prefix + "murl2_invp"));
m_Params.push_back(ParamWithName<T>(true, &m_InvP2, prefix + "murl2_invp2")); m_Params.push_back(ParamWithName<T>(true, &m_InvP2, prefix + "murl2_invp2"));
@ -4075,7 +4161,7 @@ template <typename T>
class NPolarVariation : public ParametricVariation<T> class NPolarVariation : public ParametricVariation<T>
{ {
public: public:
NPolarVariation(T weight = 1.0) : ParametricVariation<T>("npolar", eVariationId::VAR_NPOLAR, weight, true, false, false, true, false) NPolarVariation(T weight = 1.0) : ParametricVariation<T>("npolar", eVariationId::VAR_NPOLAR, weight, true, false, false, true, true)
{ {
Init(); Init();
} }
@ -4086,23 +4172,47 @@ public:
{ {
T x, y; T x, y;
if (m_IsOdd != 0) if (Compat::m_Compat)
{ {
T angle = (std::atan2(helper.In.y, helper.In.x) + M_2PI * rand.Rand(size_t(m_AbsN))) * m_Nnz; if (m_IsOdd != 0)
T r = m_Weight * std::pow(SQR(helper.In.x) + SQR(helper.In.y), m_Cn) * m_Parity; {
x = std::cos(angle) * r; T angle = (helper.m_PrecalcAtanyx + M_2PI * rand.Rand(size_t(m_AbsN))) / m_Nnz;
y = std::sin(angle) * r; T r = m_Weight * std::pow(helper.m_PrecalcSumSquares, m_Cn) * m_Parity;
x = std::cos(angle) * r;
y = std::sin(angle) * r;
}
else
{
x = m_Vvar * helper.m_PrecalcAtanxy;
y = m_Vvar2 * std::log(helper.m_PrecalcSumSquares);
T angle = (std::atan2(y, x) + M_2PI * rand.Rand(size_t(m_AbsN))) / m_Nnz;
T r = m_Weight * std::pow(SQR(x) + SQR(y), m_Cn);
T sina = std::sin(angle) * r;
T cosa = std::cos(angle) * r;
x = m_Vvar2 * std::log(SQR(cosa) + SQR(sina));
y = m_Vvar * std::atan2(cosa, sina);
}
} }
else else
{ {
x = m_Vvar * helper.m_PrecalcAtanxy; if (m_IsOdd != 0)
y = m_Vvar2 * std::log(helper.m_PrecalcSumSquares); {
T angle = (std::atan2(y, x) + M_2PI * rand.Rand(size_t(m_AbsN))) * m_Nnz; T angle = (helper.m_PrecalcAtanyx + M_2PI * rand.Rand(size_t(m_AbsN))) / m_Nnz;
T r = m_Weight * std::pow(SQR(x) + SQR(y), m_Cn); T r = m_Weight * std::pow(helper.m_PrecalcSumSquares, m_Cn);
T sina = std::sin(angle) * r; x = std::cos(angle) * r;
T cosa = std::cos(angle) * r; y = std::sin(angle) * r;
x = m_Vvar2 * std::log(SQR(cosa) + SQR(sina)); }
y = m_Vvar * std::atan2(cosa, sina); else
{
x = m_Vvar * helper.m_PrecalcAtanxy;
y = m_Vvar2 * std::log(helper.m_PrecalcSumSquares);
T angle = (std::atan2(y, x) + M_2PI * rand.Rand(size_t(m_AbsN))) / m_Nnz;
T r = m_Weight * std::pow(SQR(x) + SQR(y), m_Cn) * m_Parity;
T sina = std::sin(angle) * r;
T cosa = std::cos(angle) * r;
x = m_Vvar2 * 2 * std::log(r);
y = m_Vvar * std::atan2(cosa, sina);
}
} }
helper.Out.x = x; helper.Out.x = x;
@ -4127,41 +4237,69 @@ public:
string isOdd = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string isOdd = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
ss << "\t{\n" ss << "\t{\n"
<< "\t\treal_t x, y;\n" << "\t\treal_t x, y;\n"
<< "\n" << "\t\treal_t vvar = " << vvar << ";\n"
<< "\t\tif (" << isOdd << " != 0)\n" << "\t\treal_t vvar2 = " << vvar2 << ";\n"
<< "\t\t{\n" << "\n";
<< "\t\t real_t angle = (atan2(vIn.y, vIn.x) + M_2PI * MwcNextRange(mwc, (uint)" << absn << ")) * " << nnz << ";\n"
<< "\t\t real_t r = " << weight << " * pow(SQR(vIn.x) + SQR(vIn.y), " << cn << ") * " << parity << ";\n" if (Compat::m_Compat)
<< "\t\t x = cos(angle) * r;\n" {
<< "\t\t y = sin(angle) * r;\n" ss << "\t\tif (" << isOdd << " != 0)\n"
<< "\t\t}\n" << "\t\t{\n"
<< "\t\telse\n" << "\t\t real_t angle = (precalcAtanyx + M_2PI * MwcNextRange(mwc, (uint)" << absn << ")) / " << nnz << ";\n"
<< "\t\t{\n" << "\t\t real_t r = " << weight << " * pow(precalcSumSquares, " << cn << ") * " << parity << ";\n"
<< "\t\t x = " << vvar << " * precalcAtanxy;\n" << "\t\t x = cos(angle) * r;\n"
<< "\t\t y = " << vvar2 << " * log(precalcSumSquares);\n" << "\t\t y = sin(angle) * r;\n"
<< "\t\t real_t angle = (atan2(y, x) + M_2PI * MwcNextRange(mwc, (uint)" << absn << ")) * " << nnz << ";\n" << "\t\t}\n"
<< "\t\t real_t r = " << weight << " * pow(SQR(x) + SQR(y), " << cn << ");\n" << "\t\telse\n"
<< "\t\t real_t sina = sin(angle) * r;\n" << "\t\t{\n"
<< "\t\t real_t cosa = cos(angle) * r;\n" << "\t\t x = vvar * precalcAtanxy;\n"
<< "\t\t x = " << vvar2 << " * log(SQR(cosa) + SQR(sina));\n" << "\t\t y = vvar2 * log(precalcSumSquares);\n"
<< "\t\t y = " << vvar << " * atan2(cosa, sina);\n" << "\t\t real_t angle = (atan2(y, x) + M_2PI * MwcNextRange(mwc, (uint)" << absn << ")) / " << nnz << ";\n"
<< "\t\t}\n" << "\t\t real_t r = " << weight << " * pow(SQR(x) + SQR(y), " << cn << ");\n"
<< "\n" << "\t\t real_t sina = sin(angle) * r;\n"
<< "\t\tvOut.x = x;\n" << "\t\t real_t cosa = cos(angle) * r;\n"
<< "\t\tvOut.y = y;\n" << "\t\t x = vvar2 * log(SQR(cosa) + SQR(sina));\n"
<< "\t\tvOut.z = " << DefaultZCl() << "\t\t y = vvar * atan2(cosa, sina);\n"
<< "\t}\n"; << "\t\t}\n";
}
else
{
ss << "\t\tif (" << isOdd << " != 0)\n"
<< "\t\t{\n"
<< "\t\t real_t angle = (precalcAtanyx + M_2PI * MwcNextRange(mwc, (uint)" << absn << ")) / " << nnz << ";\n"
<< "\t\t real_t r = " << weight << " * pow(precalcSumSquares, " << cn << ");\n"
<< "\t\t x = cos(angle) * r;\n"
<< "\t\t y = sin(angle) * r;\n"
<< "\t\t}\n"
<< "\t\telse\n"
<< "\t\t{\n"
<< "\t\t x = vvar * precalcAtanxy;\n"
<< "\t\t y = vvar2 * log(precalcSumSquares);\n"
<< "\t\t real_t angle = (atan2(y, x) + M_2PI * MwcNextRange(mwc, (uint)" << absn << ")) / " << nnz << ";\n"
<< "\t\t real_t r = " << weight << " * pow(SQR(x) + SQR(y), " << cn << ") * " << parity << ";\n"
<< "\t\t real_t sina = sin(angle) * r;\n"
<< "\t\t real_t cosa = cos(angle) * r;\n"
<< "\t\t x = vvar2 * (real_t)(2.0) * log(r);\n"
<< "\t\t y = vvar * atan2(cosa, sina);\n"
<< "\t\t}\n";
}
ss << "\n"
<< "\t\tvOut.x = x;\n"
<< "\t\tvOut.y = y;\n"
<< "\t\tvOut.z = " << DefaultZCl()
<< "\t}\n";
return ss.str(); return ss.str();
} }
virtual void Precalc() override virtual void Precalc() override
{ {
m_Nnz = 1 / ((m_N == 0) ? 1 : m_N); m_Nnz = m_N == 0 ? 1 : m_N;
m_Vvar = m_Weight / T(M_PI); m_Vvar = m_Weight / T(M_PI);
m_Vvar2 = m_Vvar * T(0.5); m_Vvar2 = m_Vvar * T(0.5);
m_AbsN = abs(m_Nnz); m_AbsN = std::abs(m_Nnz);
m_Cn = 1 / m_Nnz / 2; m_Cn = 1 / m_Nnz / 2;
m_IsOdd = T(abs(int(m_Parity)) & 1); m_IsOdd = std::fmod(std::abs(m_Parity), T(2.0));
} }
protected: protected:
@ -4169,8 +4307,8 @@ protected:
{ {
string prefix = Prefix(); string prefix = Prefix();
m_Params.clear(); m_Params.clear();
m_Params.push_back(ParamWithName<T>(&m_Parity, prefix + "npolar_parity", 0, eParamType::INTEGER)); m_Params.push_back(ParamWithName<T>(&m_Parity, prefix + "npolar_parity", 0));
m_Params.push_back(ParamWithName<T>(&m_N, prefix + "npolar_n", 1, eParamType::INTEGER)); m_Params.push_back(ParamWithName<T>(&m_N, prefix + "npolar_n", 1));
m_Params.push_back(ParamWithName<T>(true, &m_Nnz, prefix + "npolar_nnz"));//Precalc. m_Params.push_back(ParamWithName<T>(true, &m_Nnz, prefix + "npolar_nnz"));//Precalc.
m_Params.push_back(ParamWithName<T>(true, &m_Vvar, prefix + "npolar_vvar")); m_Params.push_back(ParamWithName<T>(true, &m_Vvar, prefix + "npolar_vvar"));
m_Params.push_back(ParamWithName<T>(true, &m_Vvar2, prefix + "npolar_vvar_2")); m_Params.push_back(ParamWithName<T>(true, &m_Vvar2, prefix + "npolar_vvar_2"));
@ -5487,12 +5625,14 @@ public:
string weight = WeightDefineString(); string weight = WeightDefineString();
string vvar2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index;//Precalcs only, no params. string vvar2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index;//Precalcs only, no params.
ss << "\t{\n" ss << "\t{\n"
<< "\t\treal_t vvar2 = " << vvar2 << ";\n"
<< "\t\treal_t r = exp(vIn.y);\n" << "\t\treal_t r = exp(vIn.y);\n"
<< "\t\treal_t s = sin(vIn.x);\n" << "\t\treal_t s = sin(vIn.x);\n"
<< "\t\treal_t c = cos(vIn.x);\n" << "\t\treal_t c = cos(vIn.x);\n"
<< "\t\treal_t vvar2r = vvar2 * r;\n"
<< "\n" << "\n"
<< "\t\tvOut.x = " << vvar2 << " * r * s;\n" << "\t\tvOut.x = vvar2r * s;\n"
<< "\t\tvOut.y = " << vvar2 << " * r * c;\n" << "\t\tvOut.y = vvar2r * c;\n"
<< "\t\tvOut.z = " << DefaultZCl() << "\t\tvOut.z = " << DefaultZCl()
<< "\t}\n"; << "\t}\n";
return ss.str(); return ss.str();
@ -5601,7 +5741,7 @@ protected:
m_Params.push_back(ParamWithName<T>(&m_ScaleY, prefix + "wavesn_scaley", 1)); m_Params.push_back(ParamWithName<T>(&m_ScaleY, prefix + "wavesn_scaley", 1));
m_Params.push_back(ParamWithName<T>(&m_IncX, prefix + "wavesn_incx")); m_Params.push_back(ParamWithName<T>(&m_IncX, prefix + "wavesn_incx"));
m_Params.push_back(ParamWithName<T>(&m_IncY, prefix + "wavesn_incy")); m_Params.push_back(ParamWithName<T>(&m_IncY, prefix + "wavesn_incy"));
m_Params.push_back(ParamWithName<T>(&m_Power, prefix + "wavesn_power", 1, eParamType::INTEGER_NONZERO)); m_Params.push_back(ParamWithName<T>(&m_Power, prefix + "wavesn_power", 1));
m_Params.push_back(ParamWithName<T>(true, &m_AbsN, prefix + "wavesn_absn"));//Precalc. m_Params.push_back(ParamWithName<T>(true, &m_AbsN, prefix + "wavesn_absn"));//Precalc.
m_Params.push_back(ParamWithName<T>(true, &m_Cn, prefix + "wavesn_cn")); m_Params.push_back(ParamWithName<T>(true, &m_Cn, prefix + "wavesn_cn"));
} }
@ -6034,14 +6174,15 @@ public:
virtual void Precalc() override virtual void Precalc() override
{ {
auto spread = Zeps(m_Spread);
m_Ang = M_2PI / m_Divisor; m_Ang = M_2PI / m_Divisor;
m_C = m_R * std::cos(T(M_PI) / 2 * m_A) / m_Divisor; m_C = m_R * std::cos(T(M_PI) / 2 * m_A) / m_Divisor;
m_D = m_R * std::sin(T(M_PI) / 2 * m_A) / m_Divisor; m_D = m_R * std::sin(T(M_PI) / 2 * m_A) / m_Divisor;
m_HalfC = m_C / 2; m_HalfC = m_C / 2;
m_HalfD = m_D / 2; m_HalfD = m_D / 2;
m_InvSpread = T(0.5) / m_Spread; m_InvSpread = T(0.5) / spread;
m_FullSpread = M_2PI * m_Spread; m_FullSpread = M_2PI * spread;
m_SpreadUint = uint(m_Spread); m_SpreadUint = uint(spread);
} }
protected: protected:
@ -6051,8 +6192,8 @@ protected:
m_Params.clear(); m_Params.clear();
m_Params.push_back(ParamWithName<T>(&m_R, prefix + "cpow2_r", 1)); m_Params.push_back(ParamWithName<T>(&m_R, prefix + "cpow2_r", 1));
m_Params.push_back(ParamWithName<T>(&m_A, prefix + "cpow2_a")); m_Params.push_back(ParamWithName<T>(&m_A, prefix + "cpow2_a"));
m_Params.push_back(ParamWithName<T>(&m_Divisor, prefix + "cpow2_divisor", 1, eParamType::INTEGER_NONZERO)); m_Params.push_back(ParamWithName<T>(&m_Divisor, prefix + "cpow2_divisor", 1));
m_Params.push_back(ParamWithName<T>(&m_Spread, prefix + "cpow2_spread", 1, eParamType::INTEGER, 1, T(0x7FFFFFFF))); m_Params.push_back(ParamWithName<T>(&m_Spread, prefix + "cpow2_spread", 1));
m_Params.push_back(ParamWithName<T>(true, &m_C, prefix + "cpow2_c"));//Precalc. m_Params.push_back(ParamWithName<T>(true, &m_C, prefix + "cpow2_c"));//Precalc.
m_Params.push_back(ParamWithName<T>(true, &m_HalfC, prefix + "cpow2_halfc")); m_Params.push_back(ParamWithName<T>(true, &m_HalfC, prefix + "cpow2_halfc"));
m_Params.push_back(ParamWithName<T>(true, &m_D, prefix + "cpow2_d")); m_Params.push_back(ParamWithName<T>(true, &m_D, prefix + "cpow2_d"));

View File

@ -285,8 +285,18 @@ public:
T alpha = helper.m_PrecalcAtanyx + n * M_2PI / Zeps<T>(T(Floor<T>(m_Power))); T alpha = helper.m_PrecalcAtanyx + n * M_2PI / Zeps<T>(T(Floor<T>(m_Power)));
T sina = std::sin(alpha); T sina = std::sin(alpha);
T cosa = std::cos(alpha); T cosa = std::cos(alpha);
helper.Out.x = m_Weight * cosa / r;
helper.Out.y = m_Weight * sina / r; if (Compat::m_Compat)
{
helper.Out.x = m_Weight * cosa / r;
helper.Out.y = m_Weight * sina / r;
}
else
{
helper.Out.x = m_Weight * sina / r;
helper.Out.y = m_Weight * cosa / r;
}
helper.Out.z = DefaultZ(helper); helper.Out.z = DefaultZ(helper);
} }
@ -300,15 +310,27 @@ public:
string power = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string power = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
string dist = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string dist = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
ss << "\t{\n" ss << "\t{\n"
<< "\t\treal_t weight = " << weight << ";\n"
<< "\t\treal_t power = " << power << ";\n"
<< "\t\treal_t r = Zeps(pow(precalcSqrtSumSquares, " << dist << "));\n" << "\t\treal_t r = Zeps(pow(precalcSqrtSumSquares, " << dist << "));\n"
<< "\t\tint n = floor(" << power << " * MwcNext01(mwc));\n" << "\t\tint n = floor(power * MwcNext01(mwc));\n"
<< "\t\treal_t alpha = fma(n, M_2PI / Zeps(floor(" << power << ")), precalcAtanyx);\n" << "\t\treal_t alpha = fma(n, M_2PI / Zeps(floor(power)), precalcAtanyx);\n"
<< "\t\treal_t sina = sin(alpha);\n" << "\t\treal_t sina = sin(alpha);\n"
<< "\t\treal_t cosa = cos(alpha);\n" << "\t\treal_t cosa = cos(alpha);\n"
<< "\n" << "\n";
<< "\t\tvOut.x = " << weight << " * cosa / r;\n"
<< "\t\tvOut.y = " << weight << " * sina / r;\n" if (Compat::m_Compat)
<< "\t\tvOut.z = " << DefaultZCl() {
ss << "\t\tvOut.x = weight * cosa / r;\n"
<< "\t\tvOut.y = weight * sina / r;\n";
}
else
{
ss << "\t\tvOut.x = weight * sina / r;\n"
<< "\t\tvOut.y = weight * cosa / r;\n";
}
ss << "\t\tvOut.z = " << DefaultZCl()
<< "\t}\n"; << "\t}\n";
return ss.str(); return ss.str();
} }
@ -1214,7 +1236,7 @@ protected:
{ {
string prefix = Prefix(); string prefix = Prefix();
m_Params.clear(); m_Params.clear();
m_Params.push_back(ParamWithName<T>(&m_Power, prefix + "starblur_power", 5, eParamType::INTEGER_NONZERO)); m_Params.push_back(ParamWithName<T>(&m_Power, prefix + "starblur_power", 5));
m_Params.push_back(ParamWithName<T>(&m_Range, prefix + "starblur_range", T(0.4016228317))); m_Params.push_back(ParamWithName<T>(&m_Range, prefix + "starblur_range", T(0.4016228317)));
m_Params.push_back(ParamWithName<T>(true, &m_Length, prefix + "starblur_length"));//Precalc. m_Params.push_back(ParamWithName<T>(true, &m_Length, prefix + "starblur_length"));//Precalc.
m_Params.push_back(ParamWithName<T>(true, &m_Alpha, prefix + "starblur_alpha")); m_Params.push_back(ParamWithName<T>(true, &m_Alpha, prefix + "starblur_alpha"));
@ -1382,42 +1404,77 @@ private:
/// <summary> /// <summary>
/// CropN. /// CropN.
/// By zy0rg.
/// </summary> /// </summary>
template <typename T> template <typename T>
class CropNVariation : public ParametricVariation<T> class CropNVariation : public ParametricVariation<T>
{ {
public: public:
using Variation<T>::m_NeedPrecalcSumSquares;
using Variation<T>::m_NeedPrecalcAngles;
CropNVariation(T weight = 1.0) : ParametricVariation<T>("cropn", eVariationId::VAR_CROPN, weight, true, true, true, false, true) CropNVariation(T weight = 1.0) : ParametricVariation<T>("cropn", eVariationId::VAR_CROPN, weight, true, true, true, false, true)
{ {
Init(); Init();
m_NeedPrecalcSumSquares = !Compat::m_Compat;
m_NeedPrecalcAngles = Compat::m_Compat;
} }
PARVARCOPY(CropNVariation) PARVARCOPY(CropNVariation)
virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override
{ {
T xang = (helper.m_PrecalcAtanyx + T(M_PI)) / m_Alpha; if (Compat::m_Compat)
xang = (xang - int(xang)) * m_Alpha;
xang = std::cos((xang < m_Alpha / 2) ? xang : m_Alpha - xang);
T xr = xang > 0 ? m_Radius / xang : 1;
if ((helper.m_PrecalcSqrtSumSquares > xr) == (m_Power > 0))
{ {
if (m_Zero == 1) T xang = (helper.m_PrecalcAtanyx + T(M_PI)) / m_Alpha;
xang = (xang - int(xang)) * m_Alpha;
xang = std::cos((xang < m_AlphaDiv2) ? xang : m_Alpha - xang);
T xr = xang > 0 ? m_Radius / xang : 1;
if ((helper.m_PrecalcSqrtSumSquares > xr) == (m_Power > 0))
{ {
helper.Out.x = helper.Out.y = 0; if (m_Zero == 1)
{
helper.Out.x = helper.Out.y = 0;
}
else
{
T rdc = xr + (rand.Frand01<T>() * T(0.5) * m_ScatterDist);
helper.Out.x = m_Weight * rdc * helper.m_PrecalcCosa;
helper.Out.y = m_Weight * rdc * helper.m_PrecalcSina;
}
} }
else else
{ {
T rdc = xr + (rand.Frand01<T>() * T(0.5) * m_ScatterDist); helper.Out.x = m_Weight * helper.In.x;
helper.Out.x = m_Weight * rdc * helper.m_PrecalcCosa; helper.Out.y = m_Weight * helper.In.y;
helper.Out.y = m_Weight * rdc * helper.m_PrecalcSina;
} }
} }
else else
{ {
helper.Out.x = m_Weight * helper.In.x; T r2 = helper.m_PrecalcSumSquares;
helper.Out.y = m_Weight * helper.In.y; T aModAlpha = std::fmod(helper.m_PrecalcAtanyx + T(M_PI), m_Alpha);
T xang = std::cos(aModAlpha < m_AlphaDiv2 ? aModAlpha : m_Alpha - aModAlpha);
T xr = xang > 0 ? m_Radius / Zeps(xang) : T(1);
T xr2 = xr * xr;
if ((r2 > xr2) == (m_Power > 0))
{
if (m_Zero == 0)
{
helper.Out.x = helper.Out.y = 0;
}
else
{
T temp = (xr + rand.Frand01<T>() * m_ScatterDist) * m_Weight / Zeps(std::sqrt(r2));
helper.Out.x = temp * helper.In.x;
helper.Out.y = temp * helper.In.y;
}
}
else
{
helper.Out.x = m_Weight * helper.In.x;
helper.Out.y = m_Weight * helper.In.y;
}
} }
helper.Out.z = DefaultZ(helper); helper.Out.z = DefaultZ(helper);
@ -1436,45 +1493,103 @@ public:
string zero = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string zero = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
string workPower = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string workPower = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
string alpha = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string alpha = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
string alphaDiv2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
ss << "\t{\n" ss << "\t{\n"
<< "\t\treal_t xang = (precalcAtanyx + MPI) / " << alpha << ";\n" << "\t\treal_t weight = " << weight << ";\n"
<< "\n" << "\t\treal_t alpha = " << alpha << ";\n";
<< "\t\txang = (xang - (int) xang) * " << alpha << ";\n"
<< "\t\txang = cos((xang < " << alpha << " / 2) ? xang : " << alpha << " - xang);\n" if (Compat::m_Compat)
<< "\n" {
<< "\t\treal_t xr = xang > 0 ? " << radius << " / xang : 1;\n" ss << "\t\treal_t xang = (precalcAtanyx + MPI) / alpha;\n"
<< "\n" << "\n"
<< "\t\tif ((precalcSqrtSumSquares > xr) == (" << power << " > 0))\n" << "\t\txang = (xang - (int) xang) * alpha;\n"
<< "\t\t{\n" << "\t\txang = cos((xang < " << alphaDiv2 << ") ? xang : alpha - xang);\n"
<< "\t\t if (" << zero << " == 1)\n" << "\n"
<< "\t\t {\n" << "\t\treal_t xr = xang > 0 ? " << radius << " / xang : 1;\n"
<< "\t\t vOut.x = vOut.y = 0;\n" << "\n"
<< "\t\t }\n" << "\t\tif ((precalcSqrtSumSquares > xr) == (" << power << " > 0))\n"
<< "\t\t else\n" << "\t\t{\n"
<< "\t\t {\n" << "\t\t if (" << zero << " == 1)\n"
<< "\t\t real_t rdc = fma(MwcNext01(mwc), (real_t)(0.5) * " << scatterDist << ", xr);\n" << "\t\t {\n"
<< "\n" << "\t\t vOut.x = vOut.y = 0;\n"
<< "\t\t vOut.x = " << weight << " * rdc * precalcCosa;\n" << "\t\t }\n"
<< "\t\t vOut.y = " << weight << " * rdc * precalcSina;\n" << "\t\t else\n"
<< "\t\t }\n" << "\t\t {\n"
<< "\t\t}\n" << "\t\t real_t rdc = fma(MwcNext01(mwc), (real_t)(0.5) * " << scatterDist << ", xr);\n"
<< "\t\telse\n" << "\n"
<< "\t\t{\n" << "\t\t vOut.x = weight * rdc * precalcCosa;\n"
<< "\t\t vOut.x = " << weight << " * vIn.x;\n" << "\t\t vOut.y = weight * rdc * precalcSina;\n"
<< "\t\t vOut.y = " << weight << " * vIn.y;\n" << "\t\t }\n"
<< "\t\t}\n" << "\t\t}\n"
<< "\n" << "\t\telse\n"
<< "\t\tvOut.z = " << DefaultZCl() << "\t\t{\n"
<< "\t}\n"; << "\t\t vOut.x = weight * vIn.x;\n"
<< "\t\t vOut.y = weight * vIn.y;\n"
<< "\t\t}\n"
<< "\n"
<< "\t\tvOut.z = " << DefaultZCl()
<< "\t}\n";
}
else
{
ss << "\t\treal_t r2 = precalcSumSquares;\n"
<< "\t\treal_t aModAlpha = fmod(precalcAtanyx + MPI, alpha);\n"
<< "\t\treal_t xang = cos(aModAlpha < " << alphaDiv2 << " ? aModAlpha : alpha - aModAlpha);\n"
<< "\t\treal_t xr = xang > 0 ? " << radius << " / Zeps(xang) : (real_t)1.0;\n"
<< "\t\treal_t xr2 = xr * xr;\n"
<< "\n"
<< "\t\tif ((r2 > xr2) == (" << power << " > 0))\n"
<< "\t\t{\n"
<< "\t\t if (" << zero << " == 0)\n"
<< "\t\t {\n"
<< "\t\t vOut.x = vOut.y = 0;\n"
<< "\t\t }\n"
<< "\t\t else\n"
<< "\t\t {\n"
<< "\t\t real_t temp = fma(MwcNext01(mwc), " << scatterDist << ", xr) * weight / Zeps(sqrt(r2));\n"
<< "\n"
<< "\t\t vOut.x = temp * vIn.x;\n"
<< "\t\t vOut.y = temp * vIn.y;\n"
<< "\t\t }\n"
<< "\t\t}\n"
<< "\t\telse\n"
<< "\t\t{\n"
<< "\t\t vOut.x = weight * vIn.x;\n"
<< "\t\t vOut.y = weight * vIn.y;\n"
<< "\t\t}\n"
<< "\n"
<< "\t\tvOut.z = " << DefaultZCl()
<< "\t}\n";
}
return ss.str(); return ss.str();
} }
virtual vector<string> OpenCLGlobalFuncNames() const override
{
if (Compat::m_Compat)
return vector<string> { };
else
return vector<string> { "Zeps" };
}
virtual void Precalc() override virtual void Precalc() override
{ {
bool mode = m_Power > 0; if (Compat::m_Compat)
m_WorkPower = mode ? m_Power : -m_Power; {
ClampGteRef<T>(m_WorkPower, 2); bool mode = m_Power > 0;
m_Alpha = M_2PI / m_WorkPower; m_WorkPower = mode ? m_Power : -m_Power;
ClampGteRef<T>(m_WorkPower, 2);
m_Alpha = M_2PI / m_WorkPower;
}
else
{
m_Alpha = M_2PI / std::max(T(2), std::abs(m_Power));
}
m_AlphaDiv2 = m_Alpha / 2;
m_NeedPrecalcSumSquares = !Compat::m_Compat;
m_NeedPrecalcAngles = Compat::m_Compat;
} }
protected: protected:
@ -1482,12 +1597,13 @@ protected:
{ {
string prefix = Prefix(); string prefix = Prefix();
m_Params.clear(); m_Params.clear();
m_Params.push_back(ParamWithName<T>(&m_Power, prefix + "cropn_power", -5)); m_Params.push_back(ParamWithName<T>(&m_Power, prefix + "cropn_power", 5));
m_Params.push_back(ParamWithName<T>(&m_Radius, prefix + "cropn_radius", 1)); m_Params.push_back(ParamWithName<T>(&m_Radius, prefix + "cropn_radius", 1));
m_Params.push_back(ParamWithName<T>(&m_ScatterDist, prefix + "cropn_scatterdist")); m_Params.push_back(ParamWithName<T>(&m_ScatterDist, prefix + "cropn_scatterdist"));
m_Params.push_back(ParamWithName<T>(&m_Zero, prefix + "cropn_zero", 0, eParamType::INTEGER, 0, 1)); m_Params.push_back(ParamWithName<T>(&m_Zero, prefix + "cropn_zero"));
m_Params.push_back(ParamWithName<T>(true, &m_WorkPower, prefix + "cropn_workpower"));//Precalc. m_Params.push_back(ParamWithName<T>(true, &m_WorkPower, prefix + "cropn_workpower"));//Precalc.
m_Params.push_back(ParamWithName<T>(true, &m_Alpha, prefix + "cropn_alpha")); m_Params.push_back(ParamWithName<T>(true, &m_Alpha, prefix + "cropn_alpha"));
m_Params.push_back(ParamWithName<T>(true, &m_AlphaDiv2, prefix + "cropn_alpha_div_2"));
} }
private: private:
@ -1497,6 +1613,7 @@ private:
T m_Zero; T m_Zero;
T m_WorkPower;//Precalc. T m_WorkPower;//Precalc.
T m_Alpha; T m_Alpha;
T m_AlphaDiv2;
}; };
/// <summary> /// <summary>
@ -1655,13 +1772,13 @@ protected:
{ {
string prefix = Prefix(); string prefix = Prefix();
m_Params.clear(); m_Params.clear();
m_Params.push_back(ParamWithName<T>(&m_Mode, prefix + "blob2_mode", 0, eParamType::INTEGER, -1, 1)); m_Params.push_back(ParamWithName<T>(&m_Mode, prefix + "blob2_mode", T(0.5)));
m_Params.push_back(ParamWithName<T>(&m_N, prefix + "blob2_n", 5, eParamType::INTEGER)); m_Params.push_back(ParamWithName<T>(&m_N, prefix + "blob2_n", 1));
m_Params.push_back(ParamWithName<T>(&m_Radius, prefix + "blob2_radius")); m_Params.push_back(ParamWithName<T>(&m_Radius, prefix + "blob2_radius"));
m_Params.push_back(ParamWithName<T>(&m_Prescale, prefix + "blob2_prescale", 1)); m_Params.push_back(ParamWithName<T>(&m_Prescale, prefix + "blob2_prescale", 1));
m_Params.push_back(ParamWithName<T>(&m_Postscale, prefix + "blob2_postscale", T(0.5))); m_Params.push_back(ParamWithName<T>(&m_Postscale, prefix + "blob2_postscale", T(0.5)));
m_Params.push_back(ParamWithName<T>(&m_Symmetry, prefix + "blob2_symmetry", 0, eParamType::REAL, -1, 1)); m_Params.push_back(ParamWithName<T>(&m_Symmetry, prefix + "blob2_symmetry", 0, eParamType::REAL, -1, 1));
m_Params.push_back(ParamWithName<T>(&m_Compensation, prefix + "blob2_compensation", 0, eParamType::REAL, 0, 1)); m_Params.push_back(ParamWithName<T>(&m_Compensation, prefix + "blob2_compensation", 0));
m_Params.push_back(ParamWithName<T>(true, &m_DeltaHelp, prefix + "blob2_deltahelp"));//Precalc. m_Params.push_back(ParamWithName<T>(true, &m_DeltaHelp, prefix + "blob2_deltahelp"));//Precalc.
} }
@ -2688,11 +2805,24 @@ public:
{ {
T preX = helper.In.x * (m_XDistort + 1); T preX = helper.In.x * (m_XDistort + 1);
T preY = helper.In.y * (m_YDistort + 1); T preY = helper.In.y * (m_YDistort + 1);
T temp = std::atan2(preY, preX) * m_InvN + rand.Crand() * m_Inv2PiN;
T r = m_Weight * std::pow(helper.m_PrecalcSumSquares, m_Cn); if (Compat::m_Compat)
helper.Out.x = r * std::cos(temp); {
helper.Out.y = r * std::sin(temp); T temp = std::atan2(preY, preX) * m_InvN + rand.Crand() * m_Inv2PiN;
helper.Out.z = DefaultZ(helper); T r = m_Weight * std::pow(helper.m_PrecalcSumSquares, m_Cn);
helper.Out.x = r * std::cos(temp);
helper.Out.y = r * std::sin(temp);
helper.Out.z = m_Weight * helper.In.z;
}
else
{
int root = (int)(rand.Frand01<T>() * m_Power);
T a = std::atan2(preY, preX) * m_InvN + root * m_Inv2PiN;
T r = m_Weight * std::pow(helper.m_PrecalcSumSquares, m_Cn);
helper.Out.x = r * std::cos(a);
helper.Out.y = r * std::sin(a);
helper.Out.z = DefaultZ(helper);
}
} }
virtual string OpenCLString() const override virtual string OpenCLString() const override
@ -2710,15 +2840,32 @@ public:
string invN = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string invN = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
string inv2PiN = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string inv2PiN = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
ss << "\t{\n" ss << "\t{\n"
<< "\t\treal_t weight = " << weight << ";\n"
<< "\t\treal_t preX = vIn.x * (" << xDistort << " + 1);\n" << "\t\treal_t preX = vIn.x * (" << xDistort << " + 1);\n"
<< "\t\treal_t preY = vIn.y * (" << yDistort << " + 1);\n" << "\t\treal_t preY = vIn.y * (" << yDistort << " + 1);\n";
<< "\t\treal_t temp = fma(atan2(preY, preX), " << invN << ", MwcNextCrand(mwc) * " << inv2PiN << ");\n"
<< "\t\treal_t r = " << weight << " * pow(precalcSumSquares, " << cN << ");\n" if (Compat::m_Compat)
<< "\n" {
<< "\t\tvOut.x = r * cos(temp);\n" ss << "\t\treal_t temp = fma(atan2(preY, preX), " << invN << ", MwcNextCrand(mwc) * " << inv2PiN << ");\n"
<< "\t\tvOut.y = r * sin(temp);\n" << "\t\treal_t r = weight * pow(precalcSumSquares, " << cN << ");\n"
<< "\t\tvOut.z = " << DefaultZCl() << "\n"
<< "\t}\n"; << "\t\tvOut.x = r * cos(temp);\n"
<< "\t\tvOut.y = r * sin(temp);\n"
<< "\t\tvOut.z = weight * vIn.z;\n"
<< "\t}\n";
}
else
{
ss << "\t\tint root = (int)(MwcNext01(mwc) * " << power << ");\n"
<< "\t\treal_t temp = fma(atan2(preY, preX), " << invN << ", root * " << inv2PiN << ");\n"
<< "\t\treal_t r = weight * pow(precalcSumSquares, " << cN << ");\n"
<< "\n"
<< "\t\tvOut.x = r * cos(temp);\n"
<< "\t\tvOut.y = r * sin(temp);\n"
<< "\t\tvOut.z = weight * vIn.z;\n"
<< "\t}\n";
}
return ss.str(); return ss.str();
} }
@ -2727,7 +2874,7 @@ public:
auto zp = Zeps(m_Power); auto zp = Zeps(m_Power);
m_InvN = m_Dist / zp; m_InvN = m_Dist / zp;
m_Inv2PiN = M_2PI / zp; m_Inv2PiN = M_2PI / zp;
m_Cn = m_Dist / zp / 2; m_Cn = m_InvN / 2;
} }
protected: protected:
@ -3727,8 +3874,8 @@ protected:
{ {
string prefix = Prefix(); string prefix = Prefix();
m_Params.clear(); m_Params.clear();
m_Params.push_back(ParamWithName<T>(&m_A, prefix + "collideoscope_a", 0, eParamType::REAL_CYCLIC, 0, 1)); m_Params.push_back(ParamWithName<T>(&m_A, prefix + "collideoscope_a"));
m_Params.push_back(ParamWithName<T>(&m_Num, prefix + "collideoscope_num", 1, eParamType::INTEGER)); m_Params.push_back(ParamWithName<T>(&m_Num, prefix + "collideoscope_num", 1));
m_Params.push_back(ParamWithName<T>(true, &m_Ka, prefix + "collideoscope_ka"));//Precalc. m_Params.push_back(ParamWithName<T>(true, &m_Ka, prefix + "collideoscope_ka"));//Precalc.
m_Params.push_back(ParamWithName<T>(true, &m_KnPi, prefix + "collideoscope_kn_pi")); m_Params.push_back(ParamWithName<T>(true, &m_KnPi, prefix + "collideoscope_kn_pi"));
m_Params.push_back(ParamWithName<T>(true, &m_KaKn, prefix + "collideoscope_ka_kn")); m_Params.push_back(ParamWithName<T>(true, &m_KaKn, prefix + "collideoscope_ka_kn"));
@ -3972,7 +4119,7 @@ protected:
string prefix = Prefix(); string prefix = Prefix();
m_Params.clear(); m_Params.clear();
m_Params.push_back(ParamWithName<T>(&m_Rotate, prefix + "bTransform_rotate")); m_Params.push_back(ParamWithName<T>(&m_Rotate, prefix + "bTransform_rotate"));
m_Params.push_back(ParamWithName<T>(&m_Power, prefix + "bTransform_power", 1, eParamType::INTEGER, 1, T(INT_MAX))); m_Params.push_back(ParamWithName<T>(&m_Power, prefix + "bTransform_power", 0, eParamType::REAL_NONZERO, 1, T(INT_MAX)));
m_Params.push_back(ParamWithName<T>(&m_Move, prefix + "bTransform_move")); m_Params.push_back(ParamWithName<T>(&m_Move, prefix + "bTransform_move"));
m_Params.push_back(ParamWithName<T>(&m_Split, prefix + "bTransform_split")); m_Params.push_back(ParamWithName<T>(&m_Split, prefix + "bTransform_split"));
} }
@ -4060,9 +4207,9 @@ public:
virtual void Precalc() override virtual void Precalc() override
{ {
m_CnPi = m_Num * T(M_1_PI); m_CnPi = m_Num * T(M_1_PI);
m_PiCn = T(M_PI) / m_Num; m_PiCn = T(M_PI) / Zeps(m_Num);
m_Ca = T(M_PI) * m_A; m_Ca = T(M_PI) * m_A;
m_CaCn = m_Ca / m_Num; m_CaCn = m_Ca / Zeps(m_Num);
} }
protected: protected:
@ -4070,8 +4217,8 @@ protected:
{ {
string prefix = Prefix(); string prefix = Prefix();
m_Params.clear(); m_Params.clear();
m_Params.push_back(ParamWithName<T>(&m_A, prefix + "bCollide_a", 0, eParamType::REAL_CYCLIC, 0, 1)); m_Params.push_back(ParamWithName<T>(&m_A, prefix + "bCollide_a", 0, eParamType::REAL_CYCLIC, -1, 1));
m_Params.push_back(ParamWithName<T>(&m_Num, prefix + "bCollide_num", 1, eParamType::INTEGER, 1, T(INT_MAX))); m_Params.push_back(ParamWithName<T>(&m_Num, prefix + "bCollide_num", 1, eParamType::REAL, EPS, T(INT_MAX)));
m_Params.push_back(ParamWithName<T>(true, &m_Ca, prefix + "bCollide_ca"));//Precalc. m_Params.push_back(ParamWithName<T>(true, &m_Ca, prefix + "bCollide_ca"));//Precalc.
m_Params.push_back(ParamWithName<T>(true, &m_CnPi, prefix + "bCollide_cn_pi")); m_Params.push_back(ParamWithName<T>(true, &m_CnPi, prefix + "bCollide_cn_pi"));
m_Params.push_back(ParamWithName<T>(true, &m_CaCn, prefix + "bCollide_ca_cn")); m_Params.push_back(ParamWithName<T>(true, &m_CaCn, prefix + "bCollide_ca_cn"));
@ -4498,7 +4645,7 @@ public:
} }
else else
{ {
r2 = 1 / r2; r2 = 1 / Zeps(r2);
x = helper.In.x * r2; x = helper.In.x * r2;
} }
@ -4537,7 +4684,7 @@ public:
<< "\t\t}\n" << "\t\t}\n"
<< "\t\telse\n" << "\t\telse\n"
<< "\t\t{\n" << "\t\t{\n"
<< "\t\t r2 = 1 / r2;\n" << "\t\t r2 = 1 / Zeps(r2);\n"
<< "\t\t x = vIn.x * r2;\n" << "\t\t x = vIn.x * r2;\n"
<< "\t\t}\n" << "\t\t}\n"
<< "\n" << "\n"
@ -4566,7 +4713,7 @@ public:
virtual vector<string> OpenCLGlobalFuncNames() const override virtual vector<string> OpenCLGlobalFuncNames() const override
{ {
return vector<string> { "SafeSqrt" }; return vector<string> { "SafeSqrt", "Zeps" };
} }
virtual void Precalc() override virtual void Precalc() override
@ -4912,7 +5059,7 @@ public:
nu = fmod(nu + m_Rotate + T(M_PI), M_2PI) - T(M_PI); nu = fmod(nu + m_Rotate + T(M_PI), M_2PI) - T(M_PI);
helper.Out.x = m_Weight * xmax * std::cos(nu); helper.Out.x = m_Weight * xmax * std::cos(nu);
helper.Out.y = m_Weight * std::sqrt(xmax - 1) * std::sqrt(xmax + 1) * std::sin(nu); helper.Out.y = m_Weight * std::sqrt(xmax * xmax - 1) * std::sin(nu);
helper.Out.z = DefaultZ(helper); helper.Out.z = DefaultZ(helper);
} }
@ -4925,6 +5072,7 @@ public:
string weight = WeightDefineString(); string weight = WeightDefineString();
string rotate = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string rotate = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
ss << "\t{\n" ss << "\t{\n"
<< "\t\treal_t weight = " << weight << ";\n"
<< "\t\treal_t tmp = precalcSumSquares + 1;\n" << "\t\treal_t tmp = precalcSumSquares + 1;\n"
<< "\t\treal_t tmp2 = 2 * vIn.x;\n" << "\t\treal_t tmp2 = 2 * vIn.x;\n"
<< "\t\treal_t xmax = (SafeSqrt(tmp + tmp2) + SafeSqrt(tmp - tmp2)) * (real_t)(0.5);\n" << "\t\treal_t xmax = (SafeSqrt(tmp + tmp2) + SafeSqrt(tmp - tmp2)) * (real_t)(0.5);\n"
@ -4939,8 +5087,8 @@ public:
<< "\n" << "\n"
<< "\t\tnu = fmod(nu + " << rotate << " + MPI, M_2PI) - MPI;\n" << "\t\tnu = fmod(nu + " << rotate << " + MPI, M_2PI) - MPI;\n"
<< "\n" << "\n"
<< "\t\tvOut.x = " << weight << " * xmax * cos(nu);\n" << "\t\tvOut.x = weight * xmax * cos(nu);\n"
<< "\t\tvOut.y = " << weight << " * sqrt(xmax - 1) * sqrt(xmax + 1) * sin(nu);\n" << "\t\tvOut.y = weight * sqrt(xmax * xmax - 1) * sin(nu);\n"
<< "\t\tvOut.z = " << DefaultZCl() << "\t\tvOut.z = " << DefaultZCl()
<< "\t}\n"; << "\t}\n";
return ss.str(); return ss.str();

View File

@ -304,10 +304,10 @@ protected:
{ {
string prefix = Prefix(); string prefix = Prefix();
m_Params.clear(); m_Params.clear();
m_Params.push_back(ParamWithName<T>(&m_N, prefix + "lazyjess_n", 4, eParamType::INTEGER_NONZERO, 2)); m_Params.push_back(ParamWithName<T>(&m_N, prefix + "lazyjess_n", 4, eParamType::REAL_NONZERO, 2));
m_Params.push_back(ParamWithName<T>(&m_Spin, prefix + "lazyjess_spin", T(M_PI), eParamType::REAL_CYCLIC, 0, M_2PI)); m_Params.push_back(ParamWithName<T>(&m_Spin, prefix + "lazyjess_spin", T(M_PI)));
m_Params.push_back(ParamWithName<T>(&m_Space, prefix + "lazyjess_space")); m_Params.push_back(ParamWithName<T>(&m_Space, prefix + "lazyjess_space"));
m_Params.push_back(ParamWithName<T>(&m_Corner, prefix + "lazyjess_corner", 1, eParamType::INTEGER_NONZERO)); m_Params.push_back(ParamWithName<T>(&m_Corner, prefix + "lazyjess_corner", 1));
m_Params.push_back(ParamWithName<T>(true, &m_Vertex, prefix + "lazyjess_vertex"));//Precalc. m_Params.push_back(ParamWithName<T>(true, &m_Vertex, prefix + "lazyjess_vertex"));//Precalc.
m_Params.push_back(ParamWithName<T>(true, &m_SinVertex, prefix + "lazyjess_sin_vertex")); m_Params.push_back(ParamWithName<T>(true, &m_SinVertex, prefix + "lazyjess_sin_vertex"));
m_Params.push_back(ParamWithName<T>(true, &m_PieSlice, prefix + "lazyjess_pie_slice")); m_Params.push_back(ParamWithName<T>(true, &m_PieSlice, prefix + "lazyjess_pie_slice"));
@ -742,7 +742,7 @@ protected:
{ {
string prefix = Prefix(); string prefix = Prefix();
m_Params.clear(); m_Params.clear();
m_Params.push_back(ParamWithName<T>(&m_Power, prefix + "squish_power", 2, eParamType::INTEGER, 2, T(INT_MAX))); m_Params.push_back(ParamWithName<T>(&m_Power, prefix + "squish_power", 2, eParamType::REAL_NONZERO, 2));
m_Params.push_back(ParamWithName<T>(true, &m_InvPower, prefix + "squish_inv_power"));//Precalc. m_Params.push_back(ParamWithName<T>(true, &m_InvPower, prefix + "squish_inv_power"));//Precalc.
} }
@ -1800,7 +1800,7 @@ protected:
{ {
string prefix = Prefix(); string prefix = Prefix();
m_Params.clear(); m_Params.clear();
m_Params.push_back(ParamWithName<T>(&m_Slices, prefix + "waffle_slices", 6, eParamType::INTEGER_NONZERO)); m_Params.push_back(ParamWithName<T>(&m_Slices, prefix + "waffle_slices", 6, eParamType::REAL_NONZERO));
m_Params.push_back(ParamWithName<T>(&m_XThickness, prefix + "waffle_xthickness", T(0.5))); m_Params.push_back(ParamWithName<T>(&m_XThickness, prefix + "waffle_xthickness", T(0.5)));
m_Params.push_back(ParamWithName<T>(&m_YThickness, prefix + "waffle_ythickness", T(0.5))); m_Params.push_back(ParamWithName<T>(&m_YThickness, prefix + "waffle_ythickness", T(0.5)));
m_Params.push_back(ParamWithName<T>(&m_Rotation, prefix + "waffle_rotation")); m_Params.push_back(ParamWithName<T>(&m_Rotation, prefix + "waffle_rotation"));
@ -2156,8 +2156,9 @@ public:
{ {
T xi = helper.In.x - m_X; T xi = helper.In.x - m_X;
T yi = helper.In.y - m_Y; T yi = helper.In.y - m_Y;
auto b = Compat::m_Compat && m_VarType == eVariationType::VARTYPE_REG;
if (m_VarType == eVariationType::VARTYPE_REG)//Original altered the input pointed to for reg. if (b)//Original altered the input pointed to for reg.
{ {
helper.m_TransX -= m_X; helper.m_TransX -= m_X;
helper.m_TransY -= m_Y; helper.m_TransY -= m_Y;
@ -2169,31 +2170,29 @@ public:
} }
const T rad = std::sqrt(SQR(xi) + SQR(yi)); const T rad = std::sqrt(SQR(xi) + SQR(yi));
const T ang = std::atan2(yi, xi);
const T rdc = m_Radius + (rand.Frand01<T>() * T(0.5) * m_Ca); const T rdc = m_Radius + (rand.Frand01<T>() * T(0.5) * m_Ca);
const T s = std::sin(ang);
const T c = std::cos(ang);
const int esc = rad > m_Radius; const int esc = rad > m_Radius;
const int cr0 = int(m_Zero); const int cr0 = int(m_Zero);
if (cr0 && esc) if (esc)
{ {
helper.Out.x = helper.Out.y = 0; if (cr0)
{
helper.Out.x = helper.Out.y = 0;
if (m_VarType == eVariationType::VARTYPE_REG) if (b)
outPoint.m_X = outPoint.m_Y = 0; outPoint.m_X = outPoint.m_Y = 0;
}
else
{
const T ang = std::atan2(yi, xi);
const T s = std::sin(ang);
const T c = std::cos(ang);
helper.Out.x = m_Weight * rdc * c + m_X;
helper.Out.y = m_Weight * rdc * s + m_Y;
}
} }
else if (cr0 && !esc) else
{
helper.Out.x = m_Weight * xi + m_X;
helper.Out.y = m_Weight * yi + m_Y;
}
else if (!cr0 && esc)
{
helper.Out.x = m_Weight * rdc * c + m_X;
helper.Out.y = m_Weight * rdc * s + m_Y;
}
else if (!cr0 && !esc)
{ {
helper.Out.x = m_Weight * xi + m_X; helper.Out.x = m_Weight * xi + m_X;
helper.Out.y = m_Weight * yi + m_Y; helper.Out.y = m_Weight * yi + m_Y;
@ -2213,59 +2212,57 @@ public:
string scatterArea = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string scatterArea = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
string zero = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string zero = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
string ca = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string ca = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
auto b = Compat::m_Compat && m_VarType == eVariationType::VARTYPE_REG;
ss << "\t{\n" ss << "\t{\n"
<< "\t\treal_t xi = vIn.x - " << x << ";\n" << "\t\treal_t x = " << x << ";\n"
<< "\t\treal_t yi = vIn.y - " << y << ";\n" << "\t\treal_t y = " << y << ";\n"
<< "\t\treal_t radius = " << radius << ";\n"
<< "\t\treal_t xi = vIn.x - x;\n"
<< "\t\treal_t yi = vIn.y - y;\n"
<< "\t\treal_t weight = " << weight << ";\n"
<< "\n"; << "\n";
if (m_VarType == eVariationType::VARTYPE_REG)//Original altered the input pointed to for reg. if (b)//Original altered the input pointed to for reg.
{ {
ss ss << "\t\ttransX -= x;\n"
<< "\t\ttransX -= " << x << ";\n" << "\t\ttransY -= y;\n"
<< "\t\ttransY -= " << y << ";\n" << "\t\tvOut.z = weight * vIn.z;\n";
<< "\t\tvOut.z = " << weight << " * vIn.z;\n";
} }
else else
{ {
ss ss << "\t\tvOut.z = vIn.z;\n";
<< "\t\tvOut.z = vIn.z;\n";
} }
ss ss << "\t\tconst real_t rad = sqrt(SQR(xi) + SQR(yi));\n"
<< "\t\tconst real_t rad = sqrt(SQR(xi) + SQR(yi));\n" << "\t\tconst real_t rdc = fma(MwcNext01(mwc) * (real_t)(0.5), " << ca << ", radius);\n"
<< "\t\tconst real_t ang = atan2(yi, xi);\n" << "\t\tconst int esc = rad > radius;\n"
<< "\t\tconst real_t rdc = fma(MwcNext01(mwc) * (real_t)(0.5), " << ca << ", " << radius << ");\n" << "\t\tconst int cr0 = (int)" << zero << ";\n"
<< "\t\tconst real_t s = sin(ang);\n" << "\n"
<< "\t\tconst real_t c = cos(ang);\n" << "\t\tif (esc)\n"
<< "\n" << "\t\t{\n"
<< "\t\tconst int esc = rad > " << radius << ";\n" << "\t\t if (cr0)\n"
<< "\t\tconst int cr0 = (int)" << zero << ";\n" << "\t\t {\n"
<< "\n" << "\t\t vOut.x = vOut.y = 0;\n";
<< "\t\tif (cr0 && esc)\n"
<< "\t\t{\n"
<< "\t\t vOut.x = vOut.y = 0;\n";
if (m_VarType == eVariationType::VARTYPE_REG) if (b)
ss << "\t\t outPoint->m_X = outPoint->m_Y = 0;\n"; ss << "\t\t outPoint->m_X = outPoint->m_Y = 0;\n";
ss ss << "\t\t }\n"
<< "\t\t}\n" << "\t\t else\n"
<< "\t\telse if (cr0 && !esc)\n" << "\t\t {\n"
<< "\t\t{\n" << "\t\t const real_t ang = atan2(yi, xi);\n"
<< "\t\t vOut.x = fma(" << weight << ", xi, " << x << ");\n" << "\t\t const real_t s = sin(ang);\n"
<< "\t\t vOut.y = fma(" << weight << ", yi, " << y << ");\n" << "\t\t const real_t c = cos(ang);\n"
<< "\t\t}\n" << "\t\t vOut.x = fma(weight, rdc * c, x);\n"
<< "\t\telse if (!cr0 && esc)\n" << "\t\t vOut.y = fma(weight, rdc * s, y);\n"
<< "\t\t{\n" << "\t\t }\n"
<< "\t\t vOut.x = fma(" << weight << ", rdc * c, " << x << ");\n" << "\t\t}\n"
<< "\t\t vOut.y = fma(" << weight << ", rdc * s, " << y << ");\n" << "\t\telse\n"
<< "\t\t}\n" << "\t\t{\n"
<< "\t\telse if (!cr0 && !esc)\n" << "\t\t vOut.x = fma(weight, xi, x);\n"
<< "\t\t{\n" << "\t\t vOut.y = fma(weight, yi, y);\n"
<< "\t\t vOut.x = fma(" << weight << ", xi, " << x << ");\n" << "\t\t}\n"
<< "\t\t vOut.y = fma(" << weight << ", yi, " << y << ");\n" << "\t}\n";
<< "\t\t}\n"
<< "\t}\n";
return ss.str(); return ss.str();
} }
@ -2283,7 +2280,7 @@ protected:
m_Params.push_back(ParamWithName<T>(&m_X, prefix + "circlecrop_x")); m_Params.push_back(ParamWithName<T>(&m_X, prefix + "circlecrop_x"));
m_Params.push_back(ParamWithName<T>(&m_Y, prefix + "circlecrop_y")); m_Params.push_back(ParamWithName<T>(&m_Y, prefix + "circlecrop_y"));
m_Params.push_back(ParamWithName<T>(&m_ScatterArea, prefix + "circlecrop_scatter_area")); m_Params.push_back(ParamWithName<T>(&m_ScatterArea, prefix + "circlecrop_scatter_area"));
m_Params.push_back(ParamWithName<T>(&m_Zero, prefix + "circlecrop_zero", 1, eParamType::INTEGER, 0, 1)); m_Params.push_back(ParamWithName<T>(&m_Zero, prefix + "circlecrop_zero", 1, eParamType::REAL, 0, 1));
m_Params.push_back(ParamWithName<T>(true, &m_Ca, prefix + "circlecrop_ca"));//Precalc. m_Params.push_back(ParamWithName<T>(true, &m_Ca, prefix + "circlecrop_ca"));//Precalc.
} }
@ -2391,7 +2388,7 @@ protected:
m_Params.clear(); m_Params.clear();
m_Params.push_back(ParamWithName<T>(&m_Inner, prefix + "circlecrop2_inner", T(0.5))); m_Params.push_back(ParamWithName<T>(&m_Inner, prefix + "circlecrop2_inner", T(0.5)));
m_Params.push_back(ParamWithName<T>(&m_Outer, prefix + "circlecrop2_outer", 1)); m_Params.push_back(ParamWithName<T>(&m_Outer, prefix + "circlecrop2_outer", 1));
m_Params.push_back(ParamWithName<T>(&m_Zero, prefix + "circlecrop2_zero", 1, eParamType::INTEGER, 0, 1)); m_Params.push_back(ParamWithName<T>(&m_Zero, prefix + "circlecrop2_zero", 1, eParamType::REAL, 0, 1));
m_Params.push_back(ParamWithName<T>(true, &m_In, prefix + "circlecrop2_in"));//Precalc. m_Params.push_back(ParamWithName<T>(true, &m_In, prefix + "circlecrop2_in"));//Precalc.
m_Params.push_back(ParamWithName<T>(true, &m_Out, prefix + "circlecrop2_out")); m_Params.push_back(ParamWithName<T>(true, &m_Out, prefix + "circlecrop2_out"));
m_Params.push_back(ParamWithName<T>(true, &m_OutWeight, prefix + "circlecrop2_out_weight")); m_Params.push_back(ParamWithName<T>(true, &m_OutWeight, prefix + "circlecrop2_out_weight"));
@ -3000,7 +2997,9 @@ public:
helper.Out.x = (x * re + y * im) * r; helper.Out.x = (x * re + y * im) * r;
helper.Out.y = (y * re - x * im) * r; helper.Out.y = (y * re - x * im) * r;
helper.Out.z = (z * m_Weight) / c; helper.Out.z = (z * m_Weight) / c;
outPoint.m_ColorX = Clamp<T>(outPoint.m_ColorX + m_DcAdjust * c, 0, 1);
if (Compat::m_Compat)
outPoint.m_ColorX = Clamp<T>(outPoint.m_ColorX + m_DcAdjust * c, 0, 1);
} }
virtual string OpenCLString() const override virtual string OpenCLString() const override
@ -3020,21 +3019,27 @@ public:
string dcAdjust = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string dcAdjust = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
string powerInv = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string powerInv = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
ss << "\t{\n" ss << "\t{\n"
<< "\t\tconst real_t x = Powq4c(vIn.x, " << power << ");\n" << "\t\treal_t weight = " << weight << ";\n"
<< "\t\tconst real_t y = Powq4c(vIn.y, " << power << ");\n" << "\t\treal_t power = " << power << ";\n"
<< "\t\tconst real_t z = Powq4c(vIn.z, " << power << ");\n" << "\t\treal_t c1 = " << c1 << ";\n"
<< "\t\tconst real_t x = Powq4c(vIn.x, power);\n"
<< "\t\tconst real_t y = Powq4c(vIn.y, power);\n"
<< "\t\tconst real_t z = Powq4c(vIn.z, power);\n"
<< "\t\tconst real_t d = fma(x, x, -SQR(y));\n" << "\t\tconst real_t d = fma(x, x, -SQR(y));\n"
<< "\t\tconst real_t re = Spread(fma(" << c1 << ", x, " << c2 << " * d), " << sx << ") + (real_t)(1.0);\n" << "\t\tconst real_t re = Spread(fma(c1, x, " << c2 << " * d), " << sx << ") + (real_t)(1.0);\n"
<< "\t\tconst real_t im = Spread(fma(" << c1 << ", y, " << c2x2 << " * x * y), " << sy << ");\n" << "\t\tconst real_t im = Spread(fma(c1, y, " << c2x2 << " * x * y), " << sy << ");\n"
<< "\t\treal_t c = Zeps(Powq4c(fma(re, re, SQR(im)), " << powerInv << "));\n" << "\t\treal_t c = Zeps(Powq4c(fma(re, re, SQR(im)), " << powerInv << "));\n"
<< "\n" << "\n"
<< "\t\tconst real_t r = " << weight << " / c;\n" << "\t\tconst real_t r = weight / c;\n"
<< "\n" << "\n"
<< "\t\tvOut.x = fma(x, re, y * im) * r;\n" << "\t\tvOut.x = fma(x, re, y * im) * r;\n"
<< "\t\tvOut.y = fma(y, re, -(x * im)) * r;\n" << "\t\tvOut.y = fma(y, re, -(x * im)) * r;\n"
<< "\t\tvOut.z = (z * " << weight << ") / c;\n" << "\t\tvOut.z = (z * weight) / c;\n";
<< "\t\toutPoint->m_ColorX = clamp(fma(" << dcAdjust << ", c, outPoint->m_ColorX), (real_t)(0.0), (real_t)(1.0));\n"
<< "\t}\n"; if (Compat::m_Compat)
ss << "\t\toutPoint->m_ColorX = clamp(fma(" << dcAdjust << ", c, outPoint->m_ColorX), (real_t)(0.0), (real_t)(1.0));\n";
ss << "\t}\n";
return ss.str(); return ss.str();
} }
@ -4404,7 +4409,7 @@ protected:
string prefix = Prefix(); string prefix = Prefix();
m_Params.clear(); m_Params.clear();
m_Params.push_back(ParamWithName<T>(&m_P, prefix + "blur_heart_p", T(0.5))); m_Params.push_back(ParamWithName<T>(&m_P, prefix + "blur_heart_p", T(0.5)));
m_Params.push_back(ParamWithName<T>(&m_A, prefix + "blur_heart_a", T(-T(0.6)))); m_Params.push_back(ParamWithName<T>(&m_A, prefix + "blur_heart_a", T(-0.6)));
m_Params.push_back(ParamWithName<T>(&m_B, prefix + "blur_heart_b", T(0.7))); m_Params.push_back(ParamWithName<T>(&m_B, prefix + "blur_heart_b", T(0.7)));
} }
@ -4430,9 +4435,9 @@ public:
virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override
{ {
int extended = int(m_Extended); bool extended = int(m_Extended) == 0 || !Compat::m_Compat;
T seed = m_AbsSeed; T seed = m_AbsSeed;
T r = -m_Rotation; T r;
T r0 = 0; T r0 = 0;
T r1 = 0; T r1 = 0;
T tileType = 0; T tileType = 0;
@ -4445,7 +4450,6 @@ public:
T y = helper.In.y * m_Scale; T y = helper.In.y * m_Scale;
int intx = int(Round(x)); int intx = int(Round(x));
int inty = int(Round(y)); int inty = int(Round(y));
int randiter;
r = x - intx; r = x - intx;
if (r < 0) if (r < 0)
@ -4467,24 +4471,22 @@ public:
tileType = 1; tileType = 1;
else else
{ {
if (extended == 0) if (extended)
{ {
T xrand = Round(helper.In.x); T xrand = Round(helper.In.x) * m_Seed2;
T yrand = Round(helper.In.y); T yrand = Round(helper.In.y) * m_Seed2;
xrand = xrand * m_Seed2;
yrand = yrand * m_Seed2;
niter = xrand + yrand + xrand * yrand; niter = xrand + yrand + xrand * yrand;
randInt = (niter + seed) * m_Seed2 / 2; randInt = (niter + seed) * m_Seed2 * T(0.5);
randInt = fmod((randInt * multiplier + offset), modBase); randInt = fmod((randInt * multiplier + offset), modBase);
} }
else else
{ {
int randiter = 0;
int xrand = int(Round(helper.In.x)); int xrand = int(Round(helper.In.x));
int yrand = int(Round(helper.In.y)); int yrand = int(Round(helper.In.y));
seed = T(Floor<T>(seed)); seed = T(Floor<T>(seed));
niter = T(abs(xrand + yrand + xrand * yrand)); niter = T(std::abs(xrand + yrand + xrand * yrand));
randInt = seed + niter; randInt = seed + niter;
randiter = 0;
while (randiter < niter && randiter < 20)//Allow it to escape. while (randiter < niter && randiter < 20)//Allow it to escape.
{ {
@ -4496,34 +4498,38 @@ public:
tileType = fmod(randInt, T(2)); tileType = fmod(randInt, T(2));
} }
T xval1, xval2;
//Drawing the points. //Drawing the points.
if (extended == 0)//Fast drawmode if (extended)//Fast drawmode.
{ {
if (tileType < 1) if (tileType < 1)
{ {
r0 = std::pow((pow(std::abs(x), m_Exponent) + std::pow(std::abs(y), m_Exponent)), m_OneOverEx); xval1 = x;
r1 = std::pow((pow(std::abs(x - 1), m_Exponent) + std::pow(std::abs(y - 1), m_Exponent)), m_OneOverEx); xval2 = x - 1;
} }
else else
{ {
r0 = std::pow((pow(std::abs(x - 1), m_Exponent) + std::pow(std::abs(y), m_Exponent)), m_OneOverEx); xval1 = x - 1;
r1 = std::pow((pow(std::abs(x), m_Exponent) + std::pow(std::abs(y - 1), m_Exponent)), m_OneOverEx); xval2 = x;
} }
} }
else//Slow drawmode else//Slow drawmode.
{ {
if (tileType == 1) if (tileType == 1)
{ {
r0 = std::pow((std::pow(std::abs(x), m_Exponent) + std::pow(std::abs(y), m_Exponent)), m_OneOverEx); xval1 = x;
r1 = std::pow((std::pow(std::abs(x - 1), m_Exponent) + std::pow(std::abs(y - 1), m_Exponent)), m_OneOverEx); xval2 = x - 1;
} }
else else
{ {
r0 = std::pow((std::pow(std::abs(x - 1), m_Exponent) + std::pow(std::abs(y), m_Exponent)), m_OneOverEx); xval1 = x - 1;
r1 = std::pow((std::pow(std::abs(x), m_Exponent) + std::pow(std::abs(y - 1), m_Exponent)), m_OneOverEx); xval2 = x;
} }
} }
r0 = std::pow((std::pow(std::abs(xval1), m_Exponent) + std::pow(std::abs(y), m_Exponent)), m_OneOverEx);
r1 = std::pow((std::pow(std::abs(xval2), m_Exponent) + std::pow(std::abs(y - 1), m_Exponent)), m_OneOverEx);
r = std::abs(r0 - T(0.5)) * m_OneOverRmax; r = std::abs(r0 - T(0.5)) * m_OneOverRmax;
if (r < 1) if (r < 1)
@ -4569,7 +4575,11 @@ public:
ss << "\t{\n" ss << "\t{\n"
<< "\t\tint extended = (int)" << extended << ";\n" << "\t\tint extended = (int)" << extended << ";\n"
<< "\t\treal_t seed = " << absSeed << ";\n" << "\t\treal_t seed = " << absSeed << ";\n"
<< "\t\treal_t r = -" << rotation << ";\n" << "\t\treal_t seed2 = " << seed2 << ";\n"
<< "\t\treal_t exponent = " << exponent << ";\n"
<< "\t\treal_t oneOverEx = " << oneOverEx << ";\n"
<< "\t\treal_t size = " << size << ";\n"
<< "\t\treal_t oneOverRmax = " << oneOverRmax << ";\n"
<< "\t\treal_t r0 = 0;\n" << "\t\treal_t r0 = 0;\n"
<< "\t\treal_t r1 = 0;\n" << "\t\treal_t r1 = 0;\n"
<< "\t\treal_t tileType = 0;\n" << "\t\treal_t tileType = 0;\n"
@ -4582,9 +4592,7 @@ public:
<< "\t\treal_t y = vIn.y * " << scale << ";\n" << "\t\treal_t y = vIn.y * " << scale << ";\n"
<< "\t\tint intx = (int)Round(x);\n" << "\t\tint intx = (int)Round(x);\n"
<< "\t\tint inty = (int)Round(y);\n" << "\t\tint inty = (int)Round(y);\n"
<< "\t\tint randiter;\n" << "\t\treal_t r = x - intx;\n"
<< "\n"
<< "\t\tr = x - intx;\n"
<< "\n" << "\n"
<< "\t\tif (r < 0)\n" << "\t\tif (r < 0)\n"
<< "\t\t x = 1 + r;\n" << "\t\t x = 1 + r;\n"
@ -4603,71 +4611,84 @@ public:
<< "\t\telse if (seed == 1)\n" << "\t\telse if (seed == 1)\n"
<< "\t\t tileType = 1;\n" << "\t\t tileType = 1;\n"
<< "\t\telse\n" << "\t\telse\n"
<< "\t\t{\n" << "\t\t{\n";
<< "\t\t if (extended == 0)\n"
<< "\t\t {\n" if (Compat::m_Compat)
<< "\t\t real_t xrand = Round(vIn.x);\n" ss << "\t\t if (extended == 0)\n"
<< "\t\t real_t yrand = Round(vIn.y);\n" << "\t\t {\n";
<< "\n"
<< "\t\t xrand = xrand * " << seed2 << ";\n" ss << "\t\t real_t xrand = Round(vIn.x) * seed2;\n"
<< "\t\t yrand = yrand * " << seed2 << ";\n" << "\t\t real_t yrand = Round(vIn.y) * seed2;\n"
<< "\t\t niter = fma(xrand, yrand, xrand + yrand);\n" << "\t\t niter = fma(xrand, yrand, xrand + yrand);\n"
<< "\t\t randInt = (niter + seed) * " << seed2 << " / 2;\n" << "\t\t randInt = (niter + seed) * seed2 * (real_t)(0.5);\n"
<< "\t\t randInt = fmod(fma(randInt, multiplier, offset), modBase);\n" << "\t\t randInt = fmod(fma(randInt, multiplier, offset), modBase);\n";
if (Compat::m_Compat)
ss << "\t\t }\n"
<< "\t\t else\n"
<< "\t\t {\n"
<< "\t\t int xrand = (int)Round(vIn.x);\n"
<< "\t\t int yrand = (int)Round(vIn.y);\n"
<< "\n"
<< "\t\t seed = floor(seed);\n"
<< "\t\t niter = (real_t)abs(xrand + yrand + xrand * yrand);\n"
<< "\t\t randInt = seed + niter;\n"
<< "\t\t int randiter = 0;\n"
<< "\n"
<< "\t\t while (randiter < niter && randiter < 20)\n"
<< "\t\t {\n"
<< "\t\t randiter++;\n"
<< "\t\t randInt = fmod(fma(randInt, multiplier, offset), modBase);\n"
<< "\t\t }\n"
<< "\t\t }\n"
<< "\n";
ss << "\t\t tileType = fmod(randInt, 2);\n"
<< "\t\t}\n"
<< "\n"
<< "\t\treal_t xval1, xval2;\n"
<< "\n";
if (Compat::m_Compat)
ss << "\t\tif(extended == 0)\n"
<< "\t\t{\n";
ss << "\t\t if (tileType < 1)\n"
<< "\t\t {\n"
<< "\t\t xval1 = x;\n"
<< "\t\t xval2 = x - 1;\n"
<< "\t\t }\n" << "\t\t }\n"
<< "\t\t else\n" << "\t\t else\n"
<< "\t\t {\n" << "\t\t {\n"
<< "\t\t int xrand = (int)Round(vIn.x);\n" << "\t\t xval1 = x - 1;\n"
<< "\t\t int yrand = (int)Round(vIn.y);\n" << "\t\t xval2 = x;\n"
<< "\n" << "\t\t }\n";
<< "\t\t seed = floor(seed);\n"
<< "\t\t niter = (real_t)abs(xrand + yrand + xrand * yrand);\n" if (Compat::m_Compat)
<< "\t\t randInt = seed + niter;\n" ss << "\t\t}\n"
<< "\t\t randiter = 0;\n" << "\t\telse\n"
<< "\n" << "\t\t{\n"
<< "\t\t while (randiter < niter && randiter < 20)\n" << "\t\t if (tileType == 1)\n"
<< "\t\t {\n" << "\t\t {\n"
<< "\t\t randiter++;\n" << "\t\t xval1 = x;\n"
<< "\t\t randInt = fmod((randInt * multiplier + offset), modBase);\n" << "\t\t xval2 = x - 1;\n"
<< "\t\t }\n" << "\t\t }\n"
<< "\t\t }\n" << "\t\t else\n"
<< "\n" << "\t\t {\n"
<< "\t\t tileType = fmod(randInt, 2);\n" << "\t\t xval1 = x - 1;\n"
<< "\t\t}\n" << "\t\t xval2 = x;\n"
<< "\n" << "\t\t }\n"
<< "\t\tif (extended == 0)\n" << "\t\t}\n";
<< "\t\t{\n"
<< "\t\t if (tileType < 1)\n" ss << "\n"
<< "\t\t {\n" << "\t\tr0 = pow((pow(fabs(xval1), exponent) + pow(fabs(y ), exponent)), oneOverEx);\n"
<< "\t\t r0 = pow((pow(fabs(x ), " << exponent << ") + pow(fabs(y ), " << exponent << ")), " << oneOverEx << ");\n" << "\t\tr1 = pow((pow(fabs(xval2), exponent) + pow(fabs(y - 1), exponent)), oneOverEx);\n"
<< "\t\t r1 = pow((pow(fabs(x - 1), " << exponent << ") + pow(fabs(y - 1), " << exponent << ")), " << oneOverEx << ");\n" << "\t\tr = fabs(r0 - (real_t)(0.5)) * oneOverRmax;\n"
<< "\t\t }\n"
<< "\t\t else\n"
<< "\t\t {\n"
<< "\t\t r0 = pow((pow(fabs(x - 1), " << exponent << ") + pow(fabs(y ), " << exponent << ")), " << oneOverEx << ");\n"
<< "\t\t r1 = pow((pow(fabs(x ), " << exponent << ") + pow(fabs(y - 1), " << exponent << ")), " << oneOverEx << ");\n"
<< "\t\t }\n"
<< "\t\t}\n"
<< "\t\telse\n"
<< "\t\t{\n"
<< "\t\t if (tileType == 1)\n"
<< "\t\t {\n"
<< "\t\t r0 = pow((pow(fabs(x ), " << exponent << ") + pow(fabs(y ), " << exponent << ")), " << oneOverEx << ");\n"
<< "\t\t r1 = pow((pow(fabs(x - 1), " << exponent << ") + pow(fabs(y - 1), " << exponent << ")), " << oneOverEx << ");\n"
<< "\t\t }\n"
<< "\t\t else\n"
<< "\t\t {\n"
<< "\t\t r0 = pow((pow(fabs(x - 1), " << exponent << ") + pow(fabs(y ), " << exponent << ")), " << oneOverEx << ");\n"
<< "\t\t r1 = pow((pow(fabs(x ), " << exponent << ") + pow(fabs(y - 1), " << exponent << ")), " << oneOverEx << ");\n"
<< "\t\t }\n"
<< "\t\t}\n"
<< "\n"
<< "\t\tr = fabs(r0 - (real_t)(0.5)) * " << oneOverRmax << ";\n"
<< "\n" << "\n"
<< "\t\tif (r < 1)\n" << "\t\tif (r < 1)\n"
<< "\t\t{\n" << "\t\t{\n"
<< "\t\t vOut.x = " << size << " * (x + floor(vIn.x));\n" << "\t\t vOut.x = size * (x + floor(vIn.x));\n"
<< "\t\t vOut.y = " << size << " * (y + floor(vIn.y));\n" << "\t\t vOut.y = size * (y + floor(vIn.y));\n"
<< "\t\t}\n" << "\t\t}\n"
<< "\t\telse\n" << "\t\telse\n"
<< "\t\t{\n" << "\t\t{\n"
@ -4675,12 +4696,12 @@ public:
<< "\t\t vOut.y = (real_t)(0.0);\n" << "\t\t vOut.y = (real_t)(0.0);\n"
<< "\t\t}\n" << "\t\t}\n"
<< "\n" << "\n"
<< "\t\tr = fabs(r1 - (real_t)(0.5)) * " << oneOverRmax << ";\n" << "\t\tr = fabs(r1 - (real_t)(0.5)) * oneOverRmax;\n"
<< "\n" << "\n"
<< "\t\tif (r < 1)\n" << "\t\tif (r < 1)\n"
<< "\t\t{\n" << "\t\t{\n"
<< "\t\t vOut.x += " << size << " * (x + floor(vIn.x));\n" << "\t\t vOut.x += size * (x + floor(vIn.x));\n"
<< "\t\t vOut.y += " << size << " * (y + floor(vIn.y));\n" << "\t\t vOut.y += size * (y + floor(vIn.y));\n"
<< "\t\t}\n" << "\t\t}\n"
<< "\n" << "\n"
<< "\t\tvOut.z = " << DefaultZCl() << "\t\tvOut.z = " << DefaultZCl()
@ -4695,11 +4716,13 @@ public:
virtual void Precalc() override virtual void Precalc() override
{ {
m_Exponent = Clamp<T>(m_Exponent, EPS, 2);
m_ArcWidth = Clamp<T>(m_Exponent, EPS, 1);
m_OneOverEx = 1 / m_Exponent; m_OneOverEx = 1 / m_Exponent;
m_AbsSeed = std::abs(m_Seed); m_AbsSeed = std::abs(m_Seed);
m_Seed2 = std::sqrt(Zeps(m_AbsSeed + (m_AbsSeed / 2))) / Zeps((m_AbsSeed * T(0.5))) * T(0.25); m_Seed2 = std::sqrt(Zeps(m_AbsSeed * T(1.5))) / Zeps((m_AbsSeed * T(0.5))) * T(0.25);
m_OneOverRmax = 1 / (T(0.5) * (std::pow(T(2), 1 / m_Exponent) - 1) * m_ArcWidth); m_OneOverRmax = 1 / (T(0.5) * (std::pow(T(2), m_OneOverEx) - 1) * m_ArcWidth);
m_Scale = (std::cos(-m_Rotation) - std::sin(-m_Rotation)) / m_Weight; m_Scale = (std::cos(m_Rotation) + std::sin(m_Rotation)) / m_Weight;
} }
protected: protected:
@ -4707,11 +4730,11 @@ protected:
{ {
string prefix = Prefix(); string prefix = Prefix();
m_Params.clear(); m_Params.clear();
m_Params.push_back(ParamWithName<T>(&m_Extended, prefix + "Truchet_extended", 0, eParamType::INTEGER, 0, 1)); m_Params.push_back(ParamWithName<T>(&m_Extended, prefix + "Truchet_extended", 1));
m_Params.push_back(ParamWithName<T>(&m_Exponent, prefix + "Truchet_exponent", 2, eParamType::REAL_CYCLIC, T(0.001), 2)); m_Params.push_back(ParamWithName<T>(&m_Exponent, prefix + "Truchet_exponent", 2, eParamType::REAL_NONZERO, EPS, 2));
m_Params.push_back(ParamWithName<T>(&m_ArcWidth, prefix + "Truchet_arc_width", T(0.5), eParamType::REAL_CYCLIC, T(0.001), 1)); m_Params.push_back(ParamWithName<T>(&m_ArcWidth, prefix + "Truchet_arc_width", T(0.5), eParamType::REAL_NONZERO, EPS, 1));
m_Params.push_back(ParamWithName<T>(&m_Rotation, prefix + "Truchet_rotation")); m_Params.push_back(ParamWithName<T>(&m_Rotation, prefix + "Truchet_rotation"));
m_Params.push_back(ParamWithName<T>(&m_Size, prefix + "Truchet_size", 1, eParamType::REAL_CYCLIC, T(0.001), 10)); m_Params.push_back(ParamWithName<T>(&m_Size, prefix + "Truchet_size", 1, eParamType::REAL, EPS));
m_Params.push_back(ParamWithName<T>(&m_Seed, prefix + "Truchet_seed", 50)); m_Params.push_back(ParamWithName<T>(&m_Seed, prefix + "Truchet_seed", 50));
m_Params.push_back(ParamWithName<T>(true, &m_OneOverEx, prefix + "Truchet_one_over_ex"));//Precalc. m_Params.push_back(ParamWithName<T>(true, &m_OneOverEx, prefix + "Truchet_one_over_ex"));//Precalc.
m_Params.push_back(ParamWithName<T>(true, &m_AbsSeed, prefix + "Truchet_abs_seed")); m_Params.push_back(ParamWithName<T>(true, &m_AbsSeed, prefix + "Truchet_abs_seed"));

View File

@ -1429,51 +1429,90 @@ template <typename T>
class Loonie2Variation : public ParametricVariation<T> class Loonie2Variation : public ParametricVariation<T>
{ {
public: public:
using Variation<T>::m_NeedPrecalcSumSquares;
using Variation<T>::m_NeedPrecalcSqrtSumSquares;
Loonie2Variation(T weight = 1.0) : ParametricVariation<T>("loonie2", eVariationId::VAR_LOONIE2, weight, true, true) Loonie2Variation(T weight = 1.0) : ParametricVariation<T>("loonie2", eVariationId::VAR_LOONIE2, weight, true, true)
{ {
Init(); Init();
m_NeedPrecalcSqrtSumSquares = Compat::m_Compat;
} }
PARVARCOPY(Loonie2Variation) PARVARCOPY(Loonie2Variation)
virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override
{ {
int i; if (Compat::m_Compat)
T xrt = helper.In.x, yrt = helper.In.y, swp;
T r2 = xrt * m_Coss + std::abs(yrt) * m_Sins;
T circle = helper.m_PrecalcSqrtSumSquares;
for (i = 0; i < m_Sides - 1; i++)
{ {
swp = xrt * m_Cosa - yrt * m_Sina; int i;
yrt = xrt * m_Sina + yrt * m_Cosa; T xrt = helper.In.x, yrt = helper.In.y, swp;
xrt = swp; T r2 = xrt * m_Coss + std::abs(yrt) * m_Sins;
r2 = std::max(r2, xrt * m_Coss + std::abs(yrt) * m_Sins); T circle = helper.m_PrecalcSqrtSumSquares;
}
r2 = r2 * m_Cosc + circle * m_Sinc; for (i = 0; i < m_Sides - 1; i++)
{
swp = xrt * m_Cosa - yrt * m_Sina;
yrt = xrt * m_Sina + yrt * m_Cosa;
xrt = swp;
r2 = std::max(r2, xrt * m_Coss + std::abs(yrt) * m_Sins);
}
if (i > 1) r2 = r2 * m_Cosc + circle * m_Sinc;
r2 = SQR(r2);
else
r2 = std::abs(r2) * r2;
if (r2 > 0 && (r2 < m_W2)) if (i > 1)
{ r2 = SQR(r2);
T r = m_Weight * std::sqrt(std::abs(m_W2 / r2 - 1)); else
helper.Out.x = r * helper.In.x; r2 = std::abs(r2) * r2;
helper.Out.y = r * helper.In.y;
} if (r2 > 0 && (r2 < m_W2))
else if (r2 < 0) {
{ T r = m_Weight * std::sqrt(std::abs(m_W2 / r2 - 1));
T r = m_Weight / std::sqrt(std::abs(m_W2 / r2) - 1); helper.Out.x = r * helper.In.x;
helper.Out.x = r * helper.In.x; helper.Out.y = r * helper.In.y;
helper.Out.y = r * helper.In.y; }
else if (r2 < 0)
{
T r = m_Weight / std::sqrt(std::abs(m_W2 / r2) - 1);
helper.Out.x = r * helper.In.x;
helper.Out.y = r * helper.In.y;
}
else
{
helper.Out.x = m_Weight * helper.In.x;
helper.Out.y = m_Weight * helper.In.y;
}
} }
else else
{ {
helper.Out.x = m_Weight * helper.In.x; T r2 = helper.m_PrecalcSumSquares;
helper.Out.y = m_Weight * helper.In.y; T r = r2 < T(1) ? std::sqrt(1 / Zeps(r2) - 1) : T(1);
T newX = helper.In.x * r;
T newY = helper.In.y * r;
T dang = (std::atan2(newY, newX) + T(M_PI)) / m_Alpha;
T rad = std::sqrt(SQR(newX) + SQR(newY));
T zang1 = T(Floor(dang));
T xang1 = dang - zang1;
T xang2, zang, sign;
if (xang1 > T(0.5))
{
xang2 = 1 - xang1;
zang = zang1 + 1;
sign = -1;
}
else
{
xang2 = xang1;
zang = zang1;
sign = 1;
}
T xang = std::atan(xang2 * m_TanHalfAlpha2) / m_Alpha;
T coeff = 1 / Zeps(std::cos(xang * m_Alpha));
T ang = (zang + sign * xang) * m_Alpha - T(M_PI);
T temp = m_Weight * coeff * rad;
helper.Out.x = temp * std::cos(ang);
helper.Out.y = temp * std::sin(ang);
} }
helper.Out.z = DefaultZ(helper); helper.Out.z = DefaultZ(helper);
@ -1486,72 +1525,137 @@ public:
ss2 << "_" << XformIndexInEmber() << "]"; ss2 << "_" << XformIndexInEmber() << "]";
string weight = WeightDefineString(); string weight = WeightDefineString();
string index = ss2.str(); string index = ss2.str();
string sides = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string sides = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
string star = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string star = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
string circle = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string circle = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
string w2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string power = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
string sina = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string w2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
string cosa = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string sina = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
string sins = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string cosa = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
string coss = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string sins = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
string sinc = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string coss = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
string cosc = "parVars[" + ToUpper(m_Params[i++].Name()) + index; string sinc = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
ss << "\t{\n" string cosc = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
<< "\t\tint i;\n" string alpha = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
<< "\t\treal_t xrt = vIn.x, yrt = vIn.y, swp;\n" string tanhalfalpha2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
<< "\t\treal_t r2 = fma(xrt, " << coss << ", fabs(yrt) * " << sins << ");\n"
<< "\t\treal_t circle = precalcSqrtSumSquares;\n" if (Compat::m_Compat)
<< "\n" {
<< "\t\tfor (i = 0; i < " << sides << " - 1; i++)\n" ss << "\t{\n"
<< "\t\t{\n" << "\t\tint i;\n"
<< "\t\t swp = fma(xrt, " << cosa << ", -(yrt * " << sina << "));\n" << "\t\treal_t weight = " << weight << ";\n"
<< "\t\t yrt = fma(xrt, " << sina << ", yrt * " << cosa << ");\n" << "\t\treal_t coss = " << coss << ";\n"
<< "\t\t xrt = swp;\n" << "\t\treal_t sins = " << sins << ";\n"
<< "\n" << "\t\treal_t sina = " << sina << ";\n"
<< "\t\t r2 = max(r2, fma(xrt, " << coss << ", fabs(yrt) * " << sins << "));\n" << "\t\treal_t cosa = " << cosa << ";\n"
<< "\t\t}\n" << "\t\treal_t w2 = " << w2 << ";\n"
<< "\n" << "\t\treal_t xrt = vIn.x, yrt = vIn.y, swp;\n"
<< "\t\tr2 = fma(r2, " << cosc << ", circle * " << sinc << ");\n" << "\t\treal_t r2 = fma(xrt, coss, fabs(yrt) * sins);\n"
<< "\n" << "\t\treal_t circle = precalcSqrtSumSquares;\n"
<< "\t\tif (i > 1)\n" << "\n"
<< "\t\t r2 = SQR(r2);\n" << "\t\tfor (i = 0; i < " << sides << " - 1; i++)\n"
<< "\t\telse\n" << "\t\t{\n"
<< "\t\t r2 = fabs(r2) * r2;\n" << "\t\t swp = fma(xrt, cosa, -(yrt * sina));\n"
<< "\n" << "\t\t yrt = fma(xrt, sina, yrt * cosa);\n"
<< "\t\tif (r2 > 0 && (r2 < " << w2 << "))\n" << "\t\t xrt = swp;\n"
<< "\t\t{\n" << "\n"
<< "\t\t real_t r = " << weight << " * sqrt(fabs(" << w2 << " / r2 - 1));\n" << "\t\t r2 = max(r2, fma(xrt, coss, fabs(yrt) * sins));\n"
<< "\n" << "\t\t}\n"
<< "\t\t vOut.x = r * vIn.x;\n" << "\n"
<< "\t\t vOut.y = r * vIn.y;\n" << "\t\tr2 = fma(r2, " << cosc << ", circle * " << sinc << ");\n"
<< "\t\t}\n" << "\n"
<< "\t\telse if (r2 < 0)\n" << "\t\tif (i > 1)\n"
<< "\t\t{\n" << "\t\t r2 = SQR(r2);\n"
<< "\t\t real_t r = " << weight << " / sqrt(fabs(" << w2 << " / r2) - 1);\n" << "\t\telse\n"
<< "\n" << "\t\t r2 = fabs(r2) * r2;\n"
<< "\t\t vOut.x = r * vIn.x;\n" << "\n"
<< "\t\t vOut.y = r * vIn.y;\n" << "\t\tif (r2 > 0 && (r2 < w2))\n"
<< "\t\t}\n" << "\t\t{\n"
<< "\t\telse\n" << "\t\t real_t r = weight * sqrt(fabs(w2 / r2 - 1));\n"
<< "\t\t{\n" << "\n"
<< "\t\t vOut.x = " << weight << " * vIn.x;\n" << "\t\t vOut.x = r * vIn.x;\n"
<< "\t\t vOut.y = " << weight << " * vIn.y;\n" << "\t\t vOut.y = r * vIn.y;\n"
<< "\t\t}\n" << "\t\t}\n"
<< "\n" << "\t\telse if (r2 < 0)\n"
<< "\t\tvOut.z = " << DefaultZCl() << "\t\t{\n"
<< "\t\t real_t r = weight / sqrt(fabs(w2 / r2) - 1);\n"
<< "\n"
<< "\t\t vOut.x = r * vIn.x;\n"
<< "\t\t vOut.y = r * vIn.y;\n"
<< "\t\t}\n"
<< "\t\telse\n"
<< "\t\t{\n"
<< "\t\t vOut.x = weight * vIn.x;\n"
<< "\t\t vOut.y = weight * vIn.y;\n"
<< "\t\t}\n";
}
else
{
ss << "\t{\n"
<< "\t\treal_t alpha = " << alpha << ";\n"
<< "\t\treal_t r2 = precalcSumSquares;\n"
<< "\t\treal_t r = r2 < (real_t)(1.0) ? sqrt(1 / Zeps(r2) - 1) : (real_t)(1.0);\n"
<< "\t\treal_t newX = vIn.x * r;\n"
<< "\t\treal_t newY = vIn.y * r;\n"
<< "\t\treal_t dang = (atan2(newY, newX) + MPI) / alpha;\n"
<< "\t\treal_t rad = sqrt(SQR(newX) + SQR(newY));\n"
<< "\t\treal_t zang1 = floor(dang);\n"
<< "\t\treal_t xang1 = dang - zang1;\n"
<< "\t\treal_t xang2, zang, sign;\n"
<< "\n"
<< "\t\tif (xang1 > 0.5)\n"
<< "\t\t{\n"
<< "\t\t xang2 = 1 - xang1;\n"
<< "\t\t zang = zang1 + 1;\n"
<< "\t\t sign = -1;\n"
<< "\t\t}\n"
<< "\t\telse\n"
<< "\t\t{\n"
<< "\t\t xang2 = xang1;\n"
<< "\t\t zang = zang1;\n"
<< "\t\t sign = 1;\n"
<< "\t\t}\n"
<< "\n"
<< "\t\treal_t xang = atan(xang2 * " << tanhalfalpha2 << ") / alpha;\n"
<< "\t\treal_t coeff = 1 / Zeps(cos(xang * alpha));\n"
<< "\t\treal_t ang = (zang + sign * xang) * alpha - MPI;\n"
<< "\t\treal_t temp = " << weight << " * coeff * rad;\n"
<< "\t\tvOut.x = temp * cos(ang);\n"
<< "\t\tvOut.y = temp * sin(ang);\n";
}
ss << "\t\tvOut.z = " << DefaultZCl()
<< "\t}\n"; << "\t}\n";
return ss.str(); return ss.str();
} }
virtual void Precalc() override virtual void Precalc() override
{ {
auto a = M_2PI / m_Sides; if (Compat::m_Compat)
auto s = T(-M_PI_2) * m_Star; {
auto c = T(M_PI_2) * m_Circle; auto a = M_2PI / m_Sides;
m_W2 = SQR(m_Weight); auto s = T(-M_PI_2) * m_Star;
sincos(a, &m_Sina, &m_Cosa); auto c = T(M_PI_2) * m_Circle;
sincos(s, &m_Sins, &m_Coss); m_W2 = SQR(m_Weight);
sincos(c, &m_Sinc, &m_Cosc); sincos(a, &m_Sina, &m_Cosa);
sincos(s, &m_Sins, &m_Coss);
sincos(c, &m_Sinc, &m_Cosc);
}
else
{
m_Alpha = M_2PI / Zeps(m_Power);
m_TanHalfAlpha2 = std::tan(m_Alpha * T(0.5)) * 2;
}
m_NeedPrecalcSqrtSumSquares = Compat::m_Compat;
}
virtual vector<string> OpenCLGlobalFuncNames() const override
{
if (Compat::m_Compat)
return vector<string> { };
else
return vector<string> { "Zeps" };
} }
protected: protected:
@ -1562,6 +1666,7 @@ protected:
m_Params.push_back(ParamWithName<T>(&m_Sides, prefix + "loonie2_sides", 4, eParamType::INTEGER, 1, 50)); m_Params.push_back(ParamWithName<T>(&m_Sides, prefix + "loonie2_sides", 4, eParamType::INTEGER, 1, 50));
m_Params.push_back(ParamWithName<T>(&m_Star, prefix + "loonie2_star", 0, eParamType::REAL, -1, 1)); m_Params.push_back(ParamWithName<T>(&m_Star, prefix + "loonie2_star", 0, eParamType::REAL, -1, 1));
m_Params.push_back(ParamWithName<T>(&m_Circle, prefix + "loonie2_circle", 0, eParamType::REAL, -1, 1)); m_Params.push_back(ParamWithName<T>(&m_Circle, prefix + "loonie2_circle", 0, eParamType::REAL, -1, 1));
m_Params.push_back(ParamWithName<T>(&m_Power, prefix + "loonie2_power", 4));
m_Params.push_back(ParamWithName<T>(true, &m_W2, prefix + "loonie2_w2"));//Precalc. m_Params.push_back(ParamWithName<T>(true, &m_W2, prefix + "loonie2_w2"));//Precalc.
m_Params.push_back(ParamWithName<T>(true, &m_Sina, prefix + "loonie2_sina")); m_Params.push_back(ParamWithName<T>(true, &m_Sina, prefix + "loonie2_sina"));
m_Params.push_back(ParamWithName<T>(true, &m_Cosa, prefix + "loonie2_cosa")); m_Params.push_back(ParamWithName<T>(true, &m_Cosa, prefix + "loonie2_cosa"));
@ -1569,12 +1674,15 @@ protected:
m_Params.push_back(ParamWithName<T>(true, &m_Coss, prefix + "loonie2_coss")); m_Params.push_back(ParamWithName<T>(true, &m_Coss, prefix + "loonie2_coss"));
m_Params.push_back(ParamWithName<T>(true, &m_Sinc, prefix + "loonie2_sinc")); m_Params.push_back(ParamWithName<T>(true, &m_Sinc, prefix + "loonie2_sinc"));
m_Params.push_back(ParamWithName<T>(true, &m_Cosc, prefix + "loonie2_cosc")); m_Params.push_back(ParamWithName<T>(true, &m_Cosc, prefix + "loonie2_cosc"));
m_Params.push_back(ParamWithName<T>(true, &m_Alpha, prefix + "loonie2_alpha"));
m_Params.push_back(ParamWithName<T>(true, &m_TanHalfAlpha2, prefix + "loonie2_tan_half_alpha2"));
} }
private: private:
T m_Sides; T m_Sides;
T m_Star; T m_Star;
T m_Circle; T m_Circle;
T m_Power;
T m_W2;//Precalc. T m_W2;//Precalc.
T m_Sina; T m_Sina;
T m_Cosa; T m_Cosa;
@ -1582,6 +1690,8 @@ private:
T m_Coss; T m_Coss;
T m_Sinc; T m_Sinc;
T m_Cosc; T m_Cosc;
T m_Alpha;
T m_TanHalfAlpha2;
}; };
/// <summary> /// <summary>
@ -2485,9 +2595,9 @@ public:
default: default:
scale = Clamp<T>(rs, 0, T(0.9)) + T(0.1); scale = Clamp<T>(rs, 0, T(0.9)) + T(0.1);
denom = 1 / scale; denom = 1 / scale;
helper.Out.x = m_Weight * Lerp<T>(helper.In.x, std::floor(helper.In.x * denom) + scale * ax, m_MulX * rs) + m_MulX * std::pow(ax, m_BoxPow) * rs * denom;//m_BoxPow should be an integer value held in T, helper.Out.x = m_Weight * Lerp<T>(helper.In.x, Floor(helper.In.x * denom) + scale * ax, m_MulX * rs) + m_MulX * std::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, std::floor(helper.In.y * denom) + scale * ay, m_MulY * rs) + m_MulY * std::pow(ay, m_BoxPow) * rs * denom;//so std::abs() shouldn't be necessary. helper.Out.y = m_Weight * Lerp<T>(helper.In.y, Floor(helper.In.y * denom) + scale * ay, m_MulY * rs) + m_MulY * std::pow(ay, m_BoxPow) * rs * denom;//so std::abs() shouldn't be necessary.
helper.Out.z = m_Weight * Lerp<T>(helper.In.z, std::floor(helper.In.z * denom) + scale * az, m_MulZ * rs) + m_MulZ * std::pow(az, m_BoxPow) * rs * denom; helper.Out.z = m_Weight * Lerp<T>(helper.In.z, Floor(helper.In.z * denom) + scale * az, m_MulZ * rs) + m_MulZ * std::pow(az, m_BoxPow) * rs * denom;
break; break;
} }
} }
@ -2785,13 +2895,13 @@ protected:
m_Params.push_back(ParamWithName<T>(&m_MinDist, prefix + "falloff2_mindist", T(0.5))); m_Params.push_back(ParamWithName<T>(&m_MinDist, prefix + "falloff2_mindist", T(0.5)));
m_Params.push_back(ParamWithName<T>(&m_MulX, prefix + "falloff2_mul_x", 1)); m_Params.push_back(ParamWithName<T>(&m_MulX, prefix + "falloff2_mul_x", 1));
m_Params.push_back(ParamWithName<T>(&m_MulY, prefix + "falloff2_mul_y", 1)); m_Params.push_back(ParamWithName<T>(&m_MulY, prefix + "falloff2_mul_y", 1));
m_Params.push_back(ParamWithName<T>(&m_MulZ, prefix + "falloff2_mul_z", 0)); m_Params.push_back(ParamWithName<T>(&m_MulZ, prefix + "falloff2_mul_z"));
m_Params.push_back(ParamWithName<T>(&m_MulC, prefix + "falloff2_mul_c", 0)); m_Params.push_back(ParamWithName<T>(&m_MulC, prefix + "falloff2_mul_c"));
m_Params.push_back(ParamWithName<T>(&m_X0, prefix + "falloff2_x0")); m_Params.push_back(ParamWithName<T>(&m_X0, prefix + "falloff2_x0"));
m_Params.push_back(ParamWithName<T>(&m_Y0, prefix + "falloff2_y0")); m_Params.push_back(ParamWithName<T>(&m_Y0, prefix + "falloff2_y0"));
m_Params.push_back(ParamWithName<T>(&m_Z0, prefix + "falloff2_z0")); m_Params.push_back(ParamWithName<T>(&m_Z0, prefix + "falloff2_z0"));
m_Params.push_back(ParamWithName<T>(&m_Invert, prefix + "falloff2_invert", 0, eParamType::INTEGER, 0, 1)); m_Params.push_back(ParamWithName<T>(&m_Invert, prefix + "falloff2_invert", 0, eParamType::REAL, 0, 1));
m_Params.push_back(ParamWithName<T>(&m_Type, prefix + "falloff2_type", 0, eParamType::INTEGER, 0, 2)); m_Params.push_back(ParamWithName<T>(&m_Type, prefix + "falloff2_type", 0, eParamType::REAL, 0, 2));
m_Params.push_back(ParamWithName<T>(true, &m_RMax, prefix + "falloff2_rmax"));//Precalc. m_Params.push_back(ParamWithName<T>(true, &m_RMax, prefix + "falloff2_rmax"));//Precalc.
} }

View File

@ -787,7 +787,7 @@ public:
if (int(m_NumEdges) % 4 == 0) if (int(m_NumEdges) % 4 == 0)
m_AdjustedWeight = m_Weight / Zeps(std::sqrt(2 - 2 * std::cos(m_MidAngle * (m_NumEdges / 2 - 1))) / 2); m_AdjustedWeight = m_Weight / Zeps(std::sqrt(2 - 2 * std::cos(m_MidAngle * (m_NumEdges / 2 - 1))) / 2);
else else
m_AdjustedWeight = m_Weight / Zeps(std::sqrt(2 - 2 * std::cos(m_MidAngle * std::floor((m_NumEdges / 2)))) / 2); m_AdjustedWeight = m_Weight / Zeps(std::sqrt(2 - 2 * std::cos(m_MidAngle * Floor((m_NumEdges / 2)))) / 2);
} }
else else
m_AdjustedWeight = m_Weight; m_AdjustedWeight = m_Weight;
@ -3721,8 +3721,8 @@ public:
T theta = M_2PI * rand.Frand01<T>(); T theta = M_2PI * rand.Frand01<T>();
u.x = blurr * std::sin(theta); u.x = blurr * std::sin(theta);
u.y = blurr * std::cos(theta); u.y = blurr * std::cos(theta);
cv.x = int(std::floor(u.x / m_HalfCellSize)); cv.x = int(Floor(u.x / m_HalfCellSize));
cv.y = int(std::floor(u.y / m_HalfCellSize)); cv.y = int(Floor(u.y / m_HalfCellSize));
for (int di = -1; di < 2; di++) for (int di = -1; di < 2; di++)
{ {
@ -4483,7 +4483,7 @@ protected:
{ {
string prefix = Prefix(); string prefix = Prefix();
m_Params.clear(); m_Params.clear();
m_Params.push_back(ParamWithName<T>(&m_Power, prefix + "smartcrop_power", 4)); //Original used a prefix of scrop_, which is incompatible with Ember's design. m_Params.push_back(ParamWithName<T>(&m_Power, prefix + "smartcrop_power", 4));//Original used a prefix of scrop_, which is incompatible with Ember's design.
m_Params.push_back(ParamWithName<T>(&m_Radius, prefix + "smartcrop_radius", 1)); m_Params.push_back(ParamWithName<T>(&m_Radius, prefix + "smartcrop_radius", 1));
m_Params.push_back(ParamWithName<T>(&m_Roundstr, prefix + "smartcrop_roundstr")); m_Params.push_back(ParamWithName<T>(&m_Roundstr, prefix + "smartcrop_roundstr"));
m_Params.push_back(ParamWithName<T>(&m_Roundwidth, prefix + "smartcrop_roundwidth", 1)); m_Params.push_back(ParamWithName<T>(&m_Roundwidth, prefix + "smartcrop_roundwidth", 1));
@ -4492,8 +4492,8 @@ protected:
m_Params.push_back(ParamWithName<T>(&m_Scatter, prefix + "smartcrop_scatter")); m_Params.push_back(ParamWithName<T>(&m_Scatter, prefix + "smartcrop_scatter"));
m_Params.push_back(ParamWithName<T>(&m_Offset, prefix + "smartcrop_offset")); m_Params.push_back(ParamWithName<T>(&m_Offset, prefix + "smartcrop_offset"));
m_Params.push_back(ParamWithName<T>(&m_Rotation, prefix + "smartcrop_rotation")); m_Params.push_back(ParamWithName<T>(&m_Rotation, prefix + "smartcrop_rotation"));
m_Params.push_back(ParamWithName<T>(&m_Cropmode, prefix + "smartcrop_cropmode", 1, eParamType::INTEGER, -1, 2)); m_Params.push_back(ParamWithName<T>(&m_Cropmode, prefix + "smartcrop_cropmode", 1, eParamType::REAL, -1, 2));
m_Params.push_back(ParamWithName<T>(&m_Static, prefix + "smartcrop_static", 1, eParamType::INTEGER, -1, 3)); m_Params.push_back(ParamWithName<T>(&m_Static, prefix + "smartcrop_static", 1, eParamType::REAL, -1, 3));
m_Params.push_back(ParamWithName<T>(true, &m_Mode, prefix + "smartcrop_mode"));//Precalc. m_Params.push_back(ParamWithName<T>(true, &m_Mode, prefix + "smartcrop_mode"));//Precalc.
m_Params.push_back(ParamWithName<T>(true, &m_Radial, prefix + "smartcrop_radial")); m_Params.push_back(ParamWithName<T>(true, &m_Radial, prefix + "smartcrop_radial"));
m_Params.push_back(ParamWithName<T>(true, &m_WorkRadius, prefix + "smartcrop_work_radius")); m_Params.push_back(ParamWithName<T>(true, &m_WorkRadius, prefix + "smartcrop_work_radius"));

File diff suppressed because it is too large Load Diff

View File

@ -104,8 +104,8 @@ protected:
{ {
string prefix = Prefix(); string prefix = Prefix();
m_Params.clear(); m_Params.clear();
m_Params.push_back(ParamWithName<T>(&m_GnarlyCellSize, prefix + "gnarly_cellsize", T(1))); m_Params.push_back(ParamWithName<T>(&m_GnarlyCellSize, prefix + "gnarly_cellsize", 1));
m_Params.push_back(ParamWithName<T>(&m_GnarlyTwist, prefix + "gnarly_twist", T(1))); m_Params.push_back(ParamWithName<T>(&m_GnarlyTwist, prefix + "gnarly_twist", 1));
m_Params.push_back(ParamWithName<T>(true, &m_R2, prefix + "gnarly_r2"));//Precalc. m_Params.push_back(ParamWithName<T>(true, &m_R2, prefix + "gnarly_r2"));//Precalc.
} }
@ -300,7 +300,7 @@ protected:
{ {
string prefix = Prefix(); string prefix = Prefix();
m_Params.clear(); m_Params.clear();
m_Params.push_back(ParamWithName<T>(&m_Size, prefix + "hex_modulus_size", T(1.0))); m_Params.push_back(ParamWithName<T>(&m_Size, prefix + "hex_modulus_size", 1));
m_Params.push_back(ParamWithName<T>(true, &m_HsizePrecalc, prefix + "hex_modulus_hsize_precalc"));//Precalc. m_Params.push_back(ParamWithName<T>(true, &m_HsizePrecalc, prefix + "hex_modulus_hsize_precalc"));//Precalc.
m_Params.push_back(ParamWithName<T>(true, &m_WeightPrecalc, prefix + "hex_modulus_weight_precalc")); m_Params.push_back(ParamWithName<T>(true, &m_WeightPrecalc, prefix + "hex_modulus_weight_precalc"));
} }

View File

@ -55,8 +55,8 @@ XmlToEmber<T>::XmlToEmber()
{ "pow_correctn", "pow_block_correctn" }, { "pow_correctn", "pow_block_correctn" },
{ "pow_correctd", "pow_block_correctd" }, { "pow_correctd", "pow_block_correctd" },
{ "pow_power", "pow_block_power" }, { "pow_power", "pow_block_power" },
{ "lt", "linearT_powX" }, //linearT. { "lt_powx", "linearT_powX" }, //linearT.
{ "lt", "linearT_powY" }, { "lt_powy", "linearT_powY" },
{ "re_a", "Mobius_Re_A" }, //Mobius. { "re_a", "Mobius_Re_A" }, //Mobius.
{ "im_a", "Mobius_Im_A" }, { "im_a", "Mobius_Im_A" },
{ "re_b", "Mobius_Re_B" }, { "re_b", "Mobius_Re_B" },
@ -136,12 +136,12 @@ XmlToEmber<T>::XmlToEmber()
{ "nb_exactcalc", "nBlur_exactCalc" }, { "nb_exactcalc", "nBlur_exactCalc" },
{ "nb_highlightedges", "nBlur_highlightEdges" }, { "nb_highlightedges", "nBlur_highlightEdges" },
{ "octapol_r", "octapol_radius" }, //octapol. { "octapol_r", "octapol_radius" }, //octapol.
{ "number_of_stripes", "bubbleT3D_number_of_stripes" }, //bubbleT3D. //{ "number_of_stripes", "bubbleT3D_number_of_stripes" }, //bubbleT3D.
{ "ratio_of_stripes", "bubbleT3D_ratio_of_stripes" }, //{ "ratio_of_stripes", "bubbleT3D_ratio_of_stripes" },
{ "angle_of_hole", "bubbleT3D_angle_of_hole" }, //{ "angle_of_hole", "bubbleT3D_angle_of_hole" },
{ "exponentZ", "bubbleT3D_exponentZ" }, //{ "exponentZ", "bubbleT3D_exponentZ" },
{ "_symmetryZ", "bubbleT3D_symmetryZ" }, //{ "_symmetryZ", "bubbleT3D_symmetryZ" },
{ "_modusBlur", "bubbleT3D_modusBlur" }, //{ "_modusBlur", "bubbleT3D_modusBlur" },
{ "post_scrop_power", "post_smartcrop_power" }, //post_smartcrop. { "post_scrop_power", "post_smartcrop_power" }, //post_smartcrop.
{ "post_scrop_radius", "post_smartcrop_radius" }, { "post_scrop_radius", "post_smartcrop_radius" },
{ "post_scrop_roundstr", "post_smartcrop_roundstr" }, { "post_scrop_roundstr", "post_smartcrop_roundstr" },
@ -164,20 +164,20 @@ XmlToEmber<T>::XmlToEmber()
{ "tf_exponent", "Truchet_fill_exponent" }, { "tf_exponent", "Truchet_fill_exponent" },
{ "tf_arc_width", "Truchet_fill_arc_width" }, { "tf_arc_width", "Truchet_fill_arc_width" },
{ "tf_seed", "Truchet_fill_seed" }, { "tf_seed", "Truchet_fill_seed" },
{ "blockSize", "randCubes_blockSize" }, //{ "blockSize", "randCubes_blockSize" },
{ "blockHeight", "randCubes_blockHeight" }, //{ "blockHeight", "randCubes_blockHeight" },
{ "spread", "randCubes_spread" }, //{ "spread", "randCubes_spread" },
{ "seed", "randCubes_seed" }, //{ "seed", "randCubes_seed" },
{ "density", "randCubes_density" }, //{ "density", "randCubes_density" },
{ "radius", "concentric_radius" }, //{ "radius", "concentric_radius" },
//{ "density", "concentric_density" },//Can't have two, which means you can never properly paste from Apophysis with both of these in one xform. //{ "density", "concentric_density" },//Can't have two, which means you can never properly paste from Apophysis with both of these in one xform.
{ "r_blur", "concentric_R_blur" }, //{ "r_blur", "concentric_R_blur" },
{ "z_blur", "concentric_Z_blur" }, //{ "z_blur", "concentric_Z_blur" },
{ "angle", "pixel_flow_angle" }, //{ "angle", "pixel_flow_angle" },
{ "len", "pixel_flow_len" }, ///{ "len", "pixel_flow_len" },
{ "width", "pixel_flow_width" }, //{ "width", "pixel_flow_width" },
//{ "seed", "pixel_flow_seed" },//randCubes above already uses "seed", but it's just for randomness, so it shouldn't matter. //{ "seed", "pixel_flow_seed" },//randCubes above already uses "seed", but it's just for randomness, so it shouldn't matter.
{ "enable_dc", "pixel_flow_enable_dc" }, //{ "enable_dc", "pixel_flow_enable_dc" },
{ "radial_gaussian_angle", "radial_blur_angle" }, { "radial_gaussian_angle", "radial_blur_angle" },
{ "pr_a", "projective_A" }, { "pr_a", "projective_A" },
{ "pr_b", "projective_B" }, { "pr_b", "projective_B" },
@ -202,7 +202,7 @@ XmlToEmber<T>::XmlToEmber()
{ "oscope_frequency", "oscilloscope_frequency" }, { "oscope_frequency", "oscilloscope_frequency" },
{ "oscope_amplitude", "oscilloscope_amplitude" }, { "oscope_amplitude", "oscilloscope_amplitude" },
{ "oscope_damping", "oscilloscope_damping" }, { "oscope_damping", "oscilloscope_damping" },
{ "power", "scry2_power" }, //{ "power", "scry2_power" },
{ "faber_w_angle", "w_angle" }, { "faber_w_angle", "w_angle" },
{ "faber_w_hypergon", "w_hypergon" }, { "faber_w_hypergon", "w_hypergon" },
{ "faber_w_hypergon_n", "w_hypergon_n" }, { "faber_w_hypergon_n", "w_hypergon_n" },
@ -240,21 +240,26 @@ XmlToEmber<T>::XmlToEmber()
{ "post_sshape_roundwidth", "post_smartshape_roundwidth" }, { "post_sshape_roundwidth", "post_smartshape_roundwidth" },
{ "post_sshape_distortion", "post_smartshape_distortion" }, { "post_sshape_distortion", "post_smartshape_distortion" },
{ "post_sshape_compensation", "post_smartshape_compensation" }, { "post_sshape_compensation", "post_smartshape_compensation" },
{ "mult_x", "unicorngaloshen_mult_x" }, //{ "mult_x", "unicorngaloshen_mult_x" },
{ "mult_y", "unicorngaloshen_mult_y" }, //{ "mult_y", "unicorngaloshen_mult_y" },
{ "sine", "unicorngaloshen_sine" }, //{ "sine", "unicorngaloshen_sine" },
{ "sin_x_amplitude", "unicorngaloshen_sin_x_amplitude" }, //{ "sin_x_amplitude", "unicorngaloshen_sin_x_amplitude" },
{ "sin_x_freq", "unicorngaloshen_sin_x_freq" }, //{ "sin_x_freq", "unicorngaloshen_sin_x_freq" },
{ "sin_y_amplitude", "unicorngaloshen_sin_y_amplitude" }, //{ "sin_y_amplitude", "unicorngaloshen_sin_y_amplitude" },
{ "sin_y_freq", "unicorngaloshen_sin_y_freq" }, //{ "sin_y_freq", "unicorngaloshen_sin_y_freq" },
{ "mode", "unicorngaloshen_mode" }, //{ "mode", "unicorngaloshen_mode" },
{ "d_spher_weight", "d_spherical_weight" }, { "d_spher_weight", "d_spherical_weight" },
{ "poincare_p", "poincare2_p" }, { "poincare_p", "poincare2_p" },
{ "poincare_q", "poincare2_q" }, { "poincare_q", "poincare2_q" },
{ "phoenix_power", "phoenix_julia_power"}, { "phoenix_power", "phoenix_julia_power"},
{ "phoenix_dist", "phoenix_julia_dist" }, { "phoenix_dist", "phoenix_julia_dist" },
{ "x_distort", "phoenix_julia_x_distort"}, //{ "x_distort", "phoenix_julia_x_distort"},
{ "y_distort", "phoenix_julia_y_distort" } //{ "y_distort", "phoenix_julia_y_distort" },
{ "phoenixjulia_power", "phoenix_julia_power" },
{ "phoenixjulia_dist", "phoenix_julia_dist" },
{ "phoenixjulia_x_distort", "phoenix_julia_x_distort" },
{ "phoenixjulia_y_distort", "phoenix_julia_y_distort" },
{ "log_", "log" }//Chaotica uses log_ as the weight for log to avoid a name conflict with the function log().
}; };
m_FlattenNames = m_FlattenNames =
{ {
@ -908,6 +913,8 @@ bool XmlToEmber<T>::ParseEmberElementFromChaos(xmlNode* emberNode, Ember<T>& cur
{ {
const auto corrvarname = GetCorrectedVariationName(m_BadVariationNames, varname); const auto corrvarname = GetCorrectedVariationName(m_BadVariationNames, varname);
const auto corrwprefix = !StartsWith(corrvarname, prefix) ? prefix + corrvarname : corrvarname; const auto corrwprefix = !StartsWith(corrvarname, prefix) ? prefix + corrvarname : corrvarname;
const auto varnamewithunderscore = corrvarname + "_";
const auto fullprefix = prefix + varnamewithunderscore;
if (auto var = m_VariationList->GetVariation(corrwprefix)) if (auto var = m_VariationList->GetVariation(corrwprefix))
{ {
@ -949,16 +956,28 @@ bool XmlToEmber<T>::ParseEmberElementFromChaos(xmlNode* emberNode, Ember<T>& cur
} }
else if (ParseAndAssignContent(paramsChildNode, "name", paramname, val)) else if (ParseAndAssignContent(paramsChildNode, "name", paramname, val))
{ {
auto paramstr = GetCorrectedParamName(m_BadParamNames, ToLower(paramname).c_str()); auto paramstr = GetCorrectedParamName(m_BadParamNames, paramname);
if (paramname == varname)//Compare non corrected names. //Compare non corrected or corrected names.
//This is needed for the case of "log_" which gets corrected to "log".
if (paramname == varname || paramstr == varname)
{ {
varCopy->m_Weight = val; varCopy->m_Weight = val;
} }
else if (parvar) else if (parvar)
{ {
if (!StartsWith(paramstr, prefix)) if (StartsWith(paramstr, fullprefix, true))
{
//Do nothing.
}
else if (!StartsWith(paramstr, varnamewithunderscore, true) && (prefix.size() == 0 || !StartsWith(paramstr, prefix, true)))
{
paramstr = fullprefix + paramstr;
}
else if (StartsWith(paramstr, varnamewithunderscore, true))
{
paramstr = prefix + paramstr; paramstr = prefix + paramstr;
}
//Need some special corrections here because Chaotica allows values that don't make sense. //Need some special corrections here because Chaotica allows values that don't make sense.
if (varname == "falloff2") if (varname == "falloff2")
@ -2412,10 +2431,40 @@ bool XmlToEmber<T>::ParseXform(xmlNode* childNode, Xform<T>& xform, bool motion,
{ {
if (const auto parVar = dynamic_cast<ParametricVariation<T>*>(xform.GetVariation(i))) if (const auto parVar = dynamic_cast<ParametricVariation<T>*>(xform.GetVariation(i)))
{ {
string prefix;
if (!fromEmber)
{
if (parVar->VarType() == eVariationType::VARTYPE_PRE)
prefix = "pre_";
else if (parVar->VarType() == eVariationType::VARTYPE_POST)
prefix = "post_";
}
for (curAtt = attPtr; curAtt; curAtt = curAtt->next) for (curAtt = attPtr; curAtt; curAtt = curAtt->next)
{ {
//Only correct names if it came from an outside source. Names originating from this library are always considered correct. //Only correct names if it came from an outside source. Names originating from this library are always considered correct.
string s = fromEmber ? string(CCX(curAtt->name)) : GetCorrectedParamName(m_BadParamNames, ToLower(CCX(curAtt->name)).c_str()); string s = fromEmber ? string(CCX(curAtt->name)) : GetCorrectedParamName(m_BadParamNames, ToLower(CCX(curAtt->name)).c_str());
if (!fromEmber)
{
auto varnamewithunderscore = parVar->m_Name + "_";
auto fullprefix = prefix + varnamewithunderscore;
if (StartsWith(s, fullprefix, true))
{
//Do nothing.
}
else if (!StartsWith(s, varnamewithunderscore, true) && (prefix.size() == 0 || !StartsWith(s, prefix, true)))
{
s = fullprefix + s;
}
else if (StartsWith(s, varnamewithunderscore, true))
{
s = prefix + s;
}
}
const char* name = s.c_str(); const char* name = s.c_str();
if (parVar->ContainsParam(name)) if (parVar->ContainsParam(name))
@ -2504,8 +2553,12 @@ string XmlToEmber<T>::GetCorrectedVariationName(vector<pair<pair<string, string>
template <typename T> template <typename T>
string XmlToEmber<T>::GetCorrectedVariationName(vector<pair<pair<string, string>, vector<string>>>& vec, const string& varname) string XmlToEmber<T>::GetCorrectedVariationName(vector<pair<pair<string, string>, vector<string>>>& vec, const string& varname)
{ {
if (varname == "poincare")//for Apo flames, poincare must be the same, but chaotica poincare is implemented as poincare2 if (varname == "poincare")//for Apo flames, poincare must be the same, but Chaotica poincare is implemented as poincare2
return "poincare2"; return "poincare2";
else if (varname == "fisheye")
return "eyefish";//Chaotica automatically uses eyefish instead of fisheye.
else if (varname == "phoenixjulia")
return "phoenix_julia";
else if (varname != "mobius")//Chaotica actually gets this right, but Apophysis doesn't. else if (varname != "mobius")//Chaotica actually gets this right, but Apophysis doesn't.
for (auto& v : vec) for (auto& v : vec)
if (!_stricmp(v.first.first.c_str(), varname.c_str()))//Do case insensitive here. if (!_stricmp(v.first.first.c_str(), varname.c_str()))//Do case insensitive here.

View File

@ -76,7 +76,9 @@ static string ConstantDefinesString(bool doublePrecision)
"#define CUBE(x) ((x) * (x) * (x))\n" "#define CUBE(x) ((x) * (x) * (x))\n"
"#define MPI ((real_t)M_PI)\n" "#define MPI ((real_t)M_PI)\n"
"#define MPI2 ((real_t)M_PI_2)\n" "#define MPI2 ((real_t)M_PI_2)\n"
"#define MPI3 ((real_t)(1.0471975511965977461542144610932))\n"
"#define MPI4 ((real_t)M_PI_4)\n" "#define MPI4 ((real_t)M_PI_4)\n"
"#define MPI6 ((real_t)(0.52359877559829887307710723054658))\n"
"#define M1PI ((real_t)M_1_PI)\n" "#define M1PI ((real_t)M_1_PI)\n"
"#define M2PI ((real_t)M_2_PI)\n" "#define M2PI ((real_t)M_2_PI)\n"
"#define M_2PI (MPI * 2)\n" "#define M_2PI (MPI * 2)\n"
@ -87,8 +89,6 @@ static string ConstantDefinesString(bool doublePrecision)
"#define M_SQRT5 ((real_t)(2.2360679774997896964091736687313))\n" "#define M_SQRT5 ((real_t)(2.2360679774997896964091736687313))\n"
"#define M_PHI ((real_t)(1.61803398874989484820458683436563))\n" "#define M_PHI ((real_t)(1.61803398874989484820458683436563))\n"
"#define M_1_2PI ((real_t)(0.15915494309189533576888376337251))\n" "#define M_1_2PI ((real_t)(0.15915494309189533576888376337251))\n"
"#define M_PI3 ((real_t)(1.0471975511965977461542144610932))\n"
"#define M_PI6 ((real_t)(0.52359877559829887307710723054658))\n"
"#define DEG_2_RAD (MPI / 180)\n" "#define DEG_2_RAD (MPI / 180)\n"
"#define CURVES_LENGTH_M1 ((real_bucket_t)" << CURVES_LENGTH_M1 << ")\n" << "#define CURVES_LENGTH_M1 ((real_bucket_t)" << CURVES_LENGTH_M1 << ")\n" <<
"#define ONE_OVER_CURVES_LENGTH_M1 ((real_bucket_t)" << ONE_OVER_CURVES_LENGTH_M1 << ")\n" << "#define ONE_OVER_CURVES_LENGTH_M1 ((real_bucket_t)" << ONE_OVER_CURVES_LENGTH_M1 << ")\n" <<

View File

@ -43,7 +43,7 @@ using namespace Imath;
using namespace EmberNs; using namespace EmberNs;
using namespace EmberCommon; using namespace EmberCommon;
#define DO_NVIDIA 1 //#define DO_NVIDIA 1
void writeRgba1(const char filename[], void writeRgba1(const char filename[],
const Rgba* pixels, const Rgba* pixels,
@ -2251,15 +2251,53 @@ int _tmain(int argc, _TCHAR* argv[])
size_t times = 1'000'000'001; size_t times = 1'000'000'001;
QTIsaac<ISAAC_SIZE, ISAAC_INT> rand; QTIsaac<ISAAC_SIZE, ISAAC_INT> rand;
std::vector<unsigned int> vec(16, 0); std::vector<unsigned int> vec(16, 0);
double accum = 0;
Timing t(4); Timing t(4);
/* /*
for (size_t i = 1; i < times; i++) for (size_t i = 0; i < times; i++)
{ {
auto res = rand.Rand() % i; auto res = rand.Frand11<double>();
vec[res & 15]++; auto flr = (double)(Floor(res));
} accum += flr;
}
t.Toc("rand mod"); t.Toc("Floor");
cout << accum << endl;
accum = 0;
t.Tic();
for (size_t i = 0; i < times; i++)
{
auto res = rand.Frand11<double>();
auto flr = std::floor(res);
accum += flr;
}
t.Toc("std::floor");
cout << accum << endl;
t.Tic();
for (size_t i = 0; i < times; i++)
{
accum += rand.Frand01<double>();
}
t.Toc("Frand01");
cout << accum << endl;
accum = 0;
t.Tic();
for (size_t i = 0; i < times; i++)
{
accum += rand.Frand<double>(static_cast<double>(0), static_cast<double>(1));
}
t.Toc("Frand(0, 1)");
cout << accum << endl;
return 1;
*/
/*
for (auto& it : vec) for (auto& it : vec)
{ {
@ -2443,126 +2481,136 @@ int _tmain(int argc, _TCHAR* argv[])
//TestCross<double>(rand.Frand<double>(-5, 5), rand.Frand<double>(-5, 5), rand.Frand<double>(-5, 5)); //TestCross<double>(rand.Frand<double>(-5, 5), rand.Frand<double>(-5, 5), rand.Frand<double>(-5, 5));
//std::complex<double> cd, cd2; //std::complex<double> cd, cd2;
//cd2 = sin(cd); //cd2 = sin(cd);
t.Tic(); auto testfunc = [&]()
TestCasting();
t.Toc("TestCasting()");
t.Tic();
auto vlf(VariationList<float>::Instance());
t.Toc("Creating VariationList<float>");
cout << "There are " << vlf->Size() << " variations present." << endl;
#ifdef DO_DOUBLE
t.Tic();
auto vld(VariationList<double>::Instance());
t.Toc("Creating VariationList<double>");
#endif
t.Tic();
TestVarCounts();
t.Toc("TestVarCounts()");
t.Tic();
TestVarUnique<float>();
t.Toc("TestVarUnique<float>()");
#ifdef DO_DOUBLE
t.Tic();
TestVarUnique<double>();
t.Toc("TestVarUnique<double>()");
#endif
t.Tic();
TestVarCopy<float, float>();
t.Toc("TestVarCopy<float, float>()");
#ifdef DO_DOUBLE
t.Tic();
TestVarCopy<double, double>();
t.Toc("TestVarCopy<double, double>()");
t.Tic();
TestVarCopy<float, double>();
t.Toc("TestVarCopy<float, double>()");
t.Tic();
TestVarCopy<double, float>();
t.Toc("TestVarCopy<double, float>()");
#endif
t.Tic();
TestVarRegPrePost();
t.Toc("TestVarRegPrePost()");
t.Tic();
TestParVars();
t.Toc("TestParVars()");
t.Tic();
TestVarPrePostNames();
t.Toc("TestVarPrePostNames()");
t.Tic();
TestVarPrecalcUsedCL();
t.Toc("TestVarPrecalcUsedCL()");
t.Tic();
TestVarAssignTypes();
t.Toc("TestVarAssignTypes()");
t.Tic();
TestVarAssignVals();
t.Toc("TestVarAssignVals()");
t.Tic();
TestZepsFloor();
t.Toc("TestZepsFloor()");
t.Tic();
TestConstants();
t.Toc("TestConstants()");
t.Tic();
TestGlobalFuncs();
t.Toc("TestGlobalFuncs()");
/* t.Tic();
TestXformsInOutPoints();
t.Toc("TestXformsInOutPoints()");
t.Tic();
TestVarTime<float>();
t.Toc("TestVarTime()");
*/
t.Tic();
TestOperations<float>();
t.Toc("TestOperations()");
t.Tic();
TestArbitrary();
t.Toc("TestArbitrary()");
//t.Tic();
//TestVarsSimilar<float>();
//t.Toc("TestVarsSimilar()");
#ifdef TEST_CL
//t.Tic();
//TestCpuGpuResults<float>();
//t.Toc("TestCpuGpuResults<float>()");
//t.Tic();
//b = TestAllVarsCLBuild<float>(0, 0, true);
//t.Toc("TestAllVarsCLBuild<float>()");
if (b)
{ {
#ifdef DO_NVIDIA
t.Tic(); t.Tic();
b = TestAllVarsCLBuild<float>(1, 0, true); TestCasting();
t.Toc("TestAllVarsCLBuild<float>()"); t.Toc("TestCasting()");
#endif t.Tic();
} auto vlf(VariationList<float>::Instance());
t.Toc("Creating VariationList<float>");
cout << "There are " << vlf->Size() << " variations present." << endl;
#ifdef DO_DOUBLE #ifdef DO_DOUBLE
t.Tic();
auto vld(VariationList<double>::Instance());
t.Toc("Creating VariationList<double>");
#endif
t.Tic();
TestVarCounts();
t.Toc("TestVarCounts()");
t.Tic();
TestVarUnique<float>();
t.Toc("TestVarUnique<float>()");
#ifdef DO_DOUBLE
t.Tic();
TestVarUnique<double>();
t.Toc("TestVarUnique<double>()");
#endif
t.Tic();
TestVarCopy<float, float>();
t.Toc("TestVarCopy<float, float>()");
#ifdef DO_DOUBLE
t.Tic();
TestVarCopy<double, double>();
t.Toc("TestVarCopy<double, double>()");
t.Tic();
TestVarCopy<float, double>();
t.Toc("TestVarCopy<float, double>()");
t.Tic();
TestVarCopy<double, float>();
t.Toc("TestVarCopy<double, float>()");
#endif
t.Tic();
TestVarRegPrePost();
t.Toc("TestVarRegPrePost()");
t.Tic();
TestParVars();
t.Toc("TestParVars()");
t.Tic();
TestVarPrePostNames();
t.Toc("TestVarPrePostNames()");
t.Tic();
TestVarPrecalcUsedCL();
t.Toc("TestVarPrecalcUsedCL()");
t.Tic();
TestVarAssignTypes();
t.Toc("TestVarAssignTypes()");
t.Tic();
TestVarAssignVals();
t.Toc("TestVarAssignVals()");
t.Tic();
TestZepsFloor();
t.Toc("TestZepsFloor()");
t.Tic();
TestConstants();
t.Toc("TestConstants()");
t.Tic();
TestGlobalFuncs();
t.Toc("TestGlobalFuncs()");
/* t.Tic();
TestXformsInOutPoints();
t.Toc("TestXformsInOutPoints()");
//t.Tic(); t.Tic();
//TestCpuGpuResults<double>(); TestVarTime<float>();
//t.Toc("TestCpuGpuResults<double>()"); t.Toc("TestVarTime()");
if (b) */
{ t.Tic();
TestOperations<float>();
t.Toc("TestOperations()");
t.Tic();
TestArbitrary();
t.Toc("TestArbitrary()");
//t.Tic(); //t.Tic();
//b = TestAllVarsCLBuild<double>(0, 0, true); //TestVarsSimilar<float>();
//t.Toc("TestAllVarsCLBuild<double>()"); //t.Toc("TestVarsSimilar()");
#ifdef TEST_CL
//t.Tic();
//TestCpuGpuResults<float>();
//t.Toc("TestCpuGpuResults<float>()");
t.Tic();
b = TestAllVarsCLBuild<float>(0, 0, true);
t.Toc("TestAllVarsCLBuild<float>()");
if (b) if (b)
{ {
#ifdef DO_NVIDIA #ifdef DO_NVIDIA
t.Tic(); t.Tic();
TestAllVarsCLBuild<double>(1, 0, true); b = TestAllVarsCLBuild<float>(1, 0, true);
t.Toc("TestAllVarsCLBuild<double>()"); t.Toc("TestAllVarsCLBuild<float>()");
#endif #endif
} }
}
#ifdef DO_DOUBLE
//t.Tic();
//TestCpuGpuResults<double>();
//t.Toc("TestCpuGpuResults<double>()");
if (b)
{
t.Tic();
b = TestAllVarsCLBuild<double>(0, 0, true);
t.Toc("TestAllVarsCLBuild<double>()");
if (b)
{
#ifdef DO_NVIDIA
t.Tic();
TestAllVarsCLBuild<double>(1, 0, true);
t.Toc("TestAllVarsCLBuild<double>()");
#endif
}
}
#endif #endif
#endif #endif
};
cout << "\n\nTesting in compatibility mode:\n\n";
Compat::m_Compat = true;
testfunc();
cout << "\n\nTesting in non-compatibility mode:\n\n";
Compat::m_Compat = false;
testfunc();
//PrintAllVars(); //PrintAllVars();
//_CrtDumpMemoryLeaks(); //_CrtDumpMemoryLeaks();
return 0; return 0;

View File

@ -2409,7 +2409,7 @@
<x>860</x> <x>860</x>
<y>10</y> <y>10</y>
<width>295</width> <width>295</width>
<height>700</height> <height>761</height>
</rect> </rect>
</property> </property>
<property name="minimumSize"> <property name="minimumSize">
@ -2461,7 +2461,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>307</width> <width>307</width>
<height>674</height> <height>712</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy"> <property name="sizePolicy">
@ -2954,7 +2954,7 @@
</sizepolicy> </sizepolicy>
</property> </property>
<property name="toolTip"> <property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Reset all of the curves to their default position. This has the effect of disabling application of the color curves.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string> <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Reset the currently selected curve to its default position.&lt;/p&gt;&lt;p&gt;Ctrl + click resets all curves. This has the effect of disabling application of the color curves.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property> </property>
<property name="text"> <property name="text">
<string>Reset Curves</string> <string>Reset Curves</string>

View File

@ -1,7 +1,7 @@
#include "FractoriumPch.h" #include "FractoriumPch.h"
#include "Fractorium.h" #include "Fractorium.h"
#define XAOS_PREC 6 #define XAOS_PREC 8
/// <summary> /// <summary>
/// Initialize the xforms xaos UI. /// Initialize the xforms xaos UI.

View File

@ -6,7 +6,7 @@
/// </summary> /// </summary>
void Fractorium::InitXformsAffineUI() void Fractorium::InitXformsAffineUI()
{ {
const auto affinePrec = 6; const auto affinePrec = 8;
const auto spinHeight = 20; const auto spinHeight = 20;
const auto affineStep = 0.01; const auto affineStep = 0.01;
const auto affineMin = std::numeric_limits<double>::lowest(); const auto affineMin = std::numeric_limits<double>::lowest();

View File

@ -28,11 +28,11 @@ int main(int argc, char* argv[])
int rv = -1; int rv = -1;
QApplication a(argc, argv); QApplication a(argc, argv);
#ifdef TEST_CL #ifdef TEST_CL
QMessageBox::critical(QApplication::desktop(), "Error", "Fractorium cannot be run in test mode, undefine TEST_CL first."); QMessageBox::critical(nullptr, "Error", "Fractorium cannot be run in test mode, undefine TEST_CL first.");
return 1; return 1;
#endif #endif
#ifdef ISAAC_FLAM3_DEBUG #ifdef ISAAC_FLAM3_DEBUG
QMessageBox::critical(QApplication::desktop(), "Error", "Fractorium cannot be run in test mode, undefine ISAAC_FLAM3_DEBUG first."); QMessageBox::critical(nullptr, "Error", "Fractorium cannot be run in test mode, undefine ISAAC_FLAM3_DEBUG first.");
return 1; return 1;
#endif #endif
_MM_SET_FLUSH_ZERO_MODE(_MM_FLUSH_ZERO_ON); _MM_SET_FLUSH_ZERO_MODE(_MM_FLUSH_ZERO_ON);

View File

@ -246,7 +246,7 @@
<item row="6" column="0"> <item row="6" column="0">
<widget class="QCheckBox" name="Flam3CompatCheckBox"> <widget class="QCheckBox" name="Flam3CompatCheckBox">
<property name="toolTip"> <property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;The behavior of the cos, cosh, cot, coth, csc, csch, sec, sech, sin, sinh, tan and tanh variations are different in flam3/Apophysis versus Chaotica.&lt;/p&gt;&lt;p&gt;Checked: use the Apophysis behavior.&lt;/p&gt;&lt;p&gt;Unchecked: use the Chaotica behavior.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string> <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;The behavior of the asteria, bipolar, circlecrop, cos, cosh, cot, coth, cropn, cross, csc, csch, depth_ngon2, depth_sine2, edisc, escher, fan2, glynnia, hypershift, hypershift2, hypertile1, julia, julian, juliascope, loonie2, npolar, phoenix_julia, sec, sech, sin, sinh, sphericaln, tan, tanh, and truchet variations are different in flam3/Apophysis versus Chaotica.&lt;/p&gt;&lt;p&gt;Checked: use the Apophysis behavior.&lt;/p&gt;&lt;p&gt;Unchecked: use the Chaotica behavior.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property> </property>
<property name="text"> <property name="text">
<string>Flam3 Compatibility</string> <string>Flam3 Compatibility</string>