diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..6683e69
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,29 @@
+*.user
+*.opensdf
+*.sdf
+*.suo
+*.obj
+*.tlog
+*.def
+*.dll
+*.manifest
+*.exp
+*.lastbuildstate
+*.lib
+*.log
+*.map
+*.pdb
+*.cache
+*.res
+*.ipch
+*.bsc
+Builds/MSVC/VS2010/GeneratedFiles/Release/moc_AboutDialog.cpp
+*.exe
+*.xml
+*.ilk
+*.wixobj
+*.pch
+*.txt
+*.msi
+*.idb
+*.flam3
\ No newline at end of file
diff --git a/Builds/MSVC/VS2010/Fractorium.sln b/Builds/MSVC/VS2010/Fractorium.sln
index 9ca557c..f126860 100644
--- a/Builds/MSVC/VS2010/Fractorium.sln
+++ b/Builds/MSVC/VS2010/Fractorium.sln
@@ -579,7 +579,6 @@ Global
{C8096C47-E358-438C-A520-146D46B0637D}.Release|Mixed Platforms.Build.0 = Release|x86
{C8096C47-E358-438C-A520-146D46B0637D}.Release|Win32.ActiveCfg = Release|x86
{C8096C47-E358-438C-A520-146D46B0637D}.Release|x64.ActiveCfg = Release|x64
- {C8096C47-E358-438C-A520-146D46B0637D}.Release|x64.Build.0 = Release|x64
{C8096C47-E358-438C-A520-146D46B0637D}.Release|x86.ActiveCfg = Release|x86
{C8096C47-E358-438C-A520-146D46B0637D}.Release|x86.Build.0 = Release|x86
{C8096C47-E358-438C-A520-146D46B0637D}.Release-MT|Mixed Platforms.ActiveCfg = Release|x86
diff --git a/Builds/MSVC/VS2010/Fractorium.vcxproj b/Builds/MSVC/VS2010/Fractorium.vcxproj
index 65951e9..60f8f23 100644
--- a/Builds/MSVC/VS2010/Fractorium.vcxproj
+++ b/Builds/MSVC/VS2010/Fractorium.vcxproj
@@ -952,6 +952,7 @@ xcopy /F /Y /R /D "$(SolutionDir)..\..\..\Data\flam3-palettes.xml" "$(OutDir)"
.\GeneratedFiles\qrc_%(Filename).cpp;%(Outputs)
"$(QTDIR)\bin\rcc.exe" -name "%(Filename)" -no-compress "%(FullPath)" -o .\GeneratedFiles\qrc_%(Filename).cpp
"$(QTDIR)\bin\rcc.exe" -name "%(Filename)" -no-compress "%(FullPath)" -o .\GeneratedFiles\qrc_%(Filename).cpp
+ Designer
diff --git a/Builds/MSVC/VS2010/FractoriumInstaller/FractoriumInstaller.wixproj b/Builds/MSVC/VS2010/FractoriumInstaller/FractoriumInstaller.wixproj
index c74b043..f5273d8 100644
--- a/Builds/MSVC/VS2010/FractoriumInstaller/FractoriumInstaller.wixproj
+++ b/Builds/MSVC/VS2010/FractoriumInstaller/FractoriumInstaller.wixproj
@@ -6,7 +6,7 @@
3.7
{c8096c47-e358-438c-a520-146d46b0637d}
2.0
- Fractorium_Beta_0.4.0.4
+ Fractorium_Beta_0.4.0.5
Package
$(MSBuildExtensionsPath32)\Microsoft\WiX\v3.x\Wix.targets
$(MSBuildExtensionsPath)\Microsoft\WiX\v3.x\Wix.targets
diff --git a/Builds/MSVC/VS2010/FractoriumInstaller/Product.wxs b/Builds/MSVC/VS2010/FractoriumInstaller/Product.wxs
index 4a6c5b4..64321f9 100644
--- a/Builds/MSVC/VS2010/FractoriumInstaller/Product.wxs
+++ b/Builds/MSVC/VS2010/FractoriumInstaller/Product.wxs
@@ -1,6 +1,6 @@
-
+
@@ -13,7 +13,7 @@
-
+
1.
+ Add flatten and unflatten menu items.
+ Automatically flatten like Apophysis does.
+ Add plugin and new_linear tags to Xml to be compatible with Apophysis.
+
+--Bug Fixes
+ Fix blur, blur3d, bubble, cropn, cross, curl, curl3d, epispiral, ho, julia3d, julia3dz, loonie, mirror_x, mirror_y, mirror_z, rotate_x, sinusoidal, spherical, spherical3d, stripes.
+ Unique filename on final render was completely broken.
+ Two severe OpenCL bugs. Random seeds were biased and fusing was being reset too often leading to results that differ from the CPU.
+ Subtle, but sometimes severe bug in the setup of the xaos weights.
+ Use properly defined epsilon by getting the value from std::numeric_limits, rather than hard coding 1e-6 or 1e-10.
+ Omit incorrect usage of epsilon everywhere. It should not be automatically added to denominators. Rather, it should only be used if the denominator is zero.
+ Force final render progress bars to 100 on completion. Sometimes they didn't seem to make it there.
+ Make variation name and params comparisons be case insensitive.
+
+--Code Changes
+ Make ForEach and FindIf wrappers around std::for_each and std::find_if.
+
0.4.0.1 Beta 07/06/2014
--Bug Fixes
Fix name collision of mobius and Mobius. The former is treated as mobius_strip.
diff --git a/Source/Ember/Ember.cpp b/Source/Ember/Ember.cpp
index 61f43af..08a1f8f 100644
--- a/Source/Ember/Ember.cpp
+++ b/Source/Ember/Ember.cpp
@@ -392,8 +392,9 @@ auto_ptr> QTIsaac::GlobalR
bool PaletteList::m_Init = false; \
vector> PaletteList::m_Palettes = vector>(); \
bool XmlToEmber::m_Init = false; \
+ vector XmlToEmber::m_FlattenNames = vector(); \
vector> XmlToEmber::m_BadParamNames = vector>(); \
- vector> XmlToEmber::m_BadVariationNames = vector>();
+ vector, vector>> XmlToEmber::m_BadVariationNames = vector, vector>>();
EXPORT_SINGLE_TYPE_EMBER(float)
diff --git a/Source/Ember/Ember.h b/Source/Ember/Ember.h
index d0b2d7e..bb55066 100644
--- a/Source/Ember/Ember.h
+++ b/Source/Ember/Ember.h
@@ -493,7 +493,7 @@ public:
}
else if ((projBits & PROJBITS_PITCH) || (projBits & PROJBITS_YAW))
{
- if (m_CamYaw != 0)
+ if (projBits & PROJBITS_YAW)
m_ProjFunc = &EmberNs::Ember::ProjectPitchYaw;
else
m_ProjFunc = &EmberNs::Ember::ProjectPitch;
@@ -515,7 +515,7 @@ public:
{
bool b = false;
- std::for_each(m_Xforms.begin(), m_Xforms.end(), [&](Xform& xform) { b |= xform.XaosPresent(); });//If at least one entry is not equal to 1, then xaos is present.
+ ForEach(m_Xforms, [&](Xform& xform) { b |= xform.XaosPresent(); });//If at least one entry is not equal to 1, then xaos is present.
return b;
}
@@ -525,7 +525,7 @@ public:
///
void ClearXaos()
{
- std::for_each(m_Xforms.begin(), m_Xforms.end(), [&](Xform& xform) { xform.ClearXaos(); });
+ ForEach(m_Xforms, [&](Xform& xform) { xform.ClearXaos(); });
}
///
@@ -556,7 +556,7 @@ public:
{
T weight = T(1) / m_Xforms.size();
- std::for_each(m_Xforms.begin(), m_Xforms.end(), [&](Xform& xform) { xform.m_Weight = weight; });
+ ForEach(m_Xforms, [&](Xform& xform) { xform.m_Weight = weight; });
}
///
@@ -571,8 +571,8 @@ public:
if (normalizedWeights.size() != m_Xforms.size())
normalizedWeights.resize(m_Xforms.size());
- std::for_each(m_Xforms.begin(), m_Xforms.end(), [&](Xform& xform) { norm += xform.m_Weight; });
- std::for_each(normalizedWeights.begin(), normalizedWeights.end(), [&](T& weight) { weight = m_Xforms[i].m_Weight / norm; i++; });
+ ForEach(m_Xforms, [&](Xform& xform) { norm += xform.m_Weight; });
+ ForEach(normalizedWeights, [&](T& weight) { weight = m_Xforms[i].m_Weight / norm; i++; });
}
///
@@ -586,7 +586,7 @@ public:
unsigned int i = 0, xformIndex = 0, totalVarCount = m_FinalXform.TotalVariationCount();
variations.clear();
- std::for_each(m_Xforms.begin(), m_Xforms.end(), [&](const Xform& xform) { totalVarCount += xform.TotalVariationCount(); });
+ ForEach(m_Xforms, [&](const Xform& xform) { totalVarCount += xform.TotalVariationCount(); });
variations.reserve(totalVarCount);
while (Xform* xform = GetTotalXform(xformIndex++))
@@ -600,19 +600,52 @@ public:
{
string tempVarBaseName = tempVar->BaseName();
- if ((std::find_if(variations.begin(), variations.end(), [&] (const Variation* var) -> bool { return tempVar->VariationId() == var->VariationId(); }) == variations.end()) &&
- (std::find_if(variations.begin(), variations.end(), [&] (const Variation* var) -> bool { return tempVarBaseName == var->BaseName(); }) == variations.end()))
+ if (!FindIf(variations, [&] (const Variation* var) -> bool { return tempVar->VariationId() == var->VariationId(); }) &&
+ !FindIf(variations, [&] (const Variation* var) -> bool { return tempVarBaseName == var->BaseName(); }))
variations.push_back(tempVar);
}
else
{
- if (std::find_if(variations.begin(), variations.end(), [&] (const Variation* var) -> bool { return tempVar->VariationId() == var->VariationId(); }) == variations.end())
+ if (!FindIf(variations, [&] (const Variation* var) -> bool { return tempVar->VariationId() == var->VariationId(); }))
variations.push_back(tempVar);
}
}
}
}
+ ///
+ /// Flatten all xforms by adding a flatten variation if none is present, and if any of the
+ /// variations or parameters in the vector are present.
+ ///
+ /// Vector of variation and parameter names
+ /// True if flatten was added to any of the xforms, false if it already was present or if none of the specified variations or parameters were present.
+ bool Flatten(vector& names)
+ {
+ bool flattened = false;
+
+ ForEach(m_Xforms, [&](Xform& xform) { flattened |= xform.Flatten(names); });
+
+ return flattened;
+ }
+
+ ///
+ /// Flatten all xforms by adding a flatten variation in each if not already present.
+ ///
+ /// True if flatten was removed, false if it wasn't present.
+ bool Unflatten()
+ {
+ bool unflattened = false;
+
+ ForEach(m_Xforms, [&](Xform& xform)
+ {
+ unflattened |= xform.DeleteVariationById(VAR_PRE_FLATTEN);
+ unflattened |= xform.DeleteVariationById(VAR_FLATTEN);
+ unflattened |= xform.DeleteVariationById(VAR_POST_FLATTEN);
+ });
+
+ return unflattened;
+ }
+
///
/// Thin wrapper around Interpolate() which takes a vector of embers rather than a pointer and size.
/// All embers are expected to be aligned, including the final xform. If not the behavior is undefined.
@@ -1086,7 +1119,7 @@ public:
void ProjectZPerspective(Point& point, QTIsaac& rand)
{
- T zr = 1 - m_CamPerspective * (point.m_Z - m_CamZPos);
+ T zr = Zeps(1 - m_CamPerspective * (point.m_Z - m_CamZPos));
point.m_X /= zr;
point.m_Y /= zr;
@@ -1097,7 +1130,7 @@ public:
{
T z = point.m_Z - m_CamZPos;
T y = m_CamMat[1][1] * point.m_Y + m_CamMat[2][1] * z;
- T zr = 1 - m_CamPerspective * (m_CamMat[1][2] * point.m_Y + m_CamMat[2][2] * z);
+ T zr = Zeps(1 - m_CamPerspective * (m_CamMat[1][2] * point.m_Y + m_CamMat[2][2] * z));
point.m_X /= zr;
point.m_Y = y / zr;
@@ -1113,7 +1146,7 @@ public:
z = point.m_Z - m_CamZPos;
y = m_CamMat[1][1] * point.m_Y + m_CamMat[2][1] * z;
z = m_CamMat[1][2] * point.m_Y + m_CamMat[2][2] * z;
- zr = 1 - m_CamPerspective * z;
+ zr = Zeps(1 - m_CamPerspective * z);
sincos(t, &dsin, &dcos);
@@ -1134,7 +1167,7 @@ public:
z = m_CamMat[0][2] * point.m_X + m_CamMat[1][2] * point.m_Y + m_CamMat[2][2] * z;
- T zr = 1 - m_CamPerspective * z;
+ T zr = Zeps(1 - m_CamPerspective * z);
T dr = rand.Frand01() * m_BlurCoef * z;
sincos(t, &dsin, &dcos);
@@ -1149,7 +1182,7 @@ public:
T z = point.m_Z - m_CamZPos;
T x = m_CamMat[0][0] * point.m_X + m_CamMat[1][0] * point.m_Y;
T y = m_CamMat[0][1] * point.m_X + m_CamMat[1][1] * point.m_Y + m_CamMat[2][1] * z;
- T zr = 1 - m_CamPerspective * (m_CamMat[0][2] * point.m_X + m_CamMat[1][2] * point.m_Y + m_CamMat[2][2] * z);
+ T zr = Zeps(1 - m_CamPerspective * (m_CamMat[0][2] * point.m_X + m_CamMat[1][2] * point.m_Y + m_CamMat[2][2] * z));
point.m_X = x / zr;
point.m_Y = y / zr;
diff --git a/Source/Ember/EmberDefines.h b/Source/Ember/EmberDefines.h
index 2416a9e..28cfbc0 100644
--- a/Source/Ember/EmberDefines.h
+++ b/Source/Ember/EmberDefines.h
@@ -25,9 +25,9 @@ namespace EmberNs
extern void sincos(double x, double *s, double *c);
#endif
-#define EMBER_VERSION "0.4.0.4"
+#define EMBER_VERSION "0.4.0.5"
#define EPS6 T(1e-6)
-#define EPS T(1e-10)//Apoplugin.h uses -20, but -10 seems to work fine.
+#define EPS std::numeric_limits::epsilon()//Apoplugin.h uses -20, but it's more mathematically correct to do it this way.
#define ISAAC_SIZE 4
#define MEMALIGN 32
#define DE_THRESH 100
@@ -61,6 +61,7 @@ namespace EmberNs
#endif
#define DO_DOUBLE 1//Comment this out for shorter build times during development. Always uncomment for release.
+//#define ISAAC_FLAM3_DEBUG 1//This is almost never needed, but is very useful when troubleshooting difficult bugs. Enable it to do a side by side comparison with flam3.
#define v2T glm::detail::tvec2
#define v3T glm::detail::tvec3
diff --git a/Source/Ember/EmberToXml.h b/Source/Ember/EmberToXml.h
index 1365328..766f52f 100644
--- a/Source/Ember/EmberToXml.h
+++ b/Source/Ember/EmberToXml.h
@@ -128,6 +128,7 @@ public:
{
unsigned int i, j;
ostringstream os;
+ vector*> variations;
os << "* var) { os << var->Name() << (var != variations.back() ? " " : "\""); });
+ else
+ os << "\"";
+
+ os << " new_linear=\"1\"";
os << ">\n";
//This is a grey area, what to do about symmetry to avoid duplicating the symmetry xforms when reading back?//TODO//BUG.
@@ -455,7 +465,7 @@ private:
//os << "color=\"" << xform.m_ColorX << " " << xform.m_ColorY << "\" ";
os << "var_color=\"" << xform.m_DirectColor << "\" ";
os << "color_speed=\"" << xform.m_ColorSpeed << "\" ";
- os << "symmetry=\"" << xform.m_ColorSpeed << "\" ";//Legacy support.
+ //os << "symmetry=\"" << fabs(xform.m_ColorSpeed - 1) * 2 << "\" ";//Legacy support.
string s = xform.m_Name;
diff --git a/Source/Ember/Isaac.h b/Source/Ember/Isaac.h
index a3c97f6..db3e810 100644
--- a/Source/Ember/Isaac.h
+++ b/Source/Ember/Isaac.h
@@ -92,7 +92,11 @@ public:
/// The next random integer
inline T Rand()
{
+#ifdef ISAAC_FLAM3_DEBUG
+ return (!m_Rc.randcnt-- ? (Isaac(&m_Rc), m_Rc.randcnt=N-1, m_Rc.randrsl[m_Rc.randcnt]) : m_Rc.randrsl[m_Rc.randcnt]);
+#else
return (m_Rc.randcnt++ == N ? (Isaac(&m_Rc), m_Rc.randcnt=0, m_Rc.randrsl[m_Rc.randcnt]) : m_Rc.randrsl[m_Rc.randcnt]);
+#endif
}
///
@@ -126,7 +130,11 @@ public:
template
inline floatType Frand01()
{
+#ifdef ISAAC_FLAM3_DEBUG
+ return (Rand() & 0xfffffff) / (floatType)0xfffffff;
+#else
return Frand(floatType(0), floatType(1));
+#endif
}
///
@@ -137,7 +145,11 @@ public:
template
inline floatType Frand11()
{
+#ifdef ISAAC_FLAM3_DEBUG
+ return ((Rand() & 0xfffffff) - 0x7ffffff) / (floatType)0x7ffffff;
+#else
return Frand(floatType(-1), floatType(1));
+#endif
}
///
@@ -233,7 +245,7 @@ public:
}
Isaac(ctx); //Fill in the first set of results.
- ctx->randcnt = 0;//Prepare to use the first set of results.
+ ctx->randcnt = N;//TODO//0;//Prepare to use the first set of results.
}
///
@@ -257,6 +269,7 @@ public:
m_Rc.randrsl[i] = s[i];
}
+#ifndef ISAAC_FLAM3_DEBUG
if (a == 0 && b == 0 && c == 0)
{
m_Rc.randa = (T)time(0);
@@ -264,6 +277,7 @@ public:
m_Rc.randc = (T)time(0) * (T)time(0) * (T)time(0);
}
else
+#endif
{
m_Rc.randa = a;
m_Rc.randb = b;
diff --git a/Source/Ember/Iterator.h b/Source/Ember/Iterator.h
index 9df347b..4accb33 100644
--- a/Source/Ember/Iterator.h
+++ b/Source/Ember/Iterator.h
@@ -80,7 +80,7 @@ public:
/// True if success, else false.
bool InitDistributions(Ember& ember)
{
- unsigned int i, j = 0;
+ unsigned int i;
unsigned int distribCount = ember.XaosPresent() ? (unsigned int)ember.XformCount() + 1 : 1;
const Xform* xforms = ember.Xforms();
@@ -101,10 +101,6 @@ public:
if (distrib > 0)
d *= xforms[distrib - 1].Xaos(i);
-
- //Original returned false if any xform had 0 density, it's allowed here
- //because it can be useful when experimenting to test the effects of removing an
- //xform by setting its probability to 0.
totalDensity += d;
}
@@ -114,29 +110,55 @@ public:
//only the first xform will get used.
//Calculate how much of a fraction of a the total density each element represents.
- T densityPerElement = totalDensity / CHOOSE_XFORM_GRAIN;
- j = 0;
+ unsigned int j = 0;
+ T tempDensity = 0, currentDensityLimit = 0, densityPerElement = totalDensity / CHOOSE_XFORM_GRAIN;
//Assign xform indices in order to each element of m_XformDistributions.
//The number of elements assigned a given index is proportional to that xform's
//density relative to the sum of all densities.
for (i = 0; i < ember.XformCount(); i++)
{
- T tempDensity = 0;
- T currentDensityLimit = xforms[i].m_Weight;
-
+ T temp = xforms[i].m_Weight;
+
if (distrib > 0)
- currentDensityLimit *= xforms[distrib - 1].Xaos(i);
-
+ temp *= xforms[distrib - 1].Xaos(i);
+
+ currentDensityLimit += temp;
+
//Populate points corresponding to this xform's weight/density.
//Also check that j is within the bounds of the distribution array just to be safe in the case of a rounding error.
- while (tempDensity <= currentDensityLimit && j < CHOOSE_XFORM_GRAIN)
+ while (tempDensity < currentDensityLimit && j < CHOOSE_XFORM_GRAIN)
{
+ //printf("offset = %d, xform = %d, running sum = %f\n", j, i, tempDensity);
m_XformDistributions[(distrib * CHOOSE_XFORM_GRAIN) + j] = i;
tempDensity += densityPerElement;
j++;
}
}
+
+ //Flam3 did this, which gives the same result.
+ //T t = xforms[0].m_Weight;
+ //
+ //if (distrib > 0)
+ // t *= xforms[distrib - 1].Xaos(0);
+ //
+ //T r = 0;
+ //
+ //for (i = 0; i < CHOOSE_XFORM_GRAIN; i++)
+ //{
+ // while (r >= t)
+ // {
+ // j++;
+ //
+ // if (distrib > 0)
+ // t += xforms[j].m_Weight * xforms[distrib - 1].Xaos(j);
+ // else
+ // t += xforms[j].m_Weight;
+ // }
+ //
+ // m_XformDistributions[(distrib * CHOOSE_XFORM_GRAIN) + i] = j;
+ // r += densityPerElement;
+ //}
}
return true;
@@ -205,6 +227,10 @@ protected:
ember.NonConstFinalXform()->Apply(&tempPoint, sample, rand);
sample->m_VizAdjusted = tempVizAdjusted;
}
+ else
+ {
+ *sample = tempPoint;
+ }
}
///
@@ -462,8 +488,8 @@ public:
lastXformUsed = xformIndex + 1;//Store the last used transform.
}
- ember.Proj(p1, rand);
samples[0] = p1;
+ ember.Proj(samples[0], rand);
for (i = 1; i < count; i++)//Real loop.
{
diff --git a/Source/Ember/Renderer.cpp b/Source/Ember/Renderer.cpp
index 1fc8229..a92dc18 100644
--- a/Source/Ember/Renderer.cpp
+++ b/Source/Ember/Renderer.cpp
@@ -1001,10 +1001,13 @@ void Renderer::ThreadCount(unsigned int threads, const char* seedStr
if (seedString)
{
- unsigned int newSize = size + 5;
+ unsigned int newSize = size + 5 + (unsigned int)(t.Toc() + t.EndTime());
+#ifdef ISAAC_FLAM3_DEBUG
+ QTIsaac isaac(0, 0, 0, seeds);
+#else
QTIsaac isaac(newSize, newSize * newSize, newSize * newSize * newSize, seeds);
-
+#endif
m_Rand.push_back(isaac);
for (i = 0; i < (isaacSize * sizeof(ISAAC_INT)); i++)
@@ -1597,10 +1600,10 @@ EmberStats Renderer::Iterate(unsigned __int64 iterCount, unsigned in
//Use first as random point, the rest are iterated points.
//Note that this gets reset with a new random point for each subBatchSize iterations.
//This helps correct if iteration happens to be on a bad trajectory.
- m_Samples[threadIndex][0].m_X = (T)m_Rand[threadIndex].Frand11();
- m_Samples[threadIndex][0].m_Y = (T)m_Rand[threadIndex].Frand11();
+ m_Samples[threadIndex][0].m_X = m_Rand[threadIndex].Frand11();
+ m_Samples[threadIndex][0].m_Y = m_Rand[threadIndex].Frand11();
m_Samples[threadIndex][0].m_Z = 0;//m_Ember.m_CamZPos;//Apo set this to 0, then made the user use special variations to kick it. It seems easier to just set it to zpos.
- m_Samples[threadIndex][0].m_ColorX = (T)m_Rand[threadIndex].Frand01();
+ m_Samples[threadIndex][0].m_ColorX = m_Rand[threadIndex].Frand01();
//Finally, iterate.
//t.Tic();
diff --git a/Source/Ember/Utils.h b/Source/Ember/Utils.h
index fb29df7..8f4ccb5 100644
--- a/Source/Ember/Utils.h
+++ b/Source/Ember/Utils.h
@@ -8,6 +8,31 @@
///
namespace EmberNs
{
+///
+/// Thin wrapper around std::find_if() to relieve the caller of having to
+/// pass the implicitly obvious .begin() and .end(), and then compare the results to .end().
+///
+/// The container to call find_if() on
+/// The lambda to call on each element
+/// True if pred returned true once, else false.
+template
+bool inline FindIf(c& container, pr pred)
+{
+ return std::find_if(container.begin(), container.end(), pred) != container.end();
+}
+
+///
+/// Thin wrapper around std::for_each() to relieve the caller of having to
+/// pass the implicitly obvious .begin() and .end().
+///
+/// The container to call for_each() on
+/// The lambda to call on each element
+template
+void inline ForEach(c& container, fn func)
+{
+ std::for_each(container.begin(), container.end(), func);
+}
+
///
/// After a run completes, information about what was run can be saved as strings to the comments
/// section of a jpg or png file. This class is just a container for those values.
@@ -100,7 +125,7 @@ public:
{
stringstream ss;
- std::for_each(errorReport.begin() , errorReport.end() , [&](string s) { ss << s << endl; });
+ ForEach(errorReport, [&](string s) { ss << s << endl; });
return ss.str();
}
@@ -515,15 +540,15 @@ static inline T Powq4c(T x, T y)
}
///
-/// Return EPS6 if the passed in value was zero, else return the value.
+/// Return EPS if the passed in value was zero, else return the value.
///
/// The value
/// The y distance
-/// EPS6 or the value if it was non-zero
+/// EPS or the value if it was non-zero
template
static inline T Zeps(T x)
{
- return x == 0 ? EPS6 : x;
+ return x == 0 ? EPS : x;
}
///
diff --git a/Source/Ember/Variation.h b/Source/Ember/Variation.h
index 8442f9d..1ea52c3 100644
--- a/Source/Ember/Variation.h
+++ b/Source/Ember/Variation.h
@@ -1527,7 +1527,7 @@ public:
T vd = max(min(val, m_Max), m_Min);
if (IsNearZero(vd))
- *m_Param = EPS6 * SignNz(vd);
+ *m_Param = EPS * SignNz(vd);
else
*m_Param = vd;
@@ -1667,9 +1667,9 @@ public:
{
bool b = false;
- std::for_each(m_Params.begin() , m_Params.end() , [&](ParamWithName& param)
+ ForEach(m_Params, [&](ParamWithName& param)
{
- if (!strcmp(param.Name().c_str(), name))
+ if (!_stricmp(param.Name().c_str(), name))
b = true;
});
@@ -1684,7 +1684,7 @@ public:
T* GetParam(const char* name)
{
for (size_t i = 0; i < m_Params.size(); i++)
- if (!strcmp(m_Params[i].Name().c_str(), name))
+ if (!_stricmp(m_Params[i].Name().c_str(), name))
return m_Params[i].Param();
return NULL;
@@ -1698,7 +1698,7 @@ public:
T GetParamVal(const char* name) const
{
for (size_t i = 0; i < m_Params.size(); i++)
- if (!strcmp(m_Params[i].Name().c_str(), name))
+ if (!_stricmp(m_Params[i].Name().c_str(), name))
return m_Params[i].ParamVal();
return 0;
@@ -1714,9 +1714,9 @@ public:
{
bool b = false;
- std::for_each(m_Params.begin(), m_Params.end(), [&](ParamWithName& param)
+ ForEach(m_Params, [&](ParamWithName& param)
{
- if (!strcmp(param.Name().c_str(), name))
+ if (!_stricmp(param.Name().c_str(), name))
{
param.Set(val);
b = true;
@@ -1756,7 +1756,7 @@ public:
virtual void Random(QTIsaac& rand)
{
Variation::Random(rand);
- std::for_each(m_Params.begin(), m_Params.end(), [&](ParamWithName& param) { param.Set(rand.Frand11()); });
+ ForEach(m_Params, [&](ParamWithName& param) { param.Set(rand.Frand11()); });
Precalc();
}
@@ -1765,10 +1765,29 @@ public:
///
void Clear()
{
- std::for_each(m_Params.begin(), m_Params.end(), [&](ParamWithName& param) { *(param.Param()) = 0; });
+ ForEach(m_Params, [&](ParamWithName& param) { *(param.Param()) = 0; });
Precalc();
}
+ ///
+ /// Return a vector of all parameter names, optionally including precalcs.
+ ///
+ /// Whether to include the names of precalcs in the returned vector
+ /// A vector of all parameter names
+ vector ParamNames(bool includePrecalcs = false)
+ {
+ vector vec;
+
+ vec.reserve(m_Params.size());
+ ForEach(m_Params, [&](const ParamWithName& param)
+ {
+ if ((includePrecalcs && param.IsPrecalc()) || !param.IsPrecalc())
+ vec.push_back(param.Name());
+ });
+
+ return vec;
+ }
+
///
/// Return the name, weight and parameters of the variation as a string.
///
@@ -1778,7 +1797,7 @@ public:
ostringstream ss;
ss << Variation::ToString() << endl;
- std::for_each(m_Params.begin(), m_Params.end(), [&](const ParamWithName& param) { ss << param.ToString() << endl; });
+ ForEach(m_Params, [&](const ParamWithName& param) { ss << param.ToString() << endl; });
return ss.str();
}
diff --git a/Source/Ember/VariationList.h b/Source/Ember/VariationList.h
index 36e408e..951e0c0 100644
--- a/Source/Ember/VariationList.h
+++ b/Source/Ember/VariationList.h
@@ -342,16 +342,16 @@ public:
ADDPREPOSTREGVAR(DCTriangle)
ADDPREPOSTREGVAR(DCZTransl)
- std::for_each(m_Variations.begin(), m_Variations.end(), [&](Variation* var) { var->Precalc(); });
+ ForEach(m_Variations, [&](Variation* var) { var->Precalc(); });
std::sort(m_Variations.begin(), m_Variations.end(), [&](const Variation* var1, const Variation* var2) { return var1->VariationId() < var2->VariationId(); });
m_RegVariations.reserve(m_Variations.size() / 3);
m_PreVariations.reserve(m_Variations.size() / 3);
m_PostVariations.reserve(m_Variations.size() / 3);
- std::for_each(m_Variations.begin(), m_Variations.end(), [&](Variation* var) { if (var->VarType() == VARTYPE_REG) m_RegVariations.push_back(var); });
- std::for_each(m_Variations.begin(), m_Variations.end(), [&](Variation* var) { if (var->VarType() == VARTYPE_PRE) m_PreVariations.push_back(var); });
- std::for_each(m_Variations.begin(), m_Variations.end(), [&](Variation* var) { if (var->VarType() == VARTYPE_POST) m_PostVariations.push_back(var); });
+ ForEach(m_Variations, [&](Variation* var) { if (var->VarType() == VARTYPE_REG) m_RegVariations.push_back(var); });
+ ForEach(m_Variations, [&](Variation* var) { if (var->VarType() == VARTYPE_PRE) m_PreVariations.push_back(var); });
+ ForEach(m_Variations, [&](Variation* var) { if (var->VarType() == VARTYPE_POST) m_PostVariations.push_back(var); });
//Keep a list of which variations derive from ParametricVariation.
//Note that these are not new copies, rather just pointers to the original instances in m_Variations.
@@ -436,7 +436,7 @@ public:
Variation* GetVariation(string name)
{
for (unsigned int i = 0; i < m_Variations.size() && m_Variations[i] != NULL; i++)
- if (name == m_Variations[i]->Name())
+ if (!_stricmp(name.c_str(), m_Variations[i]->Name().c_str()))
return m_Variations[i];
return NULL;
@@ -467,7 +467,7 @@ public:
ParametricVariation* GetParametricVariation(string name)
{
for (unsigned int i = 0; i < m_ParametricVariations.size() && m_ParametricVariations[i] != NULL; i++)
- if (name == m_ParametricVariations[i]->Name())
+ if (!_stricmp(name.c_str(), m_ParametricVariations[i]->Name().c_str()))
return m_ParametricVariations[i];
return NULL;
@@ -481,7 +481,7 @@ public:
int GetVariationIndex(string name)
{
for (unsigned int i = 0; i < m_Variations.size() && m_Variations[i] != NULL; i++)
- if (name == m_Variations[i]->Name())
+ if (!_stricmp(name.c_str(), m_Variations[i]->Name().c_str()))
return i;
return -1;
diff --git a/Source/Ember/Variations01.h b/Source/Ember/Variations01.h
index 22da9d3..87c580d 100644
--- a/Source/Ember/Variations01.h
+++ b/Source/Ember/Variations01.h
@@ -29,7 +29,7 @@ public:
virtual string OpenCLString()
{
ostringstream ss;
- int i = 0, varIndex = IndexInXform();
+ int varIndex = IndexInXform();
ss << "\t{\n"
<< "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * vIn.x;\n"
@@ -60,16 +60,18 @@ public:
{
helper.Out.x = m_Weight * sin(helper.In.x);
helper.Out.y = m_Weight * sin(helper.In.y);
+ helper.Out.z = m_Weight * helper.In.z;
}
virtual string OpenCLString()
{
ostringstream ss;
- int i = 0, varIndex = IndexInXform();
+ int varIndex = IndexInXform();
ss << "\t{\n"
<< "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * sin(vIn.x);\n"
<< "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * sin(vIn.y);\n"
+ << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n"
<< "\t}\n";
return ss.str();
@@ -94,22 +96,24 @@ public:
void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand)
{
- T r2 = m_Weight / (helper.m_PrecalcSumSquares + EPS6);
+ T r2 = m_Weight / Zeps(helper.m_PrecalcSumSquares);
helper.Out.x = r2 * helper.In.x;
helper.Out.y = r2 * helper.In.y;
+ helper.Out.z = m_Weight * helper.In.z;
}
virtual string OpenCLString()
{
ostringstream ss;
- int i = 0, varIndex = IndexInXform();
+ int varIndex = IndexInXform();
ss << "\t{\n"
- << "\t\treal_t r2 = xform->m_VariationWeights[" << varIndex << "] / (precalcSumSquares + EPS6);\n"
+ << "\t\treal_t r2 = xform->m_VariationWeights[" << varIndex << "] / Zeps(precalcSumSquares);\n"
<< "\n"
<< "\t\tvOut.x = r2 * vIn.x;\n"
<< "\t\tvOut.y = r2 * vIn.y;\n"
+ << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n"
<< "\t}\n";
return ss.str();
@@ -147,7 +151,7 @@ public:
virtual string OpenCLString()
{
ostringstream ss;
- int i = 0, varIndex = IndexInXform();
+ int varIndex = IndexInXform();
ss << "\t{\n"
<< "\t\treal_t c1 = sin(precalcSumSquares);\n"
@@ -182,7 +186,7 @@ public:
void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand)
{
- T r = m_Weight / (helper.m_PrecalcSqrtSumSquares + T(EPS));
+ T r = m_Weight / Zeps(helper.m_PrecalcSqrtSumSquares);
helper.Out.x = (helper.In.x - helper.In.y) * (helper.In.x + helper.In.y) * r;
helper.Out.y = 2 * helper.In.x * helper.In.y * r;
@@ -192,10 +196,10 @@ public:
virtual string OpenCLString()
{
ostringstream ss;
- int i = 0, varIndex = IndexInXform();
+ int varIndex = IndexInXform();
ss << "\t{\n"
- << "\t\treal_t r = xform->m_VariationWeights[" << varIndex << "] / (precalcSqrtSumSquares + EPS);\n"
+ << "\t\treal_t r = xform->m_VariationWeights[" << varIndex << "] / Zeps(precalcSqrtSumSquares);\n"
<< "\n"
<< "\t\tvOut.x = (vIn.x - vIn.y) * (vIn.x + vIn.y) * r;\n"
<< "\t\tvOut.y = 2.0 * vIn.x * vIn.y * r;\n"
@@ -223,22 +227,19 @@ public:
void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand)
{
- T nx = helper.m_PrecalcAtanxy * T(M_1_PI);
- T ny = helper.m_PrecalcSqrtSumSquares - 1;
-
- helper.Out.x = m_Weight * nx;
- helper.Out.y = m_Weight * ny;
+ helper.Out.x = m_Weight * (helper.m_PrecalcAtanxy * T(M_1_PI));
+ helper.Out.y = m_Weight * (helper.m_PrecalcSqrtSumSquares - 1);
helper.Out.z = m_Weight * helper.In.z;
}
virtual string OpenCLString()
{
ostringstream ss;
- int i = 0, varIndex = IndexInXform();
+ int varIndex = IndexInXform();
ss << "\t{\n"
- << "\t\tvOut.x = (xform->m_VariationWeights[" << varIndex << "] * (precalcAtanxy * M_1_PI));\n"
- << "\t\tvOut.y = (xform->m_VariationWeights[" << varIndex << "] * (precalcSqrtSumSquares - 1.0));\n"
+ << "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * (precalcAtanxy * M_1_PI);\n"
+ << "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * (precalcSqrtSumSquares - 1.0);\n"
<< "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n"
<< "\t}\n";
@@ -271,7 +272,7 @@ public:
virtual string OpenCLString()
{
ostringstream ss;
- int i = 0, varIndex = IndexInXform();
+ int varIndex = IndexInXform();
ss << "\t{\n"
<< "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * precalcSqrtSumSquares * sin(precalcAtanxy + precalcSqrtSumSquares);\n"
@@ -312,7 +313,7 @@ public:
virtual string OpenCLString()
{
ostringstream ss;
- int i = 0, varIndex = IndexInXform();
+ int varIndex = IndexInXform();
ss << "\t{\n"
<< "\t\treal_t a = precalcSqrtSumSquares * precalcAtanxy;\n"
@@ -412,7 +413,7 @@ public:
void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand)
{
- T r = helper.m_PrecalcSqrtSumSquares + T(EPS);
+ T r = Zeps(helper.m_PrecalcSqrtSumSquares);
T r1 = m_Weight / r;
helper.Out.x = r1 * (helper.m_PrecalcCosa + sin(r));
@@ -423,10 +424,10 @@ public:
virtual string OpenCLString()
{
ostringstream ss;
- int i = 0, varIndex = IndexInXform();
+ int varIndex = IndexInXform();
ss << "\t{\n"
- << "\t\treal_t r = precalcSqrtSumSquares + EPS;\n"
+ << "\t\treal_t r = Zeps(precalcSqrtSumSquares);\n"
<< "\t\treal_t r1 = xform->m_VariationWeights[" << varIndex << "] / r;\n"
<< "\n"
<< "\t\tvOut.x = r1 * (precalcCosa + sin(r));\n"
@@ -455,7 +456,7 @@ public:
void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand)
{
- T r = helper.m_PrecalcSqrtSumSquares + T(EPS);
+ T r = Zeps(helper.m_PrecalcSqrtSumSquares);
helper.Out.x = m_Weight * helper.m_PrecalcSina / r;
helper.Out.y = m_Weight * helper.m_PrecalcCosa * r;
@@ -465,10 +466,10 @@ public:
virtual string OpenCLString()
{
ostringstream ss;
- int i = 0, varIndex = IndexInXform();
+ int varIndex = IndexInXform();
ss << "\t{\n"
- << "\t\treal_t r = precalcSqrtSumSquares + EPS;\n"
+ << "\t\treal_t r = Zeps(precalcSqrtSumSquares);\n"
<< "\n"
<< "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * precalcSina / r;\n"
<< "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * precalcCosa * r;\n"
@@ -504,7 +505,7 @@ public:
virtual string OpenCLString()
{
ostringstream ss;
- int i = 0, varIndex = IndexInXform();
+ int varIndex = IndexInXform();
ss << "\t{\n"
<< "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * precalcSina * cos(precalcSqrtSumSquares);\n"
@@ -552,7 +553,7 @@ public:
virtual string OpenCLString()
{
ostringstream ss;
- int i = 0, varIndex = IndexInXform();
+ int varIndex = IndexInXform();
ss << "\t{\n"
<< "\t\treal_t a = precalcAtanxy;\n"
@@ -605,7 +606,7 @@ public:
virtual string OpenCLString()
{
ostringstream ss;
- int i = 0, varIndex = IndexInXform();
+ int varIndex = IndexInXform();
ss << "\t{\n"
<< "\t\treal_t r = xform->m_VariationWeights[" << varIndex << "] * sqrt(precalcSqrtSumSquares);\n"
@@ -653,7 +654,7 @@ public:
virtual string OpenCLString()
{
ostringstream ss;
- int i = 0, varIndex = IndexInXform();
+ int varIndex = IndexInXform();
ss << "\t{\n"
<< "\t\treal_t nx = vIn.x < 0.0 ? (vIn.x * 2.0) : vIn.x;\n"
@@ -731,8 +732,8 @@ public:
T dx = m_Xform->m_Affine.C();
T dy = m_Xform->m_Affine.F();
- m_Dx2 = 1 / (dx * dx + T(EPS));
- m_Dy2 = 1 / (dy * dy + T(EPS));
+ m_Dx2 = 1 / Zeps(dx * dx);
+ m_Dy2 = 1 / Zeps(dy * dy);
}
}
@@ -781,7 +782,7 @@ public:
virtual string OpenCLString()
{
ostringstream ss;
- int i = 0, varIndex = IndexInXform();
+ int varIndex = IndexInXform();
ss << "\t{\n"
<< "\t\treal_t r = 2 * xform->m_VariationWeights[" << varIndex << "] / (precalcSqrtSumSquares + 1);\n"
@@ -827,7 +828,7 @@ public:
virtual string OpenCLString()
{
ostringstream ss;
- int i = 0, varIndex = IndexInXform();
+ int varIndex = IndexInXform();
ss << "\t{\n"
<< "\t\treal_t dx = tan(3 * vIn.y);\n"
@@ -874,7 +875,7 @@ public:
virtual string OpenCLString()
{
ostringstream ss;
- int i = 0, varIndex = IndexInXform();
+ int varIndex = IndexInXform();
ss << "\t{\n"
<< "\t\treal_t dx = xform->m_VariationWeights[" << varIndex << "] * exp(vIn.x - 1.0);\n"
@@ -920,7 +921,7 @@ public:
virtual string OpenCLString()
{
ostringstream ss;
- int i = 0, varIndex = IndexInXform();
+ int varIndex = IndexInXform();
ss << "\t{\n"
<< "\t\treal_t r = xform->m_VariationWeights[" << varIndex << "] * pow(precalcSqrtSumSquares, precalcSina);\n"
@@ -963,7 +964,7 @@ public:
virtual string OpenCLString()
{
ostringstream ss;
- int i = 0, varIndex = IndexInXform();
+ int varIndex = IndexInXform();
ss << "\t{\n"
<< "\t\treal_t a = vIn.x * M_PI;\n"
@@ -1001,7 +1002,7 @@ public:
void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand)
{
- T dx = m_Xform->m_Affine.C() * m_Xform->m_Affine.C() + T(EPS);
+ T dx = Zeps(m_Xform->m_Affine.C() * m_Xform->m_Affine.C());
T r = helper.m_PrecalcSqrtSumSquares;
r = m_Weight * (fmod(r + dx, 2 * dx) - dx + r * (1 - dx));
@@ -1013,10 +1014,10 @@ public:
virtual string OpenCLString()
{
ostringstream ss;
- int i = 0, varIndex = IndexInXform();
+ int varIndex = IndexInXform();
ss << "\t{\n"
- << "\t\treal_t dx = xform->m_C * xform->m_C + EPS;\n"
+ << "\t\treal_t dx = Zeps(xform->m_C * xform->m_C);\n"
<< "\t\treal_t r = precalcSqrtSumSquares;\n"
<< "\n"
<< "\t\tr = xform->m_VariationWeights[" << varIndex << "] * (fmod(r + dx, 2 * dx) - dx + r * (1 - dx));\n"
@@ -1053,7 +1054,7 @@ public:
void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand)
{
- T dx = T(M_PI) * (m_Xform->m_Affine.C() * m_Xform->m_Affine.C() + T(EPS));
+ T dx = T(M_PI) * Zeps(m_Xform->m_Affine.C() * m_Xform->m_Affine.C());
T dy = m_Xform->m_Affine.F();
T dx2 = T(0.5) * dx;
T a = helper.m_PrecalcAtanxy;
@@ -1068,10 +1069,10 @@ public:
virtual string OpenCLString()
{
ostringstream ss;
- int i = 0, varIndex = IndexInXform();
+ int varIndex = IndexInXform();
ss << "\t{\n"
- << "\t\treal_t dx = M_PI * (xform->m_C * xform->m_C + EPS);\n"
+ << "\t\treal_t dx = M_PI * Zeps(xform->m_C * xform->m_C);\n"
<< "\t\treal_t dy = xform->m_F;\n"
<< "\t\treal_t dx2 = 0.5 * dx;\n"
<< "\t\treal_t a = precalcAtanxy + ((fmod(precalcAtanxy + dy, dx) > dx2) ? -dx2 : dx2);\n"
@@ -1114,6 +1115,7 @@ public:
helper.Out.x = m_Weight * helper.m_PrecalcSina * r;
helper.Out.y = m_Weight * helper.m_PrecalcCosa * r;
+ helper.Out.z = (m_VarType == VARTYPE_REG) ? 0 : helper.In.z;
}
virtual string OpenCLString()
@@ -1132,6 +1134,7 @@ public:
<< "\n"
<< "\t\tvOut.x = (xform->m_VariationWeights[" << varIndex << "] * precalcSina * r);\n"
<< "\t\tvOut.y = (xform->m_VariationWeights[" << varIndex << "] * precalcCosa * r);\n"
+ << "\t\tvOut.z = " << ((m_VarType == VARTYPE_REG) ? "0" : "vIn.z") << ";\n"
<< "\t}\n";
return ss.str();
@@ -1333,7 +1336,7 @@ public:
virtual void Precalc()
{
- m_Fan2Dx = T(M_PI) * (SQR(m_Fan2X) + EPS);
+ m_Fan2Dx = T(M_PI) * Zeps(SQR(m_Fan2X));
m_Fan2Dx2 = T(0.5) * m_Fan2Dx;
}
@@ -1416,7 +1419,7 @@ public:
virtual void Precalc()
{
- m_Rings2Val2 = SQR(m_Rings2Val) + EPS;
+ m_Rings2Val2 = Zeps(SQR(m_Rings2Val));
}
virtual void Random(QTIsaac& rand)
@@ -1465,7 +1468,7 @@ public:
virtual string OpenCLString()
{
ostringstream ss;
- int i = 0, varIndex = IndexInXform();
+ int varIndex = IndexInXform();
ss << "\t{\n"
<< "\t\treal_t r = (xform->m_VariationWeights[" << varIndex << "] * 2.0) / (precalcSqrtSumSquares + 1.0);\n"
@@ -1492,24 +1495,26 @@ public:
void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand)
{
- T r = m_Weight / (T(0.25) * helper.m_PrecalcSumSquares + 1);
+ T denom = T(0.25) * helper.m_PrecalcSumSquares + 1;
+ T r = m_Weight / denom;
helper.Out.x = r * helper.In.x;
helper.Out.y = r * helper.In.y;
- helper.Out.z = m_Weight * helper.In.z;
+ helper.Out.z = m_Weight * (2 / denom - 1);
}
virtual string OpenCLString()
{
ostringstream ss;
- int i = 0, varIndex = IndexInXform();
+ int varIndex = IndexInXform();
ss << "\t{\n"
- << "\t\treal_t r = xform->m_VariationWeights[" << varIndex << "] / (0.25 * precalcSumSquares + 1);\n"
+ << "\t\treal_t denom = 0.25 * precalcSumSquares + 1;\n"
+ << "\t\treal_t r = xform->m_VariationWeights[" << varIndex << "] / denom;\n"
<< "\n"
<< "\t\tvOut.x = r * vIn.x;\n"
<< "\t\tvOut.y = r * vIn.y;\n"
- << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n"
+ << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * (2 / denom - 1);\n"
<< "\t}\n";
return ss.str();
@@ -1537,7 +1542,7 @@ public:
virtual string OpenCLString()
{
ostringstream ss;
- int i = 0, varIndex = IndexInXform();
+ int varIndex = IndexInXform();
ss << "\t{\n"
<< "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * sin(vIn.x);\n"
@@ -1565,11 +1570,7 @@ public:
void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand)
{
- T d = m_Dist - helper.In.y * m_Vsin;
-
- if (d == 0)
- d = EPS6;
-
+ T d = Zeps(m_Dist - helper.In.y * m_Vsin);
T t = 1 / d;
helper.Out.x = m_Weight * m_Dist * helper.In.x * t;
@@ -1589,11 +1590,7 @@ public:
string vfCos = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
ss << "\t{\n"
- << "\t\treal_t d = " << dist << " - vIn.y * " << vSin << ";\n"
- << "\n"
- << "\t\tif (d == 0)\n"
- << "\t\t d = EPS6;\n"
- << "\n"
+ << "\t\treal_t d = Zeps(" << dist << " - vIn.y * " << vSin << ");\n"
<< "\t\treal_t t = 1.0 / d;\n"
<< "\n"
<< "\t\tvOut.x = (xform->m_VariationWeights[" << varIndex << "] * " << dist << " * vIn.x * t);\n"
@@ -1661,7 +1658,7 @@ public:
virtual string OpenCLString()
{
ostringstream ss;
- int i = 0, varIndex = IndexInXform();
+ int varIndex = IndexInXform();
ss << "\t{\n"
<< "\t\treal_t tempr = MwcNext01(mwc) * M_2PI;\n"
@@ -1726,6 +1723,7 @@ public:
virtual void Precalc()
{
+ m_Power = Zeps(m_Power);
m_Rn = fabs(m_Power);
m_Cn = m_Dist / m_Power / 2;
}
@@ -1877,6 +1875,9 @@ private:
///
/// Blur.
+/// This is somewhat different than the original functionality in that blur used
+/// the code below, but pre_blur used gaussian_blur.
+/// If the original pre_blur functionality is needed, use pre_gaussian_blur.
///
template
class EMBER_API BlurVariation : public Variation
@@ -1889,8 +1890,7 @@ public:
void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand)
{
T tempr = rand.Frand01() * M_2PI;
- T r = m_Weight * (rand.Frand01() + rand.Frand01()
- + rand.Frand01() + rand.Frand01() - 2);
+ T r = m_Weight * rand.Frand01();
helper.Out.x = r * cos(tempr);
helper.Out.y = r * sin(tempr);
@@ -1900,7 +1900,7 @@ public:
virtual string OpenCLString()
{
ostringstream ss;
- int i = 0, varIndex = IndexInXform();
+ int varIndex = IndexInXform();
ss << "\t{\n"
<< "\t\treal_t tmpr = MwcNext01(mwc) * M_2PI;\n"
@@ -1939,7 +1939,7 @@ public:
virtual string OpenCLString()
{
ostringstream ss;
- int i = 0, varIndex = IndexInXform();
+ int varIndex = IndexInXform();
ss << "\t{\n"
<< "\t\treal_t angle = MwcNext01(mwc) * M_2PI;\n"
@@ -2122,19 +2122,22 @@ public:
void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand)
{
- T rFactor = pow(helper.m_PrecalcSumSquares, m_Power / 2);
- T theta = helper.m_PrecalcAtanyx;
- T b = M_2PI / m_Sides;
- T amp, phi = theta - (b * Floor(theta / b));
+ T rFactor;
- if (phi > b / 2)
- phi -= b;
+ if ((helper.In.x == 0) && (helper.In.y == 0))
+ rFactor = 0;
+ else
+ rFactor = pow(helper.m_PrecalcSumSquares, m_CPower);
- amp = m_Corners * (1 / (cos(phi) + EPS) - 1) + m_Circle;
- amp /= (rFactor + T(EPS));
+ T phi = helper.m_PrecalcAtanyx - m_CSides * Floor(helper.m_PrecalcAtanyx * m_CSidesInv);
+
+ if (phi > T(0.5) * m_CSides)
+ phi -= m_CSides;
- helper.Out.x = m_Weight * helper.In.x * amp;
- helper.Out.y = m_Weight * helper.In.y * amp;
+ T amp = (m_Corners * (1 / cos(phi) - 1) + m_Circle) * m_Weight * rFactor;
+
+ helper.Out.x = amp * helper.In.x;
+ helper.Out.y = amp * helper.In.y;
helper.Out.z = m_Weight * helper.In.z;
}
@@ -2144,30 +2147,44 @@ public:
int i = 0, varIndex = IndexInXform();
ss2 << "_" << XformIndexInEmber() << "]";
string index = ss2.str();
- string sides = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
- string power = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
- string circle = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
- string corners = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
+ string sides = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
+ string power = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
+ string circle = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
+ string corners = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
+ string csides = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
+ string csidesinv = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
+ string cpower = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
ss << "\t{\n"
- << "\t\treal_t rFactor = pow(precalcSumSquares, " << power << " / 2.0);\n"
- << "\t\treal_t theta = precalcAtanyx;\n"
- << "\t\treal_t b = M_2PI / " << sides << ";\n"
- << "\t\treal_t amp, phi = theta - (b * floor(theta / b));\n"
+ << "\t\treal_t rFactor;\n"
<< "\n"
- << "\t\tif (phi > b / 2)\n"
- << "\t\t phi -= b;\n"
+ << "\t\tif ((vIn.x == 0.0) && (vIn.y == 0.0))\n"
+ << "\t\t rFactor = 0.0;\n"
+ << "\t\telse\n"
+ << "\t\t rFactor = pow(precalcSumSquares, " << cpower << ");\n"
<< "\n"
- << "\t\tamp = " << corners << " * (1.0 / (cos(phi) + EPS) - 1.0) + " << circle << ";\n"
- << "\t\tamp /= (rFactor + EPS);\n"
- << "\t\tvOut.x = (xform->m_VariationWeights[" << varIndex << "] * vIn.x * amp);\n"
- << "\t\tvOut.y = (xform->m_VariationWeights[" << varIndex << "] * vIn.y * amp);\n"
+ << "\t\treal_t phi = precalcAtanyx - " << csides << " * floor(precalcAtanyx * " << csidesinv << ");\n"
+ << "\n"
+ << "\t\tif (phi > 0.5 * " << csides << ")\n"
+ << "\t\t phi -= " << csides << ";\n"
+ << "\n"
+ << "\t\treal_t amp = (" << corners << " * (1 / cos(phi) - 1) + " << circle << ") * xform->m_VariationWeights[" << varIndex << "] * rFactor;\n"
+ << "\n"
+ << "\t\tvOut.x = amp * vIn.x;\n"
+ << "\t\tvOut.y = amp * vIn.y;\n"
<< "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n"
<< "\t}\n";
return ss.str();
}
+ virtual void Precalc()
+ {
+ m_CPower = -T(0.5) * m_Power;
+ m_CSides = 2 * T(M_PI) / m_Sides;
+ m_CSidesInv = 1 / m_CSides;
+ }
+
virtual void Random(QTIsaac& rand)
{
m_Sides = (T)(int)(rand.Frand01() * 10 + 3);
@@ -2186,6 +2203,9 @@ protected:
m_Params.push_back(ParamWithName(&m_Power, prefix + "ngon_power", 3));
m_Params.push_back(ParamWithName(&m_Circle, prefix + "ngon_circle", 1));
m_Params.push_back(ParamWithName(&m_Corners, prefix + "ngon_corners", 2));
+ m_Params.push_back(ParamWithName(true, &m_CSides, prefix + "ngon_csides"));
+ m_Params.push_back(ParamWithName(true, &m_CSidesInv, prefix + "ngon_csides_inv"));
+ m_Params.push_back(ParamWithName(true, &m_CPower, prefix + "ngon_cpower"));
}
private:
@@ -2193,10 +2213,16 @@ private:
T m_Power;
T m_Circle;
T m_Corners;
+ T m_CSides;
+ T m_CSidesInv;
+ T m_CPower;
};
///
/// Curl.
+/// Note that in Apophysis, curl and post_curl differed slightly.
+/// Using what post_curl did here gave bad results, so sticking with the original
+/// curl code.
///
template
class EMBER_API CurlVariation : public ParametricVariation
@@ -2211,15 +2237,12 @@ public:
void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand)
{
- T re = 1 + m_C1w * helper.In.x + m_C2w * (SQR(helper.In.x) - SQR(helper.In.y));//Optimized from PostCurl.
- T im = m_C1w * helper.In.y + m_C22 * helper.In.x * helper.In.y;
- T r = SQR(re) + SQR(im);
+ 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 r = m_Weight / Zeps(SQR(re) + SQR(im));
- if (r == 0)
- r = EPS6;
-
- 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.x = (helper.In.x * re + helper.In.y * im) * r;
+ helper.Out.y = (helper.In.y * re - helper.In.x * im) * r;
helper.Out.z = m_Weight * helper.In.z;
}
@@ -2231,22 +2254,15 @@ public:
string index = ss2.str();
string c1 = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
string c2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
- string c1w = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
- string c2w = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
string c22 = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
ss << "\t{\n"
- << "\t\treal_t x = vIn.x;\n"
- << "\t\treal_t y = vIn.y;\n"
- << "\t\treal_t re = 1 + " << c1w << " * x + " << c2w << " * (SQR(x) - SQR(y));\n"
- << "\t\treal_t im = " << c1w << " * y + " << c22 << " * x * y;\n"
- << "\t\treal_t r = SQR(re) + SQR(im);\n"
+ << "\t\treal_t re = 1.0 + " << c1 << " * vIn.x + " << c2 << " * (SQR(vIn.x) - SQR(vIn.y));\n"
+ << "\t\treal_t im = " << c1 << " * vIn.y + " << c22 << " * vIn.x * vIn.y;\n"
+ << "\t\treal_t r = xform->m_VariationWeights[" << varIndex << "] / Zeps(SQR(re) + SQR(im));\n"
<< "\n"
- << "\t\tif (r == 0)\n"
- << "\t\t r = EPS6;\n"
- << "\n"
- << "\t\tvOut.x = (x * re + y * im) / r;\n"
- << "\t\tvOut.y = (y * re - x * im) / r;\n"
+ << "\t\tvOut.x = (vIn.x * re + vIn.y * im) * r;\n"
+ << "\t\tvOut.y = (vIn.y * re - vIn.x * im) * r;\n"
<< "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n"
<< "\t}\n";
@@ -2255,9 +2271,7 @@ public:
virtual void Precalc()
{
- m_C1w = m_C1 * m_Weight;
- m_C2w = m_C2 * m_Weight;
- m_C22 = 2 * m_C2w;
+ m_C22 = 2 * m_C2;
}
virtual void Random(QTIsaac& rand)
@@ -2274,17 +2288,13 @@ protected:
m_Params.clear();
m_Params.push_back(ParamWithName(&m_C1, prefix + "curl_c1", 1));
m_Params.push_back(ParamWithName(&m_C2, prefix + "curl_c2"));
- m_Params.push_back(ParamWithName(true, &m_C1w, prefix + "curl_c1w"));//Precalc.
- m_Params.push_back(ParamWithName(true, &m_C2w, prefix + "curl_c2w"));
- m_Params.push_back(ParamWithName(true, &m_C22, prefix + "curl_c22"));
+ m_Params.push_back(ParamWithName(true, &m_C22, prefix + "curl_c22"));//Precalc.
}
private:
T m_C1;
T m_C2;
- T m_C1w;//Precalc.
- T m_C2w;
- T m_C22;
+ T m_C22;//Precalc.
};
///
@@ -2388,7 +2398,7 @@ public:
virtual string OpenCLString()
{
ostringstream ss;
- int i = 0, varIndex = IndexInXform();
+ int varIndex = IndexInXform();
ss << "\t{\n"
<< "\t\treal_t angle = MwcNext01(mwc) * xform->m_VariationWeights[" << varIndex << "] * M_PI;\n"
@@ -2425,7 +2435,7 @@ public:
virtual string OpenCLString()
{
ostringstream ss;
- int i = 0, varIndex = IndexInXform();
+ int varIndex = IndexInXform();
ss << "\t{\n"
<< "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * sin(vIn.x) / cos(vIn.y);\n"
@@ -2458,7 +2468,7 @@ public:
virtual string OpenCLString()
{
ostringstream ss;
- int i = 0, varIndex = IndexInXform();
+ int varIndex = IndexInXform();
ss << "\t{\n"
<< "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * (MwcNext01(mwc) - 0.5);\n"
@@ -2484,7 +2494,7 @@ public:
void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand)
{
T ang = m_Weight * rand.Frand01() * T(M_PI);
- T r = m_Weight / (helper.m_PrecalcSumSquares + T(EPS));
+ T r = m_Weight / Zeps(helper.m_PrecalcSumSquares);
T tanr = m_Weight * tan(ang) * r;
helper.Out.x = tanr * cos(helper.In.x);
@@ -2495,11 +2505,11 @@ public:
virtual string OpenCLString()
{
ostringstream ss;
- int i = 0, varIndex = IndexInXform();
+ int varIndex = IndexInXform();
ss << "\t{\n"
<< "\t\treal_t ang = xform->m_VariationWeights[" << varIndex << "] * MwcNext01(mwc) * M_PI;\n"
- << "\t\treal_t r = xform->m_VariationWeights[" << varIndex << "] / (precalcSumSquares + EPS);\n"
+ << "\t\treal_t r = xform->m_VariationWeights[" << varIndex << "] / Zeps(precalcSumSquares);\n"
<< "\t\treal_t tanr = xform->m_VariationWeights[" << varIndex << "] * tan(ang) * r;\n"
<< "\n"
<< "\t\tvOut.x = tanr * cos(vIn.x);\n"
@@ -2530,12 +2540,13 @@ public:
sincos(r, &sinr, &cosr);
helper.Out.x = m_Weight * helper.In.x * (cosr + sinr);
helper.Out.y = m_Weight * helper.In.x * (cosr - sinr);
+ helper.Out.z = (m_VarType == VARTYPE_REG) ? 0 : helper.In.z;
}
virtual string OpenCLString()
{
ostringstream ss;
- int i = 0, varIndex = IndexInXform();
+ int varIndex = IndexInXform();
ss << "\t{\n"
<< "\t\treal_t r = MwcNext01(mwc) * xform->m_VariationWeights[" << varIndex << "] * precalcSqrtSumSquares;\n"
@@ -2544,6 +2555,7 @@ public:
<< "\n"
<< "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * vIn.x * (cosr + sinr);\n"
<< "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * vIn.x * (cosr - sinr);\n"
+ << "\t\tvOut.z = " << ((m_VarType == VARTYPE_REG) ? "0" : "vIn.z") << ";\n"
<< "\t}\n";
return ss.str();
@@ -2580,7 +2592,7 @@ public:
virtual string OpenCLString()
{
ostringstream ss;
- int i = 0, varIndex = IndexInXform();
+ int varIndex = IndexInXform();
ss << "\t{\n"
<< "\t\treal_t r = xform->m_VariationWeights[" << varIndex << "] * precalcSqrtSumSquares;\n"
@@ -2631,7 +2643,7 @@ public:
virtual string OpenCLString()
{
ostringstream ss;
- int i = 0, varIndex = IndexInXform();
+ int varIndex = IndexInXform();
ss << "\t{\n"
<< "\t\treal_t r = MwcNext01(mwc) * xform->m_VariationWeights[" << varIndex << "] * precalcSqrtSumSquares;\n"
@@ -2664,9 +2676,8 @@ public:
void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand)
{
- T s = helper.In.x * helper.In.x - helper.In.y * helper.In.y;
- T r = m_Weight * sqrt(1 / (s * s + EPS));
-
+ T r = m_Weight / Zeps(fabs((helper.In.x - helper.In.y) * (helper.In.x + helper.In.y)));
+
helper.Out.x = helper.In.x * r;
helper.Out.y = helper.In.y * r;
helper.Out.z = m_Weight * helper.In.z;
@@ -2675,11 +2686,10 @@ public:
virtual string OpenCLString()
{
ostringstream ss;
- int i = 0, varIndex = IndexInXform();
+ int varIndex = IndexInXform();
ss << "\t{\n"
- << "\t\treal_t s = vIn.x * vIn.x - vIn.y * vIn.y;\n"
- << "\t\treal_t r = xform->m_VariationWeights[" << varIndex << "] * sqrt(1.0 / (s * s + EPS));\n"
+ << "\t\treal_t r = xform->m_VariationWeights[" << varIndex << "] /Zeps(fabs((vIn.x - vIn.y) * (vIn.x + vIn.y)));\n"
<< "\n"
<< "\t\tvOut.x = vIn.x * r;\n"
<< "\t\tvOut.y = vIn.y * r;\n"
@@ -3201,18 +3211,18 @@ public:
void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand)
{
- T x2y2 = helper.m_PrecalcSumSquares;
- T t = x2y2 + 1;
- T x2 = 2 * helper.In.x;
+ const T x2y2 = helper.m_PrecalcSumSquares;
+ const T t = x2y2 + 1;
+ const T x2 = 2 * helper.In.x;
T y = T(0.5) * atan2(2 * helper.In.y, x2y2 - 1) + m_S;
if (y > T(M_PI_2))
- y = T(-M_PI_2) + fmod(y + T(M_PI_2), T(M_PI));
- else if (y < T(-M_PI_2))
+ y = -T(M_PI_2) + fmod(y + T(M_PI_2), T(M_PI));
+ else if (y < -T(M_PI_2))
y = T(M_PI_2) - fmod(T(M_PI_2) - y, T(M_PI));
- T f = t + x2;
- T g = t - x2;
+ const T f = t + x2;
+ const T g = t - x2;
if ((g == 0) || (f / g <= 0))
{
@@ -3296,7 +3306,7 @@ public:
virtual void Precalc()
{
- 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_V4 = m_Weight * T(0.25) * T(M_2_PI);
}
@@ -3308,7 +3318,7 @@ public:
virtual bool SetParamVal(const char* name, T val)
{
- if (!strcmp(name, "bipolar_shift"))
+ if (!_stricmp(name, "bipolar_shift"))
{
T temp = Fabsmod(T(0.5) * (val + 1));
@@ -3398,7 +3408,7 @@ public:
virtual string OpenCLString()
{
ostringstream ss;
- int i = 0, varIndex = IndexInXform();
+ int varIndex = IndexInXform();
ss << "\t{\n"
<< "\t\treal_t roundX = Rint(vIn.x);\n"
@@ -3463,7 +3473,7 @@ public:
{
T wx = m_Weight * T(1.3029400317411197908970256609023);//This precision came from the original.
T y2 = helper.In.y * 2;
- T r = wx * sqrt(fabs(helper.In.y * helper.In.x) / (T(EPS) + helper.In.x * helper.In.x + y2 * y2));
+ T r = wx * sqrt(fabs(helper.In.y * helper.In.x) / Zeps(helper.In.x * helper.In.x + y2 * y2));
helper.Out.x = r * helper.In.x;
helper.Out.y = r * y2;
@@ -3473,12 +3483,12 @@ public:
virtual string OpenCLString()
{
ostringstream ss;
- int i = 0, varIndex = IndexInXform();
+ int varIndex = IndexInXform();
ss << "\t{\n"
<< "\t\treal_t wx = xform->m_VariationWeights[" << varIndex << "] * 1.3029400317411197908970256609023;\n"
<< "\t\treal_t y2 = vIn.y * 2.0;\n"
- << "\t\treal_t r = wx * sqrt(fabs(vIn.y * vIn.x) / (EPS + vIn.x * vIn.x + y2 * y2));\n"
+ << "\t\treal_t r = wx * sqrt(fabs(vIn.y * vIn.x) / Zeps(vIn.x * vIn.x + y2 * y2));\n"
<< "\n"
<< "\t\tvOut.x = r * vIn.x;\n"
<< "\t\tvOut.y = r * y2;\n"
@@ -3841,7 +3851,7 @@ public:
virtual string OpenCLString()
{
ostringstream ss;
- int i = 0, varIndex = IndexInXform();
+ int varIndex = IndexInXform();
ss << "\t{\n"
<< "\t\treal_t tmp = precalcSumSquares + 1.0;\n"
@@ -3873,12 +3883,15 @@ public:
/// Elliptic.
///
template
-class EMBER_API EllipticVariation : public Variation
+class EMBER_API EllipticVariation : public ParametricVariation
{
public:
- EllipticVariation(T weight = 1.0) : Variation("elliptic", VAR_ELLIPTIC, weight, true) { }
+ EllipticVariation(T weight = 1.0) : ParametricVariation("elliptic", VAR_ELLIPTIC, weight, true)
+ {
+ Init();
+ }
- VARCOPY(EllipticVariation)
+ PARVARCOPY(EllipticVariation)
void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand)
{
@@ -3888,7 +3901,7 @@ public:
T a = helper.In.x / xmax;
T b = 1 - a * a;
T ssx = xmax - 1;
- T w = m_Weight / T(M_PI_2);
+ const T w = m_WeightDivPiDiv2;
if (b < 0)
b = 0;
@@ -3912,8 +3925,11 @@ public:
virtual string OpenCLString()
{
- ostringstream ss;
+ ostringstream ss, ss2;
int i = 0, varIndex = IndexInXform();
+ ss2 << "_" << XformIndexInEmber() << "]";
+ string index = ss2.str();
+ string weightDivPiDiv2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
ss << "\t{\n"
<< "\t\treal_t tmp = precalcSumSquares + 1.0;\n"
@@ -3922,7 +3938,7 @@ public:
<< "\t\treal_t a = vIn.x / xmax;\n"
<< "\t\treal_t b = 1.0 - a * a;\n"
<< "\t\treal_t ssx = xmax - 1.0;\n"
- << "\t\treal_t w = xform->m_VariationWeights[" << varIndex << "] / M_PI_2;\n"
+ << "\t\tconst real_t w = " << weightDivPiDiv2 << ";\n"
<< "\n"
<< "\t\tif (b < 0)\n"
<< "\t\t b = 0;\n"
@@ -3946,6 +3962,23 @@ public:
return ss.str();
}
+
+ virtual void Precalc()
+ {
+ m_WeightDivPiDiv2 = m_Weight / T(M_PI_2);
+ }
+
+protected:
+ void Init()
+ {
+ string prefix = Prefix();
+
+ m_Params.clear();
+ m_Params.push_back(ParamWithName(true, &m_WeightDivPiDiv2, prefix + "elliptic_weight_div_pi_div_2"));//Precalc.
+ }
+
+private:
+ T m_WeightDivPiDiv2;//Precalc.
};
///
@@ -4012,7 +4045,7 @@ public:
virtual bool SetParamVal(const char* name, T val)
{
- if (!strcmp(name, "escher_beta"))
+ if (!_stricmp(name, "escher_beta"))
{
m_Beta = Fabsmod((val + T(M_PI)) / (2 * T(M_PI))) * 2 * T(M_PI) - T(M_PI);
Precalc();
@@ -4058,36 +4091,30 @@ public:
sincos(helper.In.y, &sn, &cn);
- tmp = expx + expnx - cn;
-
- if (tmp == 0)
- tmp = EPS6;
-
- tmp = m_Weight / tmp;
+ tmp = m_Weight / Zeps(expx + expnx - cn);
helper.Out.x = tmp * (expx - expnx);
helper.Out.y = tmp * sn;
+ helper.Out.z = m_Weight * helper.In.z;
}
virtual string OpenCLString()
{
ostringstream ss;
- int i = 0, varIndex = IndexInXform();
+ int varIndex = IndexInXform();
ss << "\t{\n"
<< "\t\treal_t expx = exp(vIn.x) * 0.5;\n"
<< "\t\treal_t expnx = 0.25 / expx;\n"
<< "\t\treal_t sn = sin(vIn.y);\n"
<< "\t\treal_t cn = cos(vIn.y);\n"
- << "\t\treal_t tmp = expx + expnx - cn;\n"
- << "\n"
- << "\t\tif (tmp == 0)\n"
- << "\t\t tmp = EPS6;\n"
+ << "\t\treal_t tmp = Zeps(expx + expnx - cn);\n"
<< "\n"
<< "\t\ttmp = xform->m_VariationWeights[" << varIndex << "] / tmp;\n"
<< "\n"
<< "\t\tvOut.x = tmp * (expx - expnx);\n"
<< "\t\tvOut.y = tmp * sn;\n"
+ << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n"
<< "\t}\n";
return ss.str();
@@ -4123,7 +4150,7 @@ public:
}
else
{
- r = 1 + m_Space / (r + EPS6);
+ r = 1 + m_Space / Zeps(r);
helper.Out.x = m_Weight * (r * x + m_X);//Fix to make it colapse to 0 when weight is 0.//SMOULDER
helper.Out.y = m_Weight * (r * y - m_Y);
@@ -4158,7 +4185,7 @@ public:
<< "\t\t}\n"
<< "\t\telse\n"
<< "\t\t{\n"
- << "\t\t r = 1.0 + " << space << " / (r + EPS6);\n"
+ << "\t\t r = 1.0 + " << space << " / Zeps(r);\n"
<< "\n"
<< "\t\t vOut.x = xform->m_VariationWeights[" << varIndex << "] * (r * x + " << x << ");\n"
<< "\t\t vOut.y = xform->m_VariationWeights[" << varIndex << "] * (r * y - " << y << ");\n"
@@ -4172,7 +4199,7 @@ public:
virtual bool SetParamVal(const char* name, T val)
{
- if (!strcmp(name, "lazysusan_spin"))
+ if (!_stricmp(name, "lazysusan_spin"))
{
m_Spin = Fabsmod(val / T(M_2PI)) * T(M_2PI);
Precalc();
@@ -4228,9 +4255,9 @@ public:
void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand)
{
- if (helper.m_PrecalcSumSquares < m_W2)
+ if (helper.m_PrecalcSumSquares < m_W2 && helper.m_PrecalcSumSquares != 0)
{
- T r = m_Weight * sqrt(m_W2 / helper.m_PrecalcSumSquares - 1);
+ T r = m_Weight * sqrt((m_W2 / helper.m_PrecalcSumSquares) - 1);
helper.Out.x = r * helper.In.x;
helper.Out.y = r * helper.In.y;
@@ -4253,9 +4280,9 @@ public:
string w2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
ss << "\t{\n"
- << "\t\tif (precalcSumSquares < " << w2 << ")\n"
+ << "\t\tif (precalcSumSquares < " << w2 << " && precalcSumSquares != 0)\n"
<< "\t\t{\n"
- << "\t\t real_t r = xform->m_VariationWeights[" << varIndex << "] * sqrt(" << w2 << " / precalcSumSquares - 1.0);\n"
+ << "\t\t real_t r = xform->m_VariationWeights[" << varIndex << "] * sqrt((" << w2 << " / precalcSumSquares) - 1.0);\n"
<< "\t\t vOut.x = r * vIn.x;\n"
<< "\t\t vOut.y = r * vIn.y;\n"
<< "\t\t}\n"
@@ -4637,10 +4664,11 @@ public:
void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand)
{
T t = helper.m_PrecalcSumSquares;
- T r = 1 / (helper.m_PrecalcSqrtSumSquares * (t + m_InvWeight));
+ T r = 1 / Zeps(helper.m_PrecalcSqrtSumSquares * (t + m_InvWeight));
helper.Out.x = helper.In.x * r;
helper.Out.y = helper.In.y * r;
+ helper.Out.z = (m_VarType == VARTYPE_REG) ? 0 : helper.In.z;
}
virtual string OpenCLString()
@@ -4653,10 +4681,11 @@ public:
ss << "\t{\n"
<< "\t\treal_t t = precalcSumSquares;\n"
- << "\t\treal_t r = 1.0 / (precalcSqrtSumSquares * (t + " << invWeight << "));\n"
+ << "\t\treal_t r = 1.0 / Zeps(precalcSqrtSumSquares * (t + " << invWeight << "));\n"
<< "\n"
<< "\t\tvOut.x = vIn.x * r;\n"
<< "\t\tvOut.y = vIn.y * r;\n"
+ << "\t\tvOut.z = " << ((m_VarType == VARTYPE_REG) ? "0" : "vIn.z") << ";\n"
<< "\t}\n";
return ss.str();
@@ -4664,7 +4693,7 @@ public:
virtual void Precalc()
{
- m_InvWeight = 1 / (m_Weight + EPS6);
+ m_InvWeight = 1 / Zeps(m_Weight);
}
protected:
@@ -4956,7 +4985,7 @@ public:
void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand)
{
- T roundx = (T)Floor(helper.In.x + T(0.5));
+ T roundx = (T)(int)(helper.In.x >= 0 ? (helper.In.x + T(0.5)) : (helper.In.x - T(0.5)));
T offsetx = helper.In.x - roundx;
helper.Out.x = m_Weight * (offsetx * (1 - m_Space) + roundx);
@@ -4974,7 +5003,7 @@ public:
string warp = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
ss << "\t{\n"
- << "\t\treal_t roundx = floor(vIn.x + 0.5);\n"
+ << "\t\treal_t roundx = (real_t)(int)(vIn.x >= 0 ? (vIn.x + 0.5) : (vIn.x - 0.5));\n"
<< "\t\treal_t offsetx = vIn.x - roundx;\n"
<< "\n"
<< "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * (offsetx * (1.0 - " << space << ") + roundx);\n"
@@ -5206,7 +5235,7 @@ public:
void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand)
{
- T r = 1 / (helper.m_PrecalcSqrtSumSquares + T(EPS));
+ T r = 1 / Zeps(helper.m_PrecalcSqrtSumSquares);
T a = helper.m_PrecalcAtanyx + m_Swirl * r;
T c = (T)Floor((m_Count * a + T(M_PI)) * T(M_1_PI) * T(0.5));
T compFac = 1 - m_Angle * m_Count * T(M_1_PI) * T(0.5);
@@ -5230,7 +5259,7 @@ public:
string swirl = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
ss << "\t{\n"
- << "\t\treal_t r = 1.0 / (precalcSqrtSumSquares + EPS);\n"
+ << "\t\treal_t r = 1.0 / Zeps(precalcSqrtSumSquares);\n"
<< "\t\treal_t a = precalcAtanyx + " << swirl << " * r;\n"
<< "\t\treal_t c = floor((" << count << " * a + M_PI) * M_1_PI * 0.5);\n"
<< "\t\treal_t compFac = 1 - " << angle << " * " << count << " * M_1_PI * 0.5;\n"
@@ -5446,7 +5475,7 @@ public:
virtual string OpenCLString()
{
ostringstream ss;
- int i = 0, varIndex = IndexInXform();
+ int varIndex = IndexInXform();
ss << "\t{\n"
<< "\t\treal_t expe = xform->m_VariationWeights[" << varIndex << "] * exp(vIn.x);\n"
@@ -5510,7 +5539,7 @@ protected:
string prefix = Prefix();
m_Params.clear();
- m_Params.push_back(ParamWithName(&m_Base, prefix + "log_base", T(M_E), REAL, EPS6, TMAX));
+ m_Params.push_back(ParamWithName(&m_Base, prefix + "log_base", T(M_E), REAL, EPS, TMAX));
m_Params.push_back(ParamWithName(true, &m_Denom, prefix + "log_denom"));//Precalc.
}
@@ -5540,7 +5569,7 @@ public:
virtual string OpenCLString()
{
ostringstream ss;
- int i = 0, varIndex = IndexInXform();
+ int varIndex = IndexInXform();
ss << "\t{\n"
<< "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * sin(vIn.x) * cosh(vIn.y);\n"
@@ -5574,7 +5603,7 @@ public:
virtual string OpenCLString()
{
ostringstream ss;
- int i = 0, varIndex = IndexInXform();
+ int varIndex = IndexInXform();
ss << "\t{\n"
<< "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * cos(vIn.x) * cosh(vIn.y);\n"
@@ -5613,7 +5642,7 @@ public:
virtual string OpenCLString()
{
ostringstream ss;
- int i = 0, varIndex = IndexInXform();
+ int varIndex = IndexInXform();
ss << "\t{\n"
<< "\t\treal_t tansin = sin(2.0 * vIn.x);\n"
@@ -5658,7 +5687,7 @@ public:
virtual string OpenCLString()
{
ostringstream ss;
- int i = 0, varIndex = IndexInXform();
+ int varIndex = IndexInXform();
ss << "\t{\n"
<< "\t\treal_t secsin = sin(vIn.x);\n"
@@ -5703,7 +5732,7 @@ public:
virtual string OpenCLString()
{
ostringstream ss;
- int i = 0, varIndex = IndexInXform();
+ int varIndex = IndexInXform();
ss << "\t{\n"
<< "\t\treal_t cscsin = sin(vIn.x);\n"
@@ -5748,7 +5777,7 @@ public:
virtual string OpenCLString()
{
ostringstream ss;
- int i = 0, varIndex = IndexInXform();
+ int varIndex = IndexInXform();
ss << "\t{\n"
<< "\t\treal_t cotsin = sin(2.0 * vIn.x);\n"
@@ -5792,7 +5821,7 @@ public:
virtual string OpenCLString()
{
ostringstream ss;
- int i = 0, varIndex = IndexInXform();
+ int varIndex = IndexInXform();
ss << "\t{\n"
<< "\t\treal_t sinhsin = sin(vIn.y);\n"
@@ -5835,7 +5864,7 @@ public:
virtual string OpenCLString()
{
ostringstream ss;
- int i = 0, varIndex = IndexInXform();
+ int varIndex = IndexInXform();
ss << "\t{\n"
<< "\t\treal_t coshsin = sin(vIn.y);\n"
@@ -5879,7 +5908,7 @@ public:
virtual string OpenCLString()
{
ostringstream ss;
- int i = 0, varIndex = IndexInXform();
+ int varIndex = IndexInXform();
ss << "\t{\n"
<< "\t\treal_t tanhsin = sin(2.0 * vIn.y);\n"
@@ -5924,7 +5953,7 @@ public:
virtual string OpenCLString()
{
ostringstream ss;
- int i = 0, varIndex = IndexInXform();
+ int varIndex = IndexInXform();
ss << "\t{\n"
<< "\t\treal_t sechsin = sin(vIn.y);\n"
@@ -5969,7 +5998,7 @@ public:
virtual string OpenCLString()
{
ostringstream ss;
- int i = 0, varIndex = IndexInXform();
+ int varIndex = IndexInXform();
ss << "\t{\n"
<< "\t\treal_t cschsin = sin(vIn.y);\n"
@@ -6014,7 +6043,7 @@ public:
virtual string OpenCLString()
{
ostringstream ss;
- int i = 0, varIndex = IndexInXform();
+ int varIndex = IndexInXform();
ss << "\t{\n"
<< "\t\treal_t cothsin = sin(2.0 * vIn.y);\n"
@@ -6139,7 +6168,8 @@ public:
helper.Out.x = avgr * cos(avga);
helper.Out.y = avgr * sin(avga);
- helper.Out.z = m_Weight * helper.In.z;
+ helper.Out.z = helper.In.z;
+ //helper.Out.z = m_Weight * helper.In.z;
}
virtual string OpenCLString()
@@ -6258,7 +6288,7 @@ MAKEPREPOSTPARVAR(Cell, cell, CELL)
MAKEPREPOSTPARVAR(Cpow, cpow, CPOW)
MAKEPREPOSTPARVAR(Curve, curve, CURVE)
MAKEPREPOSTVAR(Edisc, edisc, EDISC)
-MAKEPREPOSTVAR(Elliptic, elliptic, ELLIPTIC)
+MAKEPREPOSTPARVAR(Elliptic, elliptic, ELLIPTIC)
MAKEPREPOSTPARVAR(Escher, escher, ESCHER)
MAKEPREPOSTVAR(Foci, foci, FOCI)
MAKEPREPOSTPARVAR(LazySusan, lazysusan, LAZYSUSAN)
diff --git a/Source/Ember/Variations02.h b/Source/Ember/Variations02.h
index 29dcabc..619df4a 100644
--- a/Source/Ember/Variations02.h
+++ b/Source/Ember/Variations02.h
@@ -27,7 +27,7 @@ public:
virtual string OpenCLString()
{
ostringstream ss;
- int i = 0, varIndex = IndexInXform();
+ int varIndex = IndexInXform();
ss << "\t{\n"
<< "\t\treal_t t = xform->m_VariationWeights[" << varIndex << "] / sqrt(precalcSumSquares + 1.0);\n"
@@ -64,7 +64,13 @@ public:
{
helper.Out.x = m_Weight * t * cos(theta);
helper.Out.y = m_Weight * t * sin(theta);
- helper.Out.z = m_Weight * helper.In.z;
+ helper.Out.z = 0;
+ }
+ else
+ {
+ helper.Out.x = 0;
+ helper.Out.y = 0;
+ helper.Out.z = 0;
}
}
@@ -86,7 +92,13 @@ public:
<< "\t\t{\n"
<< "\t\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * t * cos(theta);\n"
<< "\t\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * t * sin(theta);\n"
- << "\t\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n"
+ << "\t\t\tvOut.z = 0;\n"
+ << "\t\t}\n"
+ << "\t\telse\n"
+ << "\t\t{\n"
+ << "\t\t\tvOut.x = 0;\n"
+ << "\t\t\tvOut.y = 0;\n"
+ << "\t\t\tvOut.z = 0;\n"
<< "\t\t}\n"
<< "\t}\n";
@@ -239,7 +251,7 @@ public:
virtual void Precalc()
{
T radius = T(0.5) * (m_BwrapsCellsize / (1 + SQR(m_BwrapsSpace)));
- m_G2 = SQR(m_BwrapsGain) / (radius + EPS6) + EPS6;
+ m_G2 = Zeps(SQR(m_BwrapsGain) / Zeps(radius));
T maxBubble = m_G2 * radius;
if (maxBubble > 2)
@@ -505,7 +517,7 @@ protected:
string prefix = Prefix();
m_Params.clear();
- m_Params.push_back(ParamWithName(&m_BlurPixelizeSize, prefix + "blur_pixelize_size", T(0.1), REAL, EPS6));
+ m_Params.push_back(ParamWithName(&m_BlurPixelizeSize, prefix + "blur_pixelize_size", T(0.1), REAL, EPS));
m_Params.push_back(ParamWithName(&m_BlurPixelizeScale, prefix + "blur_pixelize_scale", 1));
m_Params.push_back(ParamWithName(true, &m_V, prefix + "blur_pixelize_v"));//Precalc.
m_Params.push_back(ParamWithName(true, &m_InvSize, prefix + "blur_pixelize_inv_size"));
@@ -920,7 +932,7 @@ public:
void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand)
{
- if (m_VarType == VARTYPE_REG)
+ if (m_VarType == VARTYPE_REG)//Rare and different usage of in/out.
{
helper.Out.x = helper.Out.y = helper.Out.z = 0;
outPoint.m_Z = 0;
@@ -937,10 +949,12 @@ public:
{
ostringstream ss;
- if (m_VarType == VARTYPE_REG)//Rare and different usage of in/out.
+ if (m_VarType == VARTYPE_REG)
{
ss << "\t{\n"
- << "\t\tvOut.x = vOut.y = vOut.z = 0;\n"
+ << "\t\tvOut.x = 0;\n"
+ << "\t\tvOut.y = 0;\n"
+ << "\t\tvOut.z = 0;\n"
<< "\t\toutPoint->m_Z = 0;\n"
<< "\t}\n";
}
@@ -978,12 +992,12 @@ public:
virtual string OpenCLString()
{
ostringstream ss;
- int i = 0, varIndex = IndexInXform();
+ int varIndex = IndexInXform();
ss << "\t{\n"
- << "\t\tvOut.x = vOut.y = 0;\n"
- << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * (MwcNext01(mwc) + MwcNext01(mwc) + MwcNext01(mwc) + MwcNext01(mwc) - 2.0);\n"
- << "\t}\n";
+ << "\t\tvOut.x = vOut.y = 0;\n"
+ << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * (MwcNext01(mwc) + MwcNext01(mwc) + MwcNext01(mwc) + MwcNext01(mwc) - 2.0);\n"
+ << "\t}\n";
return ss.str();
}
@@ -991,6 +1005,7 @@ public:
///
/// ZScale.
+/// This uses in/out in a rare and different way.
///
template
class EMBER_API ZScaleVariation : public Variation
@@ -1009,12 +1024,12 @@ public:
virtual string OpenCLString()
{
ostringstream ss;
- int i = 0, varIndex = IndexInXform();
+ int varIndex = IndexInXform();
ss << "\t{\n"
- << "\t\tvOut.x = vOut.y = 0;\n"
- << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n"
- << "\t}\n";
+ << "\t\tvOut.x = vOut.y = 0;\n"
+ << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n"
+ << "\t}\n";
return ss.str();
}
@@ -1022,6 +1037,7 @@ public:
///
/// ZTranslate.
+/// This uses in/out in a rare and different way.
///
template
class EMBER_API ZTranslateVariation : public Variation
@@ -1040,12 +1056,12 @@ public:
virtual string OpenCLString()
{
ostringstream ss;
- int i = 0, varIndex = IndexInXform();
+ int varIndex = IndexInXform();
ss << "\t{\n"
- << "\t\tvOut.x = vOut.y = 0;\n"
- << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "];\n"
- << "\t}\n";
+ << "\t\tvOut.x = vOut.y = 0;\n"
+ << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "];\n"
+ << "\t}\n";
return ss.str();
}
@@ -1053,6 +1069,7 @@ public:
///
/// zcone.
+/// This uses in/out in a rare and different way.
///
template
class EMBER_API ZConeVariation : public Variation
@@ -1064,7 +1081,7 @@ public:
void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand)
{
- if (m_VarType == VARTYPE_REG)
+ if (m_VarType == VARTYPE_REG)//Rare and different usage of in/out.
{
helper.Out.x = helper.Out.y = 0;
}
@@ -1080,24 +1097,23 @@ public:
virtual string OpenCLString()
{
ostringstream ss;
- int i = 0, varIndex = IndexInXform();
+ int varIndex = IndexInXform();
+
+ ss << "\t{\n";
if (m_VarType == VARTYPE_REG)
{
- ss << "\t{\n"
- << "\t\tvOut.x = vOut.y = 0;\n"
- << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * precalcSqrtSumSquares;\n"
- << "\t}\n";
+ ss << "\t\tvOut.x = vOut.y = 0;\n";
}
else
{
- ss << "\t{\n"
- << "\t\tvOut.x = vIn.x;\n"
- << "\t\tvOut.y = vIn.y;\n"
- << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * precalcSqrtSumSquares;\n"
- << "\t}\n";
+ ss << "\t\tvOut.x = vIn.x;\n"
+ << "\t\tvOut.y = vIn.y;\n";
}
+ ss << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * precalcSqrtSumSquares;\n"
+ << "\t}\n";
+
return ss.str();
}
};
@@ -1109,7 +1125,7 @@ template
class EMBER_API Blur3DVariation : public Variation
{
public:
- Blur3DVariation(T weight = 1.0) : Variation("blur_3d", VAR_BLUR3D, weight) { }
+ Blur3DVariation(T weight = 1.0) : Variation("blur3D", VAR_BLUR3D, weight) { }
VARCOPY(Blur3DVariation)
@@ -1131,7 +1147,7 @@ public:
virtual string OpenCLString()
{
ostringstream ss;
- int i = 0, varIndex = IndexInXform();
+ int varIndex = IndexInXform();
ss << "\t{\n"
<< "\t\treal_t angle = MwcNext01(mwc) * M_2PI;\n"
@@ -1164,7 +1180,7 @@ public:
void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand)
{
- T r2 = m_Weight / (helper.m_PrecalcSumSquares + helper.In.z + EPS6);
+ T r2 = m_Weight / Zeps(helper.m_PrecalcSumSquares + SQR(helper.In.z));
helper.Out.x = r2 * helper.In.x;
helper.Out.y = r2 * helper.In.y;
@@ -1174,10 +1190,10 @@ public:
virtual string OpenCLString()
{
ostringstream ss;
- int i = 0, varIndex = IndexInXform();
+ int varIndex = IndexInXform();
ss << "\t{\n"
- << "\t\treal_t r2 = xform->m_VariationWeights[" << varIndex << "] / (precalcSumSquares + vIn.z + EPS6);\n"
+ << "\t\treal_t r2 = xform->m_VariationWeights[" << varIndex << "] / Zeps(precalcSumSquares + SQR(vIn.z));\n"
<< "\n"
<< "\t\tvOut.x = r2 * vIn.x;\n"
<< "\t\tvOut.y = r2 * vIn.y;\n"
@@ -1205,7 +1221,7 @@ public:
void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand)
{
T r2 = helper.m_PrecalcSumSquares + SQR(helper.In.z);
- T r = m_Weight / ((r2 * m_C2) + (m_C2x * helper.In.x) - (m_C2y * helper.In.y) + (m_C2z * helper.In.z) + 1);
+ T r = m_Weight / Zeps(r2 * m_C2 + m_C2x * helper.In.x - m_C2y * helper.In.y + m_C2z * helper.In.z + 1);
helper.Out.x = r * (helper.In.x + m_Cx * r2);
helper.Out.y = r * (helper.In.y - m_Cy * r2);
@@ -1228,7 +1244,7 @@ public:
ss << "\t{\n"
<< "\t\treal_t r2 = precalcSumSquares + SQR(vIn.z);\n"
- << "\t\treal_t r = xform->m_VariationWeights[" << varIndex << "] / ((r2 * " << c2 << ") + (" << c2x << " * vIn.x) - (" << c2y << " * vIn.y) + (" << c2z << " * vIn.z) + 1.0);\n"
+ << "\t\treal_t r = xform->m_VariationWeights[" << varIndex << "] / Zeps(r2 * " << c2 << " + " << c2x << " * vIn.x - " << c2y << " * vIn.y + " << c2z << " * vIn.z + 1.0);\n"
<< "\n"
<< "\t\tvOut.x = r * (vIn.x + " << cx << " * r2);\n"
<< "\t\tvOut.y = r * (vIn.y - " << cy << " * r2);\n"
@@ -1243,7 +1259,7 @@ public:
m_C2x = 2 * m_Cx;
m_C2y = 2 * m_Cy;
m_C2z = 2 * m_Cz;
- m_C2 = SQR(m_C2x) + SQR(m_C2y) + SQR(m_C2z);
+ m_C2 = SQR(m_Cx) + SQR(m_Cy) + SQR(m_Cz);
}
protected:
@@ -1291,7 +1307,7 @@ public:
T temp = r * m_Pi;
T sr = sin(temp);
T cr = cos(temp);
- T vv = m_Weight * helper.m_PrecalcAtanxy / (m_Pi + EPS6);
+ T vv = m_Weight * helper.m_PrecalcAtanxy / Zeps(m_Pi);
helper.Out.x = vv * sr;
helper.Out.y = vv * cr;
@@ -1311,7 +1327,7 @@ public:
<< "\t\treal_t temp = r * " << pi << ";\n"
<< "\t\treal_t sr = sin(temp);\n"
<< "\t\treal_t cr = cos(temp);\n"
- << "\t\treal_t vv = xform->m_VariationWeights[" << varIndex << "] * precalcAtanxy / (" << pi << " + EPS6);\n"
+ << "\t\treal_t vv = xform->m_VariationWeights[" << varIndex << "] * precalcAtanxy / Zeps(" << pi << ");\n"
<< "\n"
<< "\t\tvOut.x = vv * sr;\n"
<< "\t\tvOut.y = vv * cr;\n"
@@ -1350,8 +1366,8 @@ public:
void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand)
{
- T roundX = Rint(helper.In.x);
- T roundY = Rint(helper.In.y);
+ T roundX = (T)(int)(helper.In.x >= 0 ? (int)(helper.In.x + T(0.5)) : (int)(helper.In.x - T(0.5)));
+ T roundY = (T)(int)(helper.In.y >= 0 ? (int)(helper.In.y + T(0.5)) : (int)(helper.In.y - T(0.5)));
T offsetX = helper.In.x - roundX;
T offsetY = helper.In.y - roundY;
@@ -1407,8 +1423,8 @@ public:
string cr = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
ss << "\t{\n"
- << "\t\treal_t roundX = Rint(vIn.x);\n"
- << "\t\treal_t roundY = Rint(vIn.y);\n"
+ << "\t\treal_t roundX = (real_t)(int)(vIn.x >= 0 ? (int)(vIn.x + 0.5) : (int)(vIn.x - 0.5));\n"
+ << "\t\treal_t roundY = (real_t)(int)(vIn.y >= 0 ? (int)(vIn.y + 0.5) : (int)(vIn.y - 0.5));\n"
<< "\t\treal_t offsetX = vIn.x - roundX;\n"
<< "\t\treal_t offsetY = vIn.y - roundY;\n"
<< "\n"
@@ -1455,13 +1471,9 @@ public:
virtual void Precalc()
{
- T c = fabs(m_C);
- T cl = fabs(m_Left);
- T cr = fabs(m_Right);
-
- c = c == 0 ? EPS : c;
- cl = cl == 0 ? EPS : cl;
- cr = cr == 0 ? EPS : cr;
+ T c = Zeps(fabs(m_C));
+ T cl = Zeps(fabs(m_Left));
+ T cr = Zeps(fabs(m_Right));
m_AbsC = c;
m_Cl = c * cl;
@@ -1628,7 +1640,7 @@ public:
virtual void Precalc()
{
- m_Cs = 1 / (m_Size + EPS);
+ m_Cs = 1 / Zeps(m_Size);
m_Cx = m_X;
m_Cy = m_Y;
m_Ncx = -m_X;
@@ -1907,6 +1919,7 @@ public:
helper.Out.x = -1 + m_Vv2 * Lerp(Lerp(x, Fosc(x, T(4), m_Px), oscnapx), Fosc(bx, T(4), m_Px), oscnapx);//Original did a direct assignment to outPoint, which is incompatible with Ember's design.
helper.Out.y = -1 + m_Vv2 * Lerp(Lerp(y, Fosc(y, T(4), m_Py), oscnapy), Fosc(by, T(4), m_Py), oscnapy);
+ helper.Out.z = (m_VarType == VARTYPE_REG) ? 0 : helper.In.z;
}
virtual string OpenCLString()
@@ -1937,6 +1950,7 @@ public:
<< "\n"
<< "\t\tvOut.x = -1 + " << vv2 << " * Lerp(Lerp(x, Fosc(x, 4, " << px << "), oscnapx), Fosc(bx, 4, " << px << "), oscnapx);\n"
<< "\t\tvOut.y = -1 + " << vv2 << " * Lerp(Lerp(y, Fosc(y, 4, " << py << "), oscnapy), Fosc(by, 4, " << py << "), oscnapy);\n"
+ << "\t\tvOut.z = " << ((m_VarType == VARTYPE_REG) ? "0" : "vIn.z") << ";\n"
<< "\t}\n";
return ss.str();
@@ -2014,7 +2028,7 @@ public:
virtual string OpenCLString()
{
ostringstream ss;
- int i = 0, varIndex = IndexInXform();
+ int varIndex = IndexInXform();
ss << "\t{\n"
<< "\t\treal_t avgr = xform->m_VariationWeights[" << varIndex << "] * (sqrt(SQR(vIn.y) + SQR(vIn.x + 1)) / sqrt(SQR(vIn.y) + SQR(vIn.x - 1)));\n"
@@ -2084,7 +2098,7 @@ public:
virtual void Precalc()
{
- m_K = T(0.5) * log(SQR(m_Real) + SQR(m_Imag) + EPS);//Original used 1e-300, which isn't representable with a float.
+ m_K = T(0.5) * log(Zeps(SQR(m_Real) + SQR(m_Imag)));//Original used 1e-300, which isn't representable with a float.
m_T = atan2(m_Imag, m_Real);
}
@@ -2218,7 +2232,7 @@ public:
virtual string OpenCLString()
{
ostringstream ss;
- int i = 0, varIndex = IndexInXform();
+ int varIndex = IndexInXform();
ss << "\t{\n"
<< "\t\treal_t a = M_2PI / (precalcSqrtSumSquares + 1);\n"
@@ -2602,7 +2616,7 @@ public:
virtual string OpenCLString()
{
ostringstream ss;
- int i = 0, varIndex = IndexInXform();
+ int varIndex = IndexInXform();
ss << "\t{\n"
<< "\t\treal_t x = LRint(vIn.x);\n"
@@ -2766,6 +2780,7 @@ public:
helper.Out.x = vr * (a * c + b * d);
helper.Out.y = vr * (b * c - a * d);
+ helper.Out.z = (m_VarType == VARTYPE_REG) ? 0 : helper.In.z;
}
virtual string OpenCLString()
@@ -2789,6 +2804,7 @@ public:
<< "\n"
<< "\t\tvOut.x = vr * (a * c + b * d);\n"
<< "\t\tvOut.y = vr * (b * c - a * d);\n"
+ << "\t\tvOut.z = " << ((m_VarType == VARTYPE_REG) ? "0" : "vIn.z") << ";\n"
<< "\t}\n";
return ss.str();
@@ -2860,6 +2876,7 @@ public:
helper.Out.x = vr * (a * c + b * d);
helper.Out.y = vr * (b * c - a * d);
+ helper.Out.z = (m_VarType == VARTYPE_REG) ? 0 : helper.In.z;
}
virtual string OpenCLString()
@@ -2887,6 +2904,7 @@ public:
<< "\n"
<< "\t\tvOut.x = vr * (a * c + b * d);\n"
<< "\t\tvOut.y = vr * (b * c - a * d);\n"
+ << "\t\tvOut.z = " << ((m_VarType == VARTYPE_REG) ? "0" : "vIn.z") << ";\n"
<< "\t}\n";
return ss.str();
@@ -2953,6 +2971,7 @@ public:
helper.Out.x = vr * (x * cosa + y * sina);
helper.Out.y = vr * (y * cosa - x * sina);
+ helper.Out.z = (m_VarType == VARTYPE_REG) ? 0 : helper.In.z;
}
virtual string OpenCLString()
@@ -2980,6 +2999,7 @@ public:
<< "\n"
<< "\t\tvOut.x = vr * (x * cosa + y * sina);\n"
<< "\t\tvOut.y = vr * (y * cosa - x * sina);\n"
+ << "\t\tvOut.z = " << ((m_VarType == VARTYPE_REG) ? "0" : "vIn.z") << ";\n"
<< "\t}\n";
return ss.str();
@@ -3542,6 +3562,7 @@ public:
helper.Out.x = r * cosa;
helper.Out.y = r * sina;
+ helper.Out.z = (m_VarType == VARTYPE_REG) ? 0 : helper.In.z;
}
virtual string OpenCLString()
@@ -3564,6 +3585,7 @@ public:
<< "\n"
<< "\t\tvOut.x = r * cosa;\n"
<< "\t\tvOut.y = r * sina;\n"
+ << "\t\tvOut.z = " << ((m_VarType == VARTYPE_REG) ? "0" : "vIn.z") << ";\n"
<< "\t}\n";
return ss.str();
@@ -4224,11 +4246,7 @@ public:
T x2cx = m_C2x * helper.In.x;
T y2cy = m_C2y * helper.In.y;
T z2cz = m_C2z * helper.In.z;
- T val = m_C2 * r2 - x2cx - y2cy - z2cz + 1;
-
- if (val == 0)
- val += EPS6;
-
+ T val = Zeps(m_C2 * r2 - x2cx - y2cy - z2cz + 1);
T d = m_Weight / val;
helper.Out.x = d * (helper.In.x * m_S2x + m_Cx * (y2cy + z2cz - r2 - 1));
@@ -4261,11 +4279,7 @@ public:
<< "\t\treal_t x2cx = " << c2x << " * vIn.x;\n"
<< "\t\treal_t y2cy = " << c2y << " * vIn.y;\n"
<< "\t\treal_t z2cz = " << c2z << " * vIn.z;\n"
- << "\t\treal_t val = " << c2 << " * r2 - x2cx - y2cy - z2cz + 1.0;\n"
- << "\n"
- << "\t\tif (val == 0.0)\n"
- << "\t\t val += EPS6;\n"
- << "\n"
+ << "\t\treal_t val = Zeps(" << c2 << " * r2 - x2cx - y2cy - z2cz + 1.0);\n"
<< "\t\treal_t d = xform->m_VariationWeights[" << varIndex << "] / val;\n"
<< "\n"
<< "\t\tvOut.x = d * (vIn.x * " << s2x << " + " << cx << " * (y2cy + z2cz - r2 - 1.0));\n"
@@ -4622,6 +4636,7 @@ public:
//invert the multiplication with scale from before.
helper.Out.x = m_Weight * Lerp(u1, u2, m_P) * m_Is;//Original did a direct assignment to outPoint, which is incompatible with Ember's design.
helper.Out.y = m_Weight * Lerp(v1, v2, m_P) * m_Is;
+ helper.Out.z = (m_VarType == VARTYPE_REG) ? 0 : helper.In.z;
}
virtual string OpenCLString()
@@ -4667,6 +4682,7 @@ public:
<< "\n"
<< "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * Lerp(u1, u2, " << p << ") * " << is << ";\n"
<< "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * Lerp(v1, v2, " << p << ") * " << is << ";\n"
+ << "\t\tvOut.z = " << ((m_VarType == VARTYPE_REG) ? "0" : "vIn.z") << ";\n"
<< "\t}\n";
return ss.str();
@@ -4677,7 +4693,7 @@ public:
m_F = m_Frequency * 5;
m_A = m_Amplitude * T(0.01);
m_P = m_Phase * M_2PI - T(M_PI);
- m_S = m_Scale == 0 ? EPS6 : m_Scale;//Scale must not be zero.
+ m_S = Zeps(m_Scale);//Scale must not be zero.
m_Is = 1 / m_S;//Need the inverse scale.
//Pre-multiply velocity + phase, phase + amplitude and (PI - phase) + amplitude.
@@ -4792,7 +4808,7 @@ public:
{
if (m_Sx == 0)
{
- m_Sx = EPS6;
+ m_Sx = EPS;
m_Ax = 1;
}
else
@@ -4911,11 +4927,8 @@ public:
{
m_Ax = m_AmpX;
m_Ay = m_AmpY;
- m_Fx = m_FreqX * M_2PI;
- m_Fy = m_FreqY * M_2PI;
-
- if (m_Fx == 0) m_Fx = EPS6;
- if (m_Fy == 0) m_Fy = EPS6;
+ m_Fx = Zeps(m_FreqX * M_2PI);
+ m_Fy = Zeps(m_FreqY * M_2PI);
}
protected:
@@ -5053,7 +5066,7 @@ public:
virtual string OpenCLString()
{
ostringstream ss;
- int i = 0, varIndex = IndexInXform();
+ int varIndex = IndexInXform();
ss << "\t{\n"
<< "\t\treal_t r = xform->m_VariationWeights[" << varIndex << "];\n"
@@ -5517,7 +5530,7 @@ public:
virtual string OpenCLString()
{
ostringstream ss;
- int i = 0, varIndex = IndexInXform();
+ int varIndex = IndexInXform();
ss << "\t{\n"
<< "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * sin(vIn.x) * (cosh(vIn.y) + 1.0) * Sqr(sin(vIn.x));\n"
@@ -5552,7 +5565,7 @@ public:
virtual string OpenCLString()
{
ostringstream ss;
- int i = 0, varIndex = IndexInXform();
+ int varIndex = IndexInXform();
ss << "\t{\n"
<< "\t\treal_t d = xform->m_VariationWeights[" << varIndex << "] / precalcSumSquares;\n"
@@ -5700,7 +5713,7 @@ MAKEPREPOSTPARVAR(BlurLinear, blur_linear, BLUR_LINEAR)
MAKEPREPOSTPARVARASSIGN(BlurSquare, blur_square, BLUR_SQUARE, ASSIGNTYPE_SUM)
MAKEPREPOSTVAR(Flatten, flatten, FLATTEN)
MAKEPREPOSTVARASSIGN(Zblur, zblur, ZBLUR, ASSIGNTYPE_SUM)
-MAKEPREPOSTVARASSIGN(Blur3D, blur_3d, BLUR3D, ASSIGNTYPE_SUM)
+MAKEPREPOSTVARASSIGN(Blur3D, blur3D, BLUR3D, ASSIGNTYPE_SUM)
MAKEPREPOSTVARASSIGN(ZScale, zscale, ZSCALE, ASSIGNTYPE_SUM)
MAKEPREPOSTVARASSIGN(ZTranslate, ztranslate, ZTRANSLATE, ASSIGNTYPE_SUM)
MAKEPREPOSTVAR(ZCone, zcone, ZCONE)
diff --git a/Source/Ember/Variations03.h b/Source/Ember/Variations03.h
index 8d21653..ae0af14 100644
--- a/Source/Ember/Variations03.h
+++ b/Source/Ember/Variations03.h
@@ -80,7 +80,7 @@ public:
virtual string OpenCLString()
{
ostringstream ss;
- int i = 0, varIndex = IndexInXform();
+ int varIndex = IndexInXform();
ss << "\t{\n"
<< "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * vIn.x;\n"
@@ -109,7 +109,7 @@ public:
void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand)
{
T r2 = pow(helper.m_PrecalcSumSquares, m_Power * T(0.5)) * m_Weight;
- T ran = (helper.m_PrecalcAtanyx / (m_Denominator + EPS6) + (m_Root * M_2PI * Floor(rand.Frand01() * m_Denominator) / (m_Denominator + EPS))) * m_Numerator;
+ T ran = (helper.m_PrecalcAtanyx / Zeps(m_Denominator) + (m_Root * M_2PI * Floor(rand.Frand01() * m_Denominator) / Zeps(m_Denominator))) * m_Numerator;
helper.Out.x = r2 * cos(ran);
helper.Out.y = r2 * sin(ran);
@@ -131,7 +131,7 @@ public:
ss << "\t{\n"
<< "\t\treal_t r2 = pow(precalcSumSquares, " << power << " * 0.5) * xform->m_VariationWeights[" << varIndex << "];\n"
- << "\t\treal_t ran = (precalcAtanyx / (" << denominator << " + EPS6) + (" << root << " * M_2PI * floor(MwcNext01(mwc) * " << denominator << ") / (" << denominator << " + EPS))) * " << numerator << ";\n"
+ << "\t\treal_t ran = (precalcAtanyx / Zeps(" << denominator << ") + (" << root << " * M_2PI * floor(MwcNext01(mwc) * " << denominator << ") / Zeps(" << denominator << "))) * " << numerator << ";\n"
<< "\n"
<< "\t\tvOut.x = r2 * cos(ran);\n"
<< "\t\tvOut.y = r2 * sin(ran);\n"
@@ -143,7 +143,7 @@ public:
virtual void Precalc()
{
- m_Power = m_Numerator / (m_Denominator * m_Correctn * (1 / m_Correctd) + EPS6);
+ m_Power = m_Numerator / Zeps(m_Denominator * m_Correctn * (1 / m_Correctd));
}
protected:
@@ -185,7 +185,7 @@ public:
void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand)
{
- T u = sqrt(ClampGte0((m_A + EPS6) * SQR(helper.In.x) + (m_B + EPS6) * SQR(helper.In.y)));//Original did not clamp.
+ T u = sqrt(ClampGte0(Zeps(m_A) * SQR(helper.In.x) + Zeps(m_B) * SQR(helper.In.y)));//Original did not clamp.
helper.Out.x = cos(u) * tan(helper.In.x) * m_Weight;
helper.Out.y = sin(u) * tan(helper.In.y) * m_Weight;
@@ -202,7 +202,7 @@ public:
string b = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
ss << "\t{\n"
- << "\t\treal_t u = sqrt(ClampGte((" << a << " + EPS6) * SQR(vIn.x) + (" << b << " + EPS6) * SQR(vIn.y), 0.0));\n"
+ << "\t\treal_t u = sqrt(ClampGte(Zeps(" << a << ") * SQR(vIn.x) + Zeps(" << b << ") * SQR(vIn.y), 0.0));\n"
<< "\n"
<< "\t\tvOut.x = cos(u) * tan(vIn.x) * xform->m_VariationWeights[" << varIndex << "];\n"
<< "\t\tvOut.y = sin(u) * tan(vIn.y) * xform->m_VariationWeights[" << varIndex << "];\n"
@@ -248,7 +248,7 @@ public:
virtual string OpenCLString()
{
ostringstream ss;
- int i = 0, varIndex = IndexInXform();
+ int varIndex = IndexInXform();
ss << "\t{\n"
<< "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * (vIn.x - ((SQR(vIn.x) * vIn.x) / 3)) + vIn.x * SQR(vIn.y);\n"
@@ -1087,7 +1087,7 @@ public:
virtual string OpenCLString()
{
ostringstream ss;
- int i = 0, varIndex = IndexInXform();
+ int varIndex = IndexInXform();
ss << "\t{\n"
<< "\t\treal_t rad = sqrt(MwcNext01(mwc));\n"
@@ -1261,7 +1261,7 @@ public:
bool mode = m_Power > 0;
m_WorkPower = mode ? m_Power : -m_Power;
- ClampLteRef(m_WorkPower, 2);
+ ClampGteRef(m_WorkPower, 2);
m_Alpha = M_2PI / m_WorkPower;
}
@@ -1490,7 +1490,7 @@ public:
T z = helper.In.z / m_AbsN;
T r = m_Weight * pow(helper.m_PrecalcSumSquares + SQR(z), m_Cn);
T tmp = r * helper.m_PrecalcSqrtSumSquares;
- T ang = helper.m_PrecalcAtanyx + M_2PI * rand.Rand((unsigned int)m_AbsN);
+ T ang = (helper.m_PrecalcAtanyx + M_2PI * rand.Rand((unsigned int)m_AbsN)) / m_N;
helper.Out.x = tmp * cos(ang);
helper.Out.y = tmp * sin(ang);
@@ -1511,7 +1511,7 @@ public:
<< "\t\treal_t z = vIn.z / " << absn << ";\n"
<< "\t\treal_t r = xform->m_VariationWeights[" << varIndex << "] * pow(precalcSumSquares + SQR(z), " << cn << ");\n"
<< "\t\treal_t tmp = r * precalcSqrtSumSquares;\n"
- << "\t\treal_t ang = precalcAtanyx + M_2PI * MwcNextRange(mwc, (uint)" << absn << ");\n"
+ << "\t\treal_t ang = (precalcAtanyx + M_2PI * MwcNextRange(mwc, (uint)" << absn << ")) / " << n << ";\n"
<< "\n"
<< "\t\tvOut.x = tmp * cos(ang);\n"
<< "\t\tvOut.y = tmp * sin(ang);\n"
@@ -1569,7 +1569,7 @@ public:
void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand)
{
T r = m_Weight * pow(helper.m_PrecalcSumSquares, m_Cn);
- T temp = helper.m_PrecalcAtanyx + M_2PI * rand.Rand((unsigned int)m_AbsN);
+ T temp = (helper.m_PrecalcAtanyx + M_2PI * rand.Rand((unsigned int)m_AbsN)) / m_N;
helper.Out.x = r * cos(temp);
helper.Out.y = r * sin(temp);
@@ -1588,7 +1588,7 @@ public:
ss << "\t{\n"
<< "\t\treal_t r = xform->m_VariationWeights[" << varIndex << "] * pow(precalcSumSquares, " << cn << ");\n"
- << "\t\treal_t temp = precalcAtanyx + M_2PI * MwcNextRange(mwc, (uint)" << absn << ");\n"
+ << "\t\treal_t temp = (precalcAtanyx + M_2PI * MwcNextRange(mwc, (uint)" << absn << ")) / " << n << ";\n"
<< "\n"
<< "\t\tvOut.x = r * cos(temp);\n"
<< "\t\tvOut.y = r * sin(temp);\n"
@@ -1647,6 +1647,7 @@ public:
{
helper.Out.x = SignNz(helper.In.x) * pow(fabs(helper.In.x), m_PowX) * m_Weight;
helper.Out.y = SignNz(helper.In.y) * pow(fabs(helper.In.y), m_PowY) * m_Weight;
+ helper.Out.z = (m_VarType == VARTYPE_REG) ? 0 : helper.In.z;
}
virtual string OpenCLString()
@@ -1659,8 +1660,9 @@ public:
string powy = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
ss << "\t{\n"
- << "\t\tvOut.x = (real_t)(vIn.x < 0 ? -1 : 1) * pow(fabs(vIn.x), " << powx << ") * xform->m_VariationWeights[" << varIndex << "];\n"
- << "\t\tvOut.y = (real_t)(vIn.y < 0 ? -1 : 1) * pow(fabs(vIn.y), " << powy << ") * xform->m_VariationWeights[" << varIndex << "];\n"
+ << "\t\tvOut.x = SignNz(vIn.x) * pow(fabs(vIn.x), " << powx << ") * xform->m_VariationWeights[" << varIndex << "];\n"
+ << "\t\tvOut.y = SignNz(vIn.y) * pow(fabs(vIn.y), " << powy << ") * xform->m_VariationWeights[" << varIndex << "];\n"
+ << "\t\tvOut.z = " << ((m_VarType == VARTYPE_REG) ? "0" : "vIn.z") << ";\n"
<< "\t}\n";
return ss.str();
@@ -1754,10 +1756,11 @@ public:
void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand)
{
- T r = m_Weight / (helper.m_PrecalcSumSquares + EPS6);
+ T r = m_Weight / Zeps(helper.m_PrecalcSumSquares);
helper.Out.x = helper.In.x * r * m_X;
helper.Out.y = helper.In.y * r * m_Y;
+ helper.Out.z = (m_VarType == VARTYPE_REG) ? 0 : helper.In.z;
}
virtual string OpenCLString()
@@ -1770,10 +1773,11 @@ public:
string y = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
ss << "\t{\n"
- << "\t\treal_t r = xform->m_VariationWeights[" << varIndex << "] / (precalcSumSquares + EPS6);\n"
+ << "\t\treal_t r = xform->m_VariationWeights[" << varIndex << "] / Zeps(precalcSumSquares);\n"
<< "\n"
<< "\t\tvOut.x = vIn.x * r * " << x << ";\n"
<< "\t\tvOut.y = vIn.y * r * " << y << ";\n"
+ << "\t\tvOut.z = " << ((m_VarType == VARTYPE_REG) ? "0" : "vIn.z") << ";\n"
<< "\t}\n";
return ss.str();
@@ -1810,7 +1814,7 @@ public:
void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand)
{
- T r = m_Weight / (helper.m_PrecalcSumSquares + SQR(helper.In.z) + EPS6);
+ T r = m_Weight / Zeps(helper.m_PrecalcSumSquares + SQR(helper.In.z));
helper.Out.x = helper.In.x * r * m_X;
helper.Out.y = helper.In.y * r * m_Y;
@@ -1828,7 +1832,7 @@ public:
string z = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
ss << "\t{\n"
- << "\t\treal_t r = xform->m_VariationWeights[" << varIndex << "] / (precalcSumSquares + SQR(vIn.z) + EPS6);\n"
+ << "\t\treal_t r = xform->m_VariationWeights[" << varIndex << "] / Zeps(precalcSumSquares + SQR(vIn.z));\n"
<< "\n"
<< "\t\tvOut.x = vIn.x * r * " << x << ";\n"
<< "\t\tvOut.y = vIn.y * r * " << y << ";\n"
@@ -1968,7 +1972,7 @@ public:
virtual string OpenCLString()
{
ostringstream ss;
- int i = 0, varIndex = IndexInXform();
+ int varIndex = IndexInXform();
ss << "\t{\n"
<< "\t\treal_t sinX = sin(vIn.x);\n"
@@ -2010,7 +2014,7 @@ public:
virtual string OpenCLString()
{
ostringstream ss;
- int i = 0, varIndex = IndexInXform();
+ int varIndex = IndexInXform();
ss << "\t{\n"
<< "\t\treal_t e = 1 / precalcSumSquares + SQR(M_2_PI);\n"
@@ -2084,7 +2088,7 @@ public:
virtual string OpenCLString()
{
ostringstream ss;
- int i = 0, varIndex = IndexInXform();
+ int varIndex = IndexInXform();
ss << "\t{\n"
<< "\t\treal_t inZ, otherZ, tempTz, tempPz;\n"
@@ -2158,25 +2162,27 @@ public:
void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand)
{
- T c1 = SQR(helper.In.x);
- T c2 = SQR(helper.In.y);
+ T d = Zeps(helper.m_PrecalcSumSquares);
+ T c1 = Zeps(SQR(helper.In.x));
+ T c2 = Zeps(SQR(helper.In.y));
- helper.Out.x = m_Weight * ((1 / helper.m_PrecalcSumSquares + EPS6) * cos(c1 + EPS6) * sin(c2 + EPS6));
- helper.Out.y = m_Weight * ((1 / helper.m_PrecalcSumSquares + EPS6) * sin(c1 + EPS6) * sin(c2 + EPS6));
+ helper.Out.x = m_Weight * ((1 / d) * cos(c1) * sin(c2));
+ helper.Out.y = m_Weight * ((1 / d) * sin(c1) * sin(c2));
helper.Out.z = m_Weight * helper.In.z;
}
virtual string OpenCLString()
{
ostringstream ss;
- int i = 0, varIndex = IndexInXform();
+ int varIndex = IndexInXform();
ss << "\t{\n"
- << "\t\treal_t c1 = SQR(vIn.x);\n"
- << "\t\treal_t c2 = SQR(vIn.y);\n"
+ << "\t\treal_t d = Zeps(precalcSumSquares);\n"
+ << "\t\treal_t c1 = Zeps(SQR(vIn.x));\n"
+ << "\t\treal_t c2 = Zeps(SQR(vIn.y));\n"
<< "\n"
- << "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * ((1.0 / precalcSumSquares + EPS6) * cos(c1 + EPS6) * sin(c2 + EPS6));\n"
- << "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * ((1.0 / precalcSumSquares + EPS6) * sin(c1 + EPS6) * sin(c2 + EPS6));\n"
+ << "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * ((1.0 / d) * cos(c1) * sin(c2));\n"
+ << "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * ((1.0 / d) * sin(c1) * sin(c2));\n"
<< "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n"
<< "\t}\n";
@@ -2236,7 +2242,7 @@ public:
virtual string OpenCLString()
{
ostringstream ss;
- int i = 0, varIndex = IndexInXform();
+ int varIndex = IndexInXform();
ss << "\t{\n"
<< "\t\treal_t a = precalcAtanyx;\n"
@@ -2295,7 +2301,7 @@ public:
void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand)
{
- T dx, dy, r = m_Weight / (helper.m_PrecalcSumSquares + EPS6);
+ T dx, dy, r = m_Weight / (helper.m_PrecalcSumSquares + EPS);
int isXY = int(LRint(helper.In.x * m_InvSize) + LRint(helper.In.y * m_InvSize));
if (isXY % 2)
@@ -2327,7 +2333,7 @@ public:
string invSize = "parVars[" + ToUpper(m_Params[i++].Name()) + index;//Precalc.
ss << "\t{\n"
- << "\t\treal_t dx, dy, r = xform->m_VariationWeights[" << varIndex << "] / (precalcSumSquares + EPS6);\n"
+ << "\t\treal_t dx, dy, r = xform->m_VariationWeights[" << varIndex << "] / (precalcSumSquares + EPS);\n"
<< "\t\tint isXY = LRint(vIn.x * " << invSize << ") + LRint(vIn.y * " << invSize << ");\n"
<< "\n"
<< "\t\tif (isXY % 2)\n"
@@ -2351,7 +2357,7 @@ public:
virtual void Precalc()
{
- m_InvSize = 1 / (m_Size + EPS6);
+ m_InvSize = 1 / (m_Size + EPS);
}
protected:
@@ -2481,7 +2487,7 @@ public:
T uIm = m_Re_A * helper.In.y + m_Im_A * helper.In.x + m_Im_B;
T vRe = m_Re_C * helper.In.x - m_Im_C * helper.In.y + m_Re_D;
T vIm = m_Re_C * helper.In.y + m_Im_C * helper.In.x + m_Im_D;
- T vDenom = vRe * vRe + vIm * vIm;
+ T vDenom = Zeps(SQR(vRe) + SQR(vIm));
helper.Out.x = m_Weight * (uRe * vRe + uIm * vIm) / vDenom;
helper.Out.y = m_Weight * (uIm * vRe - uRe * vIm) / vDenom;
@@ -2508,7 +2514,7 @@ public:
<< "\t\treal_t uIm = " << reA << " * vIn.y + " << imA << " * vIn.x + " << imB << ";\n"
<< "\t\treal_t vRe = " << reC << " * vIn.x - " << imC << " * vIn.y + " << reD << ";\n"
<< "\t\treal_t vIm = " << reC << " * vIn.y + " << imC << " * vIn.x + " << imD << ";\n"
- << "\t\treal_t vDenom = vRe * vRe + vIm * vIm;\n"
+ << "\t\treal_t vDenom = Zeps(vRe * vRe + vIm * vIm);\n"
<< "\n"
<< "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * (uRe * vRe + uIm * vIm) / vDenom;\n"
<< "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * (uIm * vRe - uRe * vIm) / vDenom;\n"
@@ -3069,7 +3075,7 @@ protected:
m_Params.clear();
m_Params.push_back(ParamWithName(&m_Even, prefix + "target_even", 0, REAL_CYCLIC, 0, M_2PI));
m_Params.push_back(ParamWithName(&m_Odd, prefix + "target_odd", 0, REAL_CYCLIC, 0, M_2PI));
- m_Params.push_back(ParamWithName(&m_Size, prefix + "target_size", 1, REAL, EPS6, TMAX));
+ m_Params.push_back(ParamWithName(&m_Size, prefix + "target_size", 1, REAL, EPS, TMAX));
m_Params.push_back(ParamWithName(true, &m_SizeDiv2, prefix + "target_size_2"));//Precalc.
}
@@ -3259,9 +3265,7 @@ public:
virtual void Precalc()
{
- if (m_Num == 0)
- m_Num = EPS6;
-
+ m_Num = Zeps(m_Num);
m_KnPi = m_Num * T(M_1_PI);
m_PiKn = T(M_PI) / m_Num;
m_Ka = T(M_PI) * m_A;
@@ -3380,7 +3384,7 @@ public:
T tau = T(0.5) * (log(Sqr(helper.In.x + 1) + SQR(helper.In.y)) - log(Sqr(helper.In.x - 1) + SQR(helper.In.y)));
T sigma = T(M_PI) - atan2(helper.In.y, helper.In.x + 1) - atan2(helper.In.y, 1 - helper.In.x);
- sigma += tau * m_Out + m_In / tau;
+ sigma = sigma + tau * m_Out + m_In / tau;
T temp = cosh(tau) - cos(sigma);
@@ -3402,7 +3406,7 @@ public:
<< "\t\treal_t tau = 0.5 * (log(Sqr(vIn.x + 1.0) + SQR(vIn.y)) - log(Sqr(vIn.x - 1.0) + SQR(vIn.y)));\n"
<< "\t\treal_t sigma = M_PI - atan2(vIn.y, vIn.x + 1.0) - atan2(vIn.y, 1.0 - vIn.x);\n"
<< "\n"
- << "\t\tsigma += tau * " << out << " + " << in << " / tau;\n"
+ << "\t\tsigma = sigma + tau * " << out << " + " << in << " / tau;\n"
<< "\n"
<< "\t\treal_t temp = cosh(tau) - cos(sigma);\n"
<< "\n"
@@ -3448,7 +3452,7 @@ public:
T tau = T(0.5) * (log(Sqr(helper.In.x + 1) + SQR(helper.In.y)) - log(Sqr(helper.In.x - 1) + SQR(helper.In.y))) / m_Power + m_Move;
T sigma = T(M_PI) - atan2(helper.In.y, helper.In.x + 1) - atan2(helper.In.y, 1 - helper.In.x) + m_Rotate;
- sigma /= m_Power + M_2PI / m_Power * Floor