mirror of
https://bitbucket.org/mfeemster/fractorium.git
synced 2025-07-01 13:56:06 -04:00
Numerous fixes
0.4.0.5 Beta 07/18/2014 --User Changes Allow for vibrancy values > 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.
This commit is contained in:
@ -392,8 +392,9 @@ auto_ptr<QTIsaac<ISAAC_SIZE, ISAAC_INT>> QTIsaac<ISAAC_SIZE, ISAAC_INT>::GlobalR
|
||||
bool PaletteList<T>::m_Init = false; \
|
||||
vector<Palette<T>> PaletteList<T>::m_Palettes = vector<Palette<T>>(); \
|
||||
bool XmlToEmber<T>::m_Init = false; \
|
||||
vector<string> XmlToEmber<T>::m_FlattenNames = vector<string>(); \
|
||||
vector<pair<string, string>> XmlToEmber<T>::m_BadParamNames = vector<pair<string, string>>(); \
|
||||
vector<pair<string, string>> XmlToEmber<T>::m_BadVariationNames = vector<pair<string, string>>();
|
||||
vector<pair<pair<string, string>, vector<string>>> XmlToEmber<T>::m_BadVariationNames = vector<pair<pair<string, string>, vector<string>>>();
|
||||
|
||||
EXPORT_SINGLE_TYPE_EMBER(float)
|
||||
|
||||
|
@ -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<T>::ProjectPitchYaw;
|
||||
else
|
||||
m_ProjFunc = &EmberNs::Ember<T>::ProjectPitch;
|
||||
@ -515,7 +515,7 @@ public:
|
||||
{
|
||||
bool b = false;
|
||||
|
||||
std::for_each(m_Xforms.begin(), m_Xforms.end(), [&](Xform<T>& xform) { b |= xform.XaosPresent(); });//If at least one entry is not equal to 1, then xaos is present.
|
||||
ForEach(m_Xforms, [&](Xform<T>& 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:
|
||||
/// </summary>
|
||||
void ClearXaos()
|
||||
{
|
||||
std::for_each(m_Xforms.begin(), m_Xforms.end(), [&](Xform<T>& xform) { xform.ClearXaos(); });
|
||||
ForEach(m_Xforms, [&](Xform<T>& xform) { xform.ClearXaos(); });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -556,7 +556,7 @@ public:
|
||||
{
|
||||
T weight = T(1) / m_Xforms.size();
|
||||
|
||||
std::for_each(m_Xforms.begin(), m_Xforms.end(), [&](Xform<T>& xform) { xform.m_Weight = weight; });
|
||||
ForEach(m_Xforms, [&](Xform<T>& xform) { xform.m_Weight = weight; });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -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<T>& 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<T>& xform) { norm += xform.m_Weight; });
|
||||
ForEach(normalizedWeights, [&](T& weight) { weight = m_Xforms[i].m_Weight / norm; i++; });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -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<T>& xform) { totalVarCount += xform.TotalVariationCount(); });
|
||||
ForEach(m_Xforms, [&](const Xform<T>& xform) { totalVarCount += xform.TotalVariationCount(); });
|
||||
variations.reserve(totalVarCount);
|
||||
|
||||
while (Xform<T>* xform = GetTotalXform(xformIndex++))
|
||||
@ -600,19 +600,52 @@ public:
|
||||
{
|
||||
string tempVarBaseName = tempVar->BaseName();
|
||||
|
||||
if ((std::find_if(variations.begin(), variations.end(), [&] (const Variation<T>* var) -> bool { return tempVar->VariationId() == var->VariationId(); }) == variations.end()) &&
|
||||
(std::find_if(variations.begin(), variations.end(), [&] (const Variation<T>* var) -> bool { return tempVarBaseName == var->BaseName(); }) == variations.end()))
|
||||
if (!FindIf(variations, [&] (const Variation<T>* var) -> bool { return tempVar->VariationId() == var->VariationId(); }) &&
|
||||
!FindIf(variations, [&] (const Variation<T>* var) -> bool { return tempVarBaseName == var->BaseName(); }))
|
||||
variations.push_back(tempVar);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (std::find_if(variations.begin(), variations.end(), [&] (const Variation<T>* var) -> bool { return tempVar->VariationId() == var->VariationId(); }) == variations.end())
|
||||
if (!FindIf(variations, [&] (const Variation<T>* var) -> bool { return tempVar->VariationId() == var->VariationId(); }))
|
||||
variations.push_back(tempVar);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
/// <param name="names">Vector of variation and parameter names</param>
|
||||
/// <returns>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.</returns>
|
||||
bool Flatten(vector<string>& names)
|
||||
{
|
||||
bool flattened = false;
|
||||
|
||||
ForEach(m_Xforms, [&](Xform<T>& xform) { flattened |= xform.Flatten(names); });
|
||||
|
||||
return flattened;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Flatten all xforms by adding a flatten variation in each if not already present.
|
||||
/// </summary>
|
||||
/// <returns>True if flatten was removed, false if it wasn't present.</returns>
|
||||
bool Unflatten()
|
||||
{
|
||||
bool unflattened = false;
|
||||
|
||||
ForEach(m_Xforms, [&](Xform<T>& xform)
|
||||
{
|
||||
unflattened |= xform.DeleteVariationById(VAR_PRE_FLATTEN);
|
||||
unflattened |= xform.DeleteVariationById(VAR_FLATTEN);
|
||||
unflattened |= xform.DeleteVariationById(VAR_POST_FLATTEN);
|
||||
});
|
||||
|
||||
return unflattened;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 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<T>& point, QTIsaac<ISAAC_SIZE, ISAAC_INT>& 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<T>() * 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;
|
||||
|
@ -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<T>::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<T, glm::defaultp>
|
||||
#define v3T glm::detail::tvec3<T, glm::defaultp>
|
||||
|
@ -128,6 +128,7 @@ public:
|
||||
{
|
||||
unsigned int i, j;
|
||||
ostringstream os;
|
||||
vector<Variation<T>*> variations;
|
||||
|
||||
os << "<flame version=\"EMBER-" << EmberVersion() << "\" time=\"" << ember.m_Time << "\"";
|
||||
|
||||
@ -194,6 +195,15 @@ public:
|
||||
if (!extraAttributes.empty())
|
||||
os << " " << extraAttributes;
|
||||
|
||||
os << " plugins=\"";
|
||||
ember.GetPresentVariations(variations, false);
|
||||
|
||||
if (!variations.empty())
|
||||
ForEach(variations, [&] (Variation<T>* 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;
|
||||
|
||||
|
@ -92,7 +92,11 @@ public:
|
||||
/// <returns>The next random integer</returns>
|
||||
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
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -126,7 +130,11 @@ public:
|
||||
template<typename floatType>
|
||||
inline floatType Frand01()
|
||||
{
|
||||
#ifdef ISAAC_FLAM3_DEBUG
|
||||
return (Rand() & 0xfffffff) / (floatType)0xfffffff;
|
||||
#else
|
||||
return Frand<floatType>(floatType(0), floatType(1));
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -137,7 +145,11 @@ public:
|
||||
template<typename floatType>
|
||||
inline floatType Frand11()
|
||||
{
|
||||
#ifdef ISAAC_FLAM3_DEBUG
|
||||
return ((Rand() & 0xfffffff) - 0x7ffffff) / (floatType)0x7ffffff;
|
||||
#else
|
||||
return Frand<floatType>(floatType(-1), floatType(1));
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -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.
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -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;
|
||||
|
@ -80,7 +80,7 @@ public:
|
||||
/// <returns>True if success, else false.</returns>
|
||||
bool InitDistributions(Ember<T>& ember)
|
||||
{
|
||||
unsigned int i, j = 0;
|
||||
unsigned int i;
|
||||
unsigned int distribCount = ember.XaosPresent() ? (unsigned int)ember.XformCount() + 1 : 1;
|
||||
const Xform<T>* 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;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -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.
|
||||
{
|
||||
|
@ -1001,10 +1001,13 @@ void Renderer<T, bucketT>::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_SIZE, ISAAC_INT> isaac(0, 0, 0, seeds);
|
||||
#else
|
||||
QTIsaac<ISAAC_SIZE, ISAAC_INT> 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<T, bucketT>::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<T>();
|
||||
m_Samples[threadIndex][0].m_Y = (T)m_Rand[threadIndex].Frand11<T>();
|
||||
m_Samples[threadIndex][0].m_X = m_Rand[threadIndex].Frand11<T>();
|
||||
m_Samples[threadIndex][0].m_Y = m_Rand[threadIndex].Frand11<T>();
|
||||
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<T>();
|
||||
m_Samples[threadIndex][0].m_ColorX = m_Rand[threadIndex].Frand01<T>();
|
||||
|
||||
//Finally, iterate.
|
||||
//t.Tic();
|
||||
|
@ -8,6 +8,31 @@
|
||||
/// </summary>
|
||||
namespace EmberNs
|
||||
{
|
||||
/// <summary>
|
||||
/// 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().
|
||||
/// </summary>
|
||||
/// <param name="container">The container to call find_if() on</param>
|
||||
/// <param name="pred">The lambda to call on each element</param>
|
||||
/// <returns>True if pred returned true once, else false.</returns>
|
||||
template<class c, class pr>
|
||||
bool inline FindIf(c& container, pr pred)
|
||||
{
|
||||
return std::find_if(container.begin(), container.end(), pred) != container.end();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Thin wrapper around std::for_each() to relieve the caller of having to
|
||||
/// pass the implicitly obvious .begin() and .end().
|
||||
/// </summary>
|
||||
/// <param name="container">The container to call for_each() on</param>
|
||||
/// <param name="pred">The lambda to call on each element</param>
|
||||
template<class c, class fn>
|
||||
void inline ForEach(c& container, fn func)
|
||||
{
|
||||
std::for_each(container.begin(), container.end(), func);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 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)
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
/// <param name="x">The value</param>
|
||||
/// <param name="y">The y distance</param>
|
||||
/// <returns>EPS6 or the value if it was non-zero</returns>
|
||||
/// <returns>EPS or the value if it was non-zero</returns>
|
||||
template <typename T>
|
||||
static inline T Zeps(T x)
|
||||
{
|
||||
return x == 0 ? EPS6 : x;
|
||||
return x == 0 ? EPS : x;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -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<T>& param)
|
||||
ForEach(m_Params, [&](ParamWithName<T>& 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<T>& param)
|
||||
ForEach(m_Params, [&](ParamWithName<T>& 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<ISAAC_SIZE, ISAAC_INT>& rand)
|
||||
{
|
||||
Variation<T>::Random(rand);
|
||||
std::for_each(m_Params.begin(), m_Params.end(), [&](ParamWithName<T>& param) { param.Set(rand.Frand11<T>()); });
|
||||
ForEach(m_Params, [&](ParamWithName<T>& param) { param.Set(rand.Frand11<T>()); });
|
||||
Precalc();
|
||||
}
|
||||
|
||||
@ -1765,10 +1765,29 @@ public:
|
||||
/// </summary>
|
||||
void Clear()
|
||||
{
|
||||
std::for_each(m_Params.begin(), m_Params.end(), [&](ParamWithName<T>& param) { *(param.Param()) = 0; });
|
||||
ForEach(m_Params, [&](ParamWithName<T>& param) { *(param.Param()) = 0; });
|
||||
Precalc();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return a vector of all parameter names, optionally including precalcs.
|
||||
/// </summary>
|
||||
/// <param name="includePrecalcs">Whether to include the names of precalcs in the returned vector</param>
|
||||
/// <returns>A vector of all parameter names</returns>
|
||||
vector<string> ParamNames(bool includePrecalcs = false)
|
||||
{
|
||||
vector<string> vec;
|
||||
|
||||
vec.reserve(m_Params.size());
|
||||
ForEach(m_Params, [&](const ParamWithName<T>& param)
|
||||
{
|
||||
if ((includePrecalcs && param.IsPrecalc()) || !param.IsPrecalc())
|
||||
vec.push_back(param.Name());
|
||||
});
|
||||
|
||||
return vec;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return the name, weight and parameters of the variation as a string.
|
||||
/// </summary>
|
||||
@ -1778,7 +1797,7 @@ public:
|
||||
ostringstream ss;
|
||||
|
||||
ss << Variation<T>::ToString() << endl;
|
||||
std::for_each(m_Params.begin(), m_Params.end(), [&](const ParamWithName<T>& param) { ss << param.ToString() << endl; });
|
||||
ForEach(m_Params, [&](const ParamWithName<T>& param) { ss << param.ToString() << endl; });
|
||||
|
||||
return ss.str();
|
||||
}
|
||||
|
@ -342,16 +342,16 @@ public:
|
||||
ADDPREPOSTREGVAR(DCTriangle)
|
||||
ADDPREPOSTREGVAR(DCZTransl)
|
||||
|
||||
std::for_each(m_Variations.begin(), m_Variations.end(), [&](Variation<T>* var) { var->Precalc(); });
|
||||
ForEach(m_Variations, [&](Variation<T>* var) { var->Precalc(); });
|
||||
std::sort(m_Variations.begin(), m_Variations.end(), [&](const Variation<T>* var1, const Variation<T>* 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<T>* var) { if (var->VarType() == VARTYPE_REG) m_RegVariations.push_back(var); });
|
||||
std::for_each(m_Variations.begin(), m_Variations.end(), [&](Variation<T>* var) { if (var->VarType() == VARTYPE_PRE) m_PreVariations.push_back(var); });
|
||||
std::for_each(m_Variations.begin(), m_Variations.end(), [&](Variation<T>* var) { if (var->VarType() == VARTYPE_POST) m_PostVariations.push_back(var); });
|
||||
ForEach(m_Variations, [&](Variation<T>* var) { if (var->VarType() == VARTYPE_REG) m_RegVariations.push_back(var); });
|
||||
ForEach(m_Variations, [&](Variation<T>* var) { if (var->VarType() == VARTYPE_PRE) m_PreVariations.push_back(var); });
|
||||
ForEach(m_Variations, [&](Variation<T>* 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<T>* 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<T>* 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;
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -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<T>(&m_BlurPixelizeSize, prefix + "blur_pixelize_size", T(0.1), REAL, EPS6));
|
||||
m_Params.push_back(ParamWithName<T>(&m_BlurPixelizeSize, prefix + "blur_pixelize_size", T(0.1), REAL, EPS));
|
||||
m_Params.push_back(ParamWithName<T>(&m_BlurPixelizeScale, prefix + "blur_pixelize_scale", 1));
|
||||
m_Params.push_back(ParamWithName<T>(true, &m_V, prefix + "blur_pixelize_v"));//Precalc.
|
||||
m_Params.push_back(ParamWithName<T>(true, &m_InvSize, prefix + "blur_pixelize_inv_size"));
|
||||
@ -920,7 +932,7 @@ public:
|
||||
|
||||
void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& 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:
|
||||
|
||||
/// <summary>
|
||||
/// ZScale.
|
||||
/// This uses in/out in a rare and different way.
|
||||
/// </summary>
|
||||
template <typename T>
|
||||
class EMBER_API ZScaleVariation : public Variation<T>
|
||||
@ -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:
|
||||
|
||||
/// <summary>
|
||||
/// ZTranslate.
|
||||
/// This uses in/out in a rare and different way.
|
||||
/// </summary>
|
||||
template <typename T>
|
||||
class EMBER_API ZTranslateVariation : public Variation<T>
|
||||
@ -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:
|
||||
|
||||
/// <summary>
|
||||
/// zcone.
|
||||
/// This uses in/out in a rare and different way.
|
||||
/// </summary>
|
||||
template <typename T>
|
||||
class EMBER_API ZConeVariation : public Variation<T>
|
||||
@ -1064,7 +1081,7 @@ public:
|
||||
|
||||
void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& 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 <typename T>
|
||||
class EMBER_API Blur3DVariation : public Variation<T>
|
||||
{
|
||||
public:
|
||||
Blur3DVariation(T weight = 1.0) : Variation<T>("blur_3d", VAR_BLUR3D, weight) { }
|
||||
Blur3DVariation(T weight = 1.0) : Variation<T>("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<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& 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<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& 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<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& 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<T>(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<T>(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<T>(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<T>(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)
|
||||
|
@ -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<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& 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<T>(rand.Frand01<T>() * m_Denominator) / (m_Denominator + EPS))) * m_Numerator;
|
||||
T ran = (helper.m_PrecalcAtanyx / Zeps(m_Denominator) + (m_Root * M_2PI * Floor<T>(rand.Frand01<T>() * 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<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand)
|
||||
{
|
||||
T u = sqrt(ClampGte0<T>((m_A + EPS6) * SQR(helper.In.x) + (m_B + EPS6) * SQR(helper.In.y)));//Original did not clamp.
|
||||
T u = sqrt(ClampGte0<T>(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<T>(m_WorkPower, 2);
|
||||
ClampGteRef<T>(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<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& 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<T>(helper.In.x) * pow(fabs(helper.In.x), m_PowX) * m_Weight;
|
||||
helper.Out.y = SignNz<T>(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<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& 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<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& 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<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& 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<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& 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<T>(&m_Even, prefix + "target_even", 0, REAL_CYCLIC, 0, M_2PI));
|
||||
m_Params.push_back(ParamWithName<T>(&m_Odd, prefix + "target_odd", 0, REAL_CYCLIC, 0, M_2PI));
|
||||
m_Params.push_back(ParamWithName<T>(&m_Size, prefix + "target_size", 1, REAL, EPS6, TMAX));
|
||||
m_Params.push_back(ParamWithName<T>(&m_Size, prefix + "target_size", 1, REAL, EPS, TMAX));
|
||||
m_Params.push_back(ParamWithName<T>(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<T>(rand.Frand01<T>() * m_Power);
|
||||
sigma = sigma / m_Power + M_2PI / m_Power * Floor<T>(rand.Frand01<T>() * m_Power);
|
||||
|
||||
if (helper.In.x >= 0)
|
||||
tau += m_Split;
|
||||
@ -3477,7 +3481,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))) / " << power << " + " << move << ";\n"
|
||||
<< "\t\treal_t sigma = M_PI - atan2(vIn.y, vIn.x + 1.0) - atan2(vIn.y, 1.0 - vIn.x) + " << rotate << ";\n"
|
||||
<< "\n"
|
||||
<< "\t\tsigma /= " << power << " + M_2PI / " << power << " * floor(MwcNext01(mwc) * " << power << ");\n"
|
||||
<< "\t\tsigma = sigma / " << power << " + M_2PI / " << power << " * floor(MwcNext01(mwc) * " << power << ");\n"
|
||||
<< "\n"
|
||||
<< "\t\tif (vIn.x >= 0)\n"
|
||||
<< "\t\t tau += " << split << ";\n"
|
||||
@ -3804,7 +3808,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"
|
||||
|
@ -601,7 +601,7 @@ public:
|
||||
|
||||
void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand)
|
||||
{
|
||||
T d = helper.m_PrecalcSumSquares + EPS6;
|
||||
T d = Zeps(helper.m_PrecalcSumSquares);
|
||||
|
||||
helper.Out.x = (m_Weight / d) * (tanh(d) * (2 * helper.In.x));
|
||||
helper.Out.y = (m_Weight / d) * (cos(d) * (2 * helper.In.y));
|
||||
@ -611,10 +611,10 @@ public:
|
||||
virtual string OpenCLString()
|
||||
{
|
||||
ostringstream ss;
|
||||
int i = 0, varIndex = IndexInXform();
|
||||
int varIndex = IndexInXform();
|
||||
|
||||
ss << "\t{\n"
|
||||
<< "\t\treal_t d = precalcSumSquares + EPS6;\n"
|
||||
<< "\t\treal_t d = Zeps(precalcSumSquares);\n"
|
||||
<< "\n"
|
||||
<< "\t\tvOut.x = (xform->m_VariationWeights[" << varIndex << "] / d) * (tanh(d) * (2.0 * vIn.x));\n"
|
||||
<< "\t\tvOut.y = (xform->m_VariationWeights[" << varIndex << "] / d) * (cos(d) * (2.0 * vIn.y));\n"
|
||||
@ -638,7 +638,7 @@ public:
|
||||
|
||||
void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand)
|
||||
{
|
||||
T d = helper.m_PrecalcSumSquares + EPS6;
|
||||
T d = Zeps(helper.m_PrecalcSumSquares);
|
||||
|
||||
helper.Out.x = (m_Weight / 2) * (tanh(d) * (2 * helper.In.x));
|
||||
helper.Out.y = (m_Weight / 2) * (cos(d) * (2 * helper.In.y));
|
||||
@ -648,10 +648,10 @@ public:
|
||||
virtual string OpenCLString()
|
||||
{
|
||||
ostringstream ss;
|
||||
int i = 0, varIndex = IndexInXform();
|
||||
int varIndex = IndexInXform();
|
||||
|
||||
ss << "\t{\n"
|
||||
<< "\t\treal_t d = precalcSumSquares + EPS6;\n"
|
||||
<< "\t\treal_t d = Zeps(precalcSumSquares);\n"
|
||||
<< "\n"
|
||||
<< "\t\tvOut.x = (xform->m_VariationWeights[" << varIndex << "] / 2.0) * (tanh(d) * (2.0 * vIn.x));\n"
|
||||
<< "\t\tvOut.y = (xform->m_VariationWeights[" << varIndex << "] / 2.0) * (cos(d) * (2.0 * vIn.y));\n"
|
||||
@ -664,6 +664,7 @@ public:
|
||||
|
||||
/// <summary>
|
||||
/// RotateX.
|
||||
/// This uses in/out in a rare and different way.
|
||||
/// </summary>
|
||||
template <typename T>
|
||||
class EMBER_API RotateXVariation : public ParametricVariation<T>
|
||||
@ -678,7 +679,7 @@ public:
|
||||
|
||||
void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand)
|
||||
{
|
||||
T z = m_RxCos * helper.In.x - m_RxSin * helper.In.y;
|
||||
T z = m_RxCos * helper.In.z - m_RxSin * helper.In.y;
|
||||
|
||||
if (m_VarType == VARTYPE_REG)
|
||||
{
|
||||
@ -704,7 +705,7 @@ public:
|
||||
string rxCos = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
|
||||
ss << "\t{\n"
|
||||
<< "\t\treal_t z = " << rxCos << " * vIn.x - " << rxSin << " * vIn.y;\n"
|
||||
<< "\t\treal_t z = " << rxCos << " * vIn.z - " << rxSin << " * vIn.y;\n"
|
||||
<< "\n";
|
||||
|
||||
if (m_VarType == VARTYPE_REG)
|
||||
@ -749,6 +750,7 @@ private:
|
||||
|
||||
/// <summary>
|
||||
/// RotateY.
|
||||
/// This uses in/out in a rare and different way.
|
||||
/// </summary>
|
||||
template <typename T>
|
||||
class EMBER_API RotateYVariation : public ParametricVariation<T>
|
||||
@ -913,6 +915,7 @@ private:
|
||||
|
||||
/// <summary>
|
||||
/// MirrorX.
|
||||
/// This uses in/out in a rare and different way.
|
||||
/// </summary>
|
||||
template <typename T>
|
||||
class EMBER_API MirrorXVariation : public Variation<T>
|
||||
@ -924,20 +927,24 @@ public:
|
||||
|
||||
void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand)
|
||||
{
|
||||
helper.Out.x = fabs(helper.In.x);
|
||||
|
||||
if (rand.Rand() & 1)
|
||||
helper.Out.x = -helper.Out.x;
|
||||
|
||||
if (m_VarType == VARTYPE_REG)
|
||||
{
|
||||
helper.Out.x = fabs(outPoint.m_X);
|
||||
|
||||
if (rand.RandBit())
|
||||
helper.Out.x = -helper.Out.x;
|
||||
|
||||
helper.Out.y = 0;
|
||||
helper.Out.z = 0;
|
||||
outPoint.m_Y = helper.In.y;
|
||||
outPoint.m_Z = helper.In.z;
|
||||
outPoint.m_X = 0;//Flipped x will be added.
|
||||
}
|
||||
else
|
||||
{
|
||||
helper.Out.x = fabs(helper.In.x);
|
||||
|
||||
if (rand.RandBit())
|
||||
helper.Out.x = -helper.Out.x;
|
||||
|
||||
helper.Out.y = helper.In.y;
|
||||
helper.Out.z = helper.In.z;
|
||||
}
|
||||
@ -947,23 +954,28 @@ public:
|
||||
{
|
||||
ostringstream ss;
|
||||
|
||||
ss << "\t{\n"
|
||||
<< "\t\tvOut.x = fabs(vIn.x);\n"
|
||||
<< "\n"
|
||||
<< "\t\tif (MwcNext(mwc) & 1)\n"
|
||||
<< "\t\t vOut.x = -vOut.x;\n";
|
||||
ss << "\t{\n";
|
||||
|
||||
if (m_VarType == VARTYPE_REG)
|
||||
{
|
||||
ss <<
|
||||
"\t\tvOut.x = fabs(outPoint->m_X);\n"
|
||||
"\n"
|
||||
"\t\tif (MwcNext(mwc) & 1)\n"
|
||||
"\t\t vOut.x = -vOut.x;\n"
|
||||
"\n"
|
||||
"\t\tvOut.y = 0;\n"
|
||||
"\t\tvOut.z = 0;\n"
|
||||
"\t\toutPoint->m_Y = vIn.y;\n"
|
||||
"\t\toutPoint->m_Z = vIn.z;\n";
|
||||
"\t\toutPoint->m_X = 0;\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
ss <<
|
||||
"\t\tvOut.x = fabs(vIn.x);\n"
|
||||
"\n"
|
||||
"\t\tif (MwcNext(mwc) & 1)\n"
|
||||
"\t\t vOut.x = -vOut.x;\n"
|
||||
"\n"
|
||||
"\t\tvOut.y = vIn.y;\n"
|
||||
"\t\tvOut.z = vIn.z;\n";
|
||||
}
|
||||
@ -976,6 +988,7 @@ public:
|
||||
|
||||
/// <summary>
|
||||
/// MirrorY.
|
||||
/// This uses in/out in a rare and different way.
|
||||
/// </summary>
|
||||
template <typename T>
|
||||
class EMBER_API MirrorYVariation : public Variation<T>
|
||||
@ -987,20 +1000,24 @@ public:
|
||||
|
||||
void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand)
|
||||
{
|
||||
helper.Out.y = fabs(helper.In.y);
|
||||
|
||||
if (rand.Rand() & 1)
|
||||
helper.Out.y = -helper.Out.y;
|
||||
|
||||
if (m_VarType == VARTYPE_REG)
|
||||
{
|
||||
helper.Out.y = fabs(outPoint.m_Y);
|
||||
|
||||
if (rand.RandBit())
|
||||
helper.Out.y = -helper.Out.y;
|
||||
|
||||
helper.Out.x = 0;
|
||||
helper.Out.z = 0;
|
||||
outPoint.m_X = helper.In.x;
|
||||
outPoint.m_Z = helper.In.z;
|
||||
outPoint.m_Y = 0;//Flipped y will be added.
|
||||
}
|
||||
else
|
||||
{
|
||||
helper.Out.y = fabs(helper.In.y);
|
||||
|
||||
if (rand.RandBit())
|
||||
helper.Out.y = -helper.Out.y;
|
||||
|
||||
helper.Out.x = helper.In.x;
|
||||
helper.Out.z = helper.In.z;
|
||||
}
|
||||
@ -1010,23 +1027,28 @@ public:
|
||||
{
|
||||
ostringstream ss;
|
||||
|
||||
ss << "\t{\n"
|
||||
<< "\t\tvOut.y = fabs(vIn.y);\n"
|
||||
<< "\n"
|
||||
<< "\t\tif (MwcNext(mwc) & 1)\n"
|
||||
<< "\t\t vOut.y = -vOut.y;\n";
|
||||
ss << "\t{\n";
|
||||
|
||||
if (m_VarType == VARTYPE_REG)
|
||||
{
|
||||
ss <<
|
||||
"\t\tvOut.y = fabs(outPoint->m_Y);\n"
|
||||
"\n"
|
||||
"\t\tif (MwcNext(mwc) & 1)\n"
|
||||
"\t\t vOut.y = -vOut.y;\n"
|
||||
"\n"
|
||||
"\t\tvOut.x = 0;\n"
|
||||
"\t\tvOut.z = 0;\n"
|
||||
"\t\toutPoint->m_X = vIn.x;\n"
|
||||
"\t\toutPoint->m_Z = vIn.z;\n";
|
||||
"\t\toutPoint->m_Y = 0;\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
ss <<
|
||||
"\t\tvOut.y = fabs(vIn.y);\n"
|
||||
"\n"
|
||||
"\t\tif (MwcNext(mwc) & 1)\n"
|
||||
"\t\t vOut.y = -vOut.y;\n"
|
||||
"\n"
|
||||
"\t\tvOut.x = vIn.x;\n"
|
||||
"\t\tvOut.z = vIn.z;\n";
|
||||
}
|
||||
@ -1039,6 +1061,7 @@ public:
|
||||
|
||||
/// <summary>
|
||||
/// MirrorZ.
|
||||
/// This uses in/out in a rare and different way.
|
||||
/// </summary>
|
||||
template <typename T>
|
||||
class EMBER_API MirrorZVariation : public Variation<T>
|
||||
@ -1052,21 +1075,25 @@ public:
|
||||
{
|
||||
if (m_VarType == VARTYPE_REG)
|
||||
{
|
||||
helper.Out.z = fabs(outPoint.m_Z);
|
||||
|
||||
if (rand.RandBit())
|
||||
helper.Out.z = -helper.Out.z;
|
||||
|
||||
helper.Out.x = 0;
|
||||
helper.Out.y = 0;
|
||||
outPoint.m_X = helper.In.x;
|
||||
outPoint.m_Y = helper.In.y;
|
||||
outPoint.m_Z = 0;//Flipped z will be added.
|
||||
}
|
||||
else
|
||||
{
|
||||
helper.Out.z = fabs(helper.In.z);
|
||||
|
||||
if (rand.RandBit())
|
||||
helper.Out.z = -helper.Out.z;
|
||||
|
||||
helper.Out.x = helper.In.x;
|
||||
helper.Out.y = helper.In.y;
|
||||
}
|
||||
|
||||
helper.Out.z = fabs(helper.In.z);
|
||||
|
||||
if (rand.Rand() & 1)
|
||||
helper.Out.z = -helper.Out.z;
|
||||
}
|
||||
|
||||
virtual string OpenCLString()
|
||||
@ -1078,23 +1105,28 @@ public:
|
||||
if (m_VarType == VARTYPE_REG)
|
||||
{
|
||||
ss <<
|
||||
"\t\tvOut.z = fabs(outPoint->m_Z);\n"
|
||||
"\n"
|
||||
"\t\tif (MwcNext(mwc) & 1)\n"
|
||||
"\t\t vOut.z = -vOut.z;\n"
|
||||
"\n"
|
||||
"\t\tvOut.x = 0;\n"
|
||||
"\t\tvOut.y = 0;\n"
|
||||
"\t\toutPoint->m_X = vIn.x;\n"
|
||||
"\t\toutPoint->m_Y = vIn.y;\n";
|
||||
"\t\toutPoint->m_Z = 0;\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
ss <<
|
||||
"\t\tvOut.z = fabs(vIn.z);\n"
|
||||
"\n"
|
||||
"\t\tif (MwcNext(mwc) & 1)\n"
|
||||
"\t\t vOut.z = -vOut.z;\n"
|
||||
"\n"
|
||||
"\t\tvOut.x = vIn.x;\n"
|
||||
"\t\tvOut.y = vIn.y;\n";
|
||||
}
|
||||
|
||||
ss << "\t\tvOut.z = fabs(vIn.z);\n"
|
||||
<< "\n"
|
||||
<< "\t\tif (MwcNext(mwc) & 1)\n"
|
||||
<< "\t\t vOut.z = -vOut.z;\n"
|
||||
<< "\t}\n";
|
||||
ss << "\t}\n";
|
||||
|
||||
return ss.str();
|
||||
}
|
||||
@ -1197,10 +1229,7 @@ public:
|
||||
|
||||
void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand)
|
||||
{
|
||||
T jun = EPS6;
|
||||
|
||||
if (fabs(m_N) > EPS6)
|
||||
jun = m_N;
|
||||
T jun = Zeps(fabs(m_N));
|
||||
|
||||
T a = (atan2(helper.In.y, pow(helper.In.x, m_Sep)) + M_2PI * Floor<T>(rand.Frand01<T>() * m_AbsN)) / jun;
|
||||
T r = m_Weight * pow(helper.m_PrecalcSumSquares, m_Cn * m_A);
|
||||
@ -1224,10 +1253,7 @@ public:
|
||||
string cn = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
|
||||
ss << "\t{\n"
|
||||
<< "\t\treal_t jun = EPS6;\n"
|
||||
<< "\n"
|
||||
<< "\t\tif (fabs(" << n << ") > EPS6)\n"
|
||||
<< "\t\t jun = " << n << ";\n"
|
||||
<< "\t\treal_t jun = Zeps(fabs(" << n << "));\n"
|
||||
<< "\n"
|
||||
<< "\t\treal_t a = (atan2(vIn.y, pow(vIn.x, " << sep << ")) + M_2PI * floor(MwcNext01(mwc) * " << absN << ")) / jun;\n"
|
||||
<< "\t\treal_t r = xform->m_VariationWeights[" << varIndex << "] * pow(precalcSumSquares, " << cn << " * " << a << ");\n"
|
||||
@ -1242,10 +1268,7 @@ public:
|
||||
|
||||
virtual void Precalc()
|
||||
{
|
||||
T jun = EPS6;
|
||||
|
||||
if (abs(m_N) > EPS)
|
||||
jun = m_N;
|
||||
T jun = Zeps(fabs(m_N));
|
||||
|
||||
m_AbsN = abs(m_N);
|
||||
m_Cn = 1 / jun / 2;
|
||||
@ -1296,6 +1319,7 @@ public:
|
||||
|
||||
helper.Out.x = m_Weight * sin(helper.In.x) * (sqX + m_W - v);
|
||||
helper.Out.y = m_Weight * sin(helper.In.y) * (sqY + m_W - v);
|
||||
helper.Out.z = (m_VarType == VARTYPE_REG) ? 0 : helper.In.z;
|
||||
}
|
||||
|
||||
virtual string OpenCLString()
|
||||
@ -1313,6 +1337,7 @@ public:
|
||||
<< "\n"
|
||||
<< "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * sin(vIn.x) * (sqX + " << w << " - v);\n"
|
||||
<< "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * sin(vIn.y) * (sqY + " << w << " - v);\n"
|
||||
<< "\t\tvOut.z = " << ((m_VarType == VARTYPE_REG) ? "0" : "vIn.z") << ";\n"
|
||||
<< "\t}\n";
|
||||
|
||||
return ss.str();
|
||||
@ -1383,6 +1408,7 @@ public:
|
||||
|
||||
helper.Out.x = m_Weight * (m_K * (helper.In.x - x0) + x0);
|
||||
helper.Out.y = m_Weight * (m_K * (helper.In.y - y0) + y0);
|
||||
helper.Out.z = (m_VarType == VARTYPE_REG) ? 0 : helper.In.z;
|
||||
}
|
||||
|
||||
virtual string OpenCLString()
|
||||
@ -1434,6 +1460,7 @@ public:
|
||||
<< "\n"
|
||||
<< "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * (" << m_k << " * (vIn.x - x0) + x0);\n"
|
||||
<< "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * (" << m_k << " * (vIn.y - y0) + y0);\n"
|
||||
<< "\t\tvOut.z = " << ((m_VarType == VARTYPE_REG) ? "0" : "vIn.z") << ";\n"
|
||||
<< "\t}\n";
|
||||
|
||||
return ss.str();
|
||||
@ -1461,7 +1488,7 @@ protected:
|
||||
|
||||
m_Params.clear();
|
||||
m_Params.push_back(ParamWithName<T>(&m_K, prefix + "Voron_K", T(0.99)));
|
||||
m_Params.push_back(ParamWithName<T>(&m_Step, prefix + "Voron_Step", T(0.25)));
|
||||
m_Params.push_back(ParamWithName<T>(&m_Step, prefix + "Voron_Step", T(0.25), REAL_NONZERO));
|
||||
m_Params.push_back(ParamWithName<T>(&m_Num, prefix + "Voron_Num", 1, INTEGER, 1, 25));
|
||||
m_Params.push_back(ParamWithName<T>(&m_XSeed, prefix + "Voron_XSeed", 3, INTEGER));
|
||||
m_Params.push_back(ParamWithName<T>(&m_YSeed, prefix + "Voron_YSeed", 7, INTEGER));
|
||||
@ -1511,10 +1538,10 @@ public:
|
||||
break;
|
||||
case 1:
|
||||
a = (rand.Rand((ISAAC_INT)m_Slices) + rand.Frand01<T>()) / m_Slices;
|
||||
r = (rand.Rand((ISAAC_INT)m_Slices) + m_YThickness) / m_Slices;
|
||||
r = (rand.Rand((ISAAC_INT)m_Slices) + m_YThickness) / m_Slices;
|
||||
break;
|
||||
case 2:
|
||||
a = (rand.Rand((ISAAC_INT)m_Slices) + m_XThickness) / m_Slices;
|
||||
a = (rand.Rand((ISAAC_INT)m_Slices) + m_XThickness) / m_Slices;
|
||||
r = (rand.Rand((ISAAC_INT)m_Slices) + rand.Frand01<T>()) / m_Slices;
|
||||
break;
|
||||
case 3:
|
||||
@ -1529,6 +1556,7 @@ public:
|
||||
|
||||
helper.Out.x = m_CosR * a + m_SinR * r;
|
||||
helper.Out.y = -m_SinR * a + m_CosR * r;
|
||||
helper.Out.z = (m_VarType == VARTYPE_REG) ? 0 : helper.In.z;
|
||||
}
|
||||
|
||||
virtual string OpenCLString()
|
||||
@ -1573,6 +1601,7 @@ public:
|
||||
<< "\n"
|
||||
<< "\t\tvOut.x = " << cosr << " * a + " << sinr << " * r;\n"
|
||||
<< "\t\tvOut.y = -" << sinr << " * a + " << cosr << " * r;\n"
|
||||
<< "\t\tvOut.z = " << ((m_VarType == VARTYPE_REG) ? "0" : "vIn.z") << ";\n"
|
||||
<< "\t}\n";
|
||||
|
||||
return ss.str();
|
||||
@ -1590,7 +1619,7 @@ protected:
|
||||
string prefix = Prefix();
|
||||
|
||||
m_Params.clear();
|
||||
m_Params.push_back(ParamWithName<T>(&m_Slices, prefix + "waffle_slices", 6, INTEGER));
|
||||
m_Params.push_back(ParamWithName<T>(&m_Slices, prefix + "waffle_slices", 6, INTEGER_NONZERO));
|
||||
m_Params.push_back(ParamWithName<T>(&m_XThickness, prefix + "waffle_xthickness", T(0.5)));
|
||||
m_Params.push_back(ParamWithName<T>(&m_YThickness, prefix + "waffle_ythickness", T(0.5)));
|
||||
m_Params.push_back(ParamWithName<T>(&m_Rotation, prefix + "waffle_rotation"));
|
||||
@ -1628,7 +1657,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"
|
||||
@ -1870,7 +1899,7 @@ public:
|
||||
{
|
||||
T t, rX, rY, rZ;
|
||||
|
||||
t = helper.m_PrecalcSumSquares + SQR(helper.In.z) + EPS6;
|
||||
t = Zeps(helper.m_PrecalcSumSquares + SQR(helper.In.z));
|
||||
rX = m_Weight / pow(t, m_StretchX);
|
||||
rY = m_Weight / pow(t, m_StretchY);
|
||||
|
||||
@ -1899,7 +1928,7 @@ public:
|
||||
ss << "\t{\n"
|
||||
<< "\t\treal_t t, rX, rY, rZ;\n"
|
||||
<< "\n"
|
||||
<< "\t\tt = precalcSumSquares + SQR(vIn.z) + EPS6;\n"
|
||||
<< "\t\tt = Zeps(precalcSumSquares + SQR(vIn.z));\n"
|
||||
<< "\t\trX = xform->m_VariationWeights[" << varIndex << "] / pow(t, " << stretchX << ");\n"
|
||||
<< "\t\trY = xform->m_VariationWeights[" << varIndex << "] / pow(t, " << stretchY << ");\n"
|
||||
<< "\n"
|
||||
@ -2239,7 +2268,7 @@ public:
|
||||
}
|
||||
else
|
||||
{
|
||||
r = m_Weight * (1 + m_Space / r);
|
||||
r = m_Weight * (1 + m_Space / Zeps(r));
|
||||
helper.Out.x = r * x + m_X;
|
||||
helper.Out.y = r * y - m_Y;
|
||||
}
|
||||
@ -2249,6 +2278,8 @@ public:
|
||||
helper.Out.x = m_Weight * helper.In.x;
|
||||
helper.Out.y = m_Weight * helper.In.y;
|
||||
}
|
||||
|
||||
helper.Out.z = (m_VarType == VARTYPE_REG) ? 0 : helper.In.z;
|
||||
}
|
||||
|
||||
virtual string OpenCLString()
|
||||
@ -2305,7 +2336,7 @@ public:
|
||||
<< "\t\t }\n"
|
||||
<< "\t\t else\n"
|
||||
<< "\t\t {\n"
|
||||
<< "\t\t r = xform->m_VariationWeights[" << varIndex << "] * (1 + " << space << " / r);\n"
|
||||
<< "\t\t r = xform->m_VariationWeights[" << varIndex << "] * (1 + " << space << " / Zeps(r));\n"
|
||||
<< "\t\t vOut.x = r * x + " << x << ";\n"
|
||||
<< "\t\t vOut.y = r * y - " << y << ";\n"
|
||||
<< "\t\t }\n"
|
||||
@ -2315,6 +2346,8 @@ public:
|
||||
<< "\t\t vOut.x = xform->m_VariationWeights[" << varIndex << "] * vIn.x;\n"
|
||||
<< "\t\t vOut.y = xform->m_VariationWeights[" << varIndex << "] * vIn.y;\n"
|
||||
<< "\t\t}\n"
|
||||
<< "\n"
|
||||
<< "\t\tvOut.z = " << ((m_VarType == VARTYPE_REG) ? "0" : "vIn.z") << ";\n"
|
||||
<< "\t}\n";
|
||||
|
||||
return ss.str();
|
||||
@ -2592,9 +2625,9 @@ public:
|
||||
T sv = sin(v);
|
||||
T cv = cos(v);
|
||||
|
||||
helper.Out.x += m_X * r * sv * cu;
|
||||
helper.Out.y += m_Y * r * sv * su;
|
||||
helper.Out.z += m_Z * r * cv;
|
||||
helper.Out.x = m_X * r * sv * cu;
|
||||
helper.Out.y = m_Y * r * sv * su;
|
||||
helper.Out.z = m_Z * r * cv;
|
||||
}
|
||||
|
||||
virtual string OpenCLString()
|
||||
@ -2675,11 +2708,7 @@ public:
|
||||
const T d = SQR(x) - SQR(y);
|
||||
const T re = Spread(m_C1 * x + m_C2 * d, m_Sx) + 1;
|
||||
const T im = Spread(m_C1 * y + m_C2x2 * x * y, m_Sy);
|
||||
T c = Powq4c(SQR(re) + SQR(im), m_PowerInv);
|
||||
|
||||
if (c == 0)
|
||||
c = EPS6;
|
||||
|
||||
T c = Zeps(Powq4c(SQR(re) + SQR(im), m_PowerInv));
|
||||
const T r = m_Weight / c;
|
||||
|
||||
helper.Out.x = (x * re + y * im) * r;
|
||||
@ -2711,10 +2740,7 @@ public:
|
||||
<< "\t\tconst real_t d = SQR(x) - SQR(y);\n"
|
||||
<< "\t\tconst real_t re = Spread(" << c1 << " * x + " << c2 << " * d, " << sx << ") + 1.0;\n"
|
||||
<< "\t\tconst real_t im = Spread(" << c1 << " * y + " << c2x2 << " * x * y, " << sy << ");\n"
|
||||
<< "\t\treal_t c = Powq4c(SQR(re) + SQR(im), " << powerInv << ");\n"
|
||||
<< "\n"
|
||||
<< "\t\tif (c == 0.0)\n"
|
||||
<< "\t\t c = EPS6;\n"
|
||||
<< "\t\treal_t c = Zeps(Powq4c(SQR(re) + SQR(im), " << powerInv << "));\n"
|
||||
<< "\n"
|
||||
<< "\t\tconst real_t r = xform->m_VariationWeights[" << varIndex << "] / c;\n"
|
||||
<< "\n"
|
||||
@ -2785,7 +2811,7 @@ public:
|
||||
r += m_Ar * sin(fma(m_Br, r, m_Cr));
|
||||
|
||||
if (r == 0)
|
||||
r = EPS6;
|
||||
r = EPS;
|
||||
|
||||
T temp = fma(m_At, sin(fma(m_Bt, r, m_Ct)), helper.m_PrecalcAtanyx);
|
||||
T st = sin(temp);
|
||||
@ -2832,7 +2858,7 @@ public:
|
||||
<< "\t\tr += " << ar << " * sin(fma(" << br << ", r, " << cr << "));\n"
|
||||
<< "\n"
|
||||
<< "\t\tif (r == 0)\n"
|
||||
<< "\t\t r = EPS6;\n"
|
||||
<< "\t\t r = EPS;\n"
|
||||
<< "\n"
|
||||
<< "\t\treal_t temp = fma(" << at << ", sin(fma(" << bt << ", r, " << ct << ")), precalcAtanyx);\n"
|
||||
<< "\t\treal_t st = sin(temp);\n"
|
||||
@ -2978,6 +3004,7 @@ public:
|
||||
|
||||
helper.Out.x = m_Weight * (fp1x + fp2x);
|
||||
helper.Out.y = m_Weight * (fp1y + fp2y);
|
||||
helper.Out.z = (m_VarType == VARTYPE_REG) ? 0 : helper.In.z;
|
||||
}
|
||||
|
||||
virtual string OpenCLString()
|
||||
@ -3045,6 +3072,7 @@ public:
|
||||
<< "\n"
|
||||
<< "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * (fp1x + fp2x);\n"
|
||||
<< "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * (fp1y + fp2y);\n"
|
||||
<< "\t\tvOut.z = " << ((m_VarType == VARTYPE_REG) ? "0" : "vIn.z") << ";\n"
|
||||
<< "\t}\n";
|
||||
|
||||
return ss.str();
|
||||
@ -3055,17 +3083,17 @@ public:
|
||||
return
|
||||
"real_t Interference2Sine(real_t a, real_t b, real_t c, real_t p, real_t x)\n"
|
||||
"{\n"
|
||||
" return a * pow(ClampGte(sin(b * x + c), EPS6), p);\n"
|
||||
" return a * pow(ClampGte(sin(b * x + c), EPS), p);\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"real_t Interference2Tri(real_t a, real_t b, real_t c, real_t p, real_t x)\n"
|
||||
"{\n"
|
||||
" return a * 2 * pow(ClampGte(asin(cos(b * x + c - M_PI_2)), EPS6) * M_1_PI, p);\n"
|
||||
" return a * 2 * pow(ClampGte(asin(cos(b * x + c - M_PI_2)), EPS) * M_1_PI, p);\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"real_t Interference2Squ(real_t a, real_t b, real_t c, real_t p, real_t x)\n"
|
||||
"{\n"
|
||||
" return a * pow(sin(b * x + c) < 0 ? EPS6 : 1, p);\n"
|
||||
" return a * pow(sin(b * x + c) < 0 ? EPS : 1, p);\n"
|
||||
"}\n"
|
||||
"\n";
|
||||
}
|
||||
@ -3091,17 +3119,17 @@ protected:
|
||||
private:
|
||||
inline static T Sine(T a, T b, T c, T p, T x)
|
||||
{
|
||||
return a * pow(ClampGte<T>(sin(b * x + c), EPS6), p);//Original did not clamp.
|
||||
return a * pow(ClampGte<T>(sin(b * x + c), EPS), p);//Original did not clamp.
|
||||
}
|
||||
|
||||
inline static T Tri(T a, T b, T c, T p, T x)
|
||||
{
|
||||
return a * 2 * pow(ClampGte<T>(asin(cos(b * x + c - T(M_PI_2))), EPS6) * T(M_1_PI), p);//Original did not clamp.
|
||||
return a * 2 * pow(ClampGte<T>(asin(cos(b * x + c - T(M_PI_2))), EPS) * T(M_1_PI), p);//Original did not clamp.
|
||||
}
|
||||
|
||||
inline static T Squ(T a, T b, T c, T p, T x)
|
||||
{
|
||||
return a * pow(sin(b * x + c) < 0 ? EPS6 : T(1), p);//Original passed -1 to pow if sin() was < 0. Doing so will return NaN, so EPS6 is passed instead.
|
||||
return a * pow(sin(b * x + c) < 0 ? EPS : T(1), p);//Original passed -1 to pow if sin() was < 0. Doing so will return NaN, so EPS is passed instead.
|
||||
}
|
||||
|
||||
T m_A1;
|
||||
@ -3144,7 +3172,7 @@ public:
|
||||
virtual string OpenCLString()
|
||||
{
|
||||
ostringstream ss;
|
||||
int i = 0, varIndex = IndexInXform();
|
||||
int varIndex = IndexInXform();
|
||||
|
||||
ss << "\t{\n"
|
||||
<< "\t\treal_t absV = Hypot(vIn.y, vIn.z);\n"
|
||||
@ -3191,7 +3219,7 @@ public:
|
||||
virtual string OpenCLString()
|
||||
{
|
||||
ostringstream ss;
|
||||
int i = 0, varIndex = IndexInXform();
|
||||
int varIndex = IndexInXform();
|
||||
|
||||
ss << "\t{\n"
|
||||
<< "\t\treal_t absV = Hypot(vIn.y, vIn.z);\n"
|
||||
@ -3239,7 +3267,7 @@ public:
|
||||
virtual string OpenCLString()
|
||||
{
|
||||
ostringstream ss;
|
||||
int i = 0, varIndex = IndexInXform();
|
||||
int varIndex = IndexInXform();
|
||||
|
||||
ss << "\t{\n"
|
||||
<< "\t\treal_t absV = Hypot(vIn.y, vIn.z);\n"
|
||||
@ -3288,7 +3316,7 @@ public:
|
||||
virtual string OpenCLString()
|
||||
{
|
||||
ostringstream ss;
|
||||
int i = 0, varIndex = IndexInXform();
|
||||
int varIndex = IndexInXform();
|
||||
|
||||
ss << "\t{\n"
|
||||
<< "\t\treal_t absV = Hypot(vIn.y, vIn.z);\n"
|
||||
@ -3342,7 +3370,7 @@ public:
|
||||
virtual string OpenCLString()
|
||||
{
|
||||
ostringstream ss;
|
||||
int i = 0, varIndex = IndexInXform();
|
||||
int varIndex = IndexInXform();
|
||||
|
||||
ss << "\t{\n"
|
||||
<< "\t\treal_t sysz = SQR(vIn.y) + SQR(vIn.z);\n"
|
||||
@ -3401,7 +3429,7 @@ public:
|
||||
virtual string OpenCLString()
|
||||
{
|
||||
ostringstream ss;
|
||||
int i = 0, varIndex = IndexInXform();
|
||||
int varIndex = IndexInXform();
|
||||
|
||||
ss << "\t{\n"
|
||||
<< "\t\treal_t sysz = SQR(vIn.y) + SQR(vIn.z);\n"
|
||||
@ -3454,7 +3482,7 @@ public:
|
||||
virtual string OpenCLString()
|
||||
{
|
||||
ostringstream ss;
|
||||
int i = 0, varIndex = IndexInXform();
|
||||
int varIndex = IndexInXform();
|
||||
|
||||
ss << "\t{\n"
|
||||
<< "\t\treal_t absV = Hypot(vIn.y, vIn.z);\n"
|
||||
@ -3501,7 +3529,7 @@ public:
|
||||
virtual string OpenCLString()
|
||||
{
|
||||
ostringstream ss;
|
||||
int i = 0, varIndex = IndexInXform();
|
||||
int varIndex = IndexInXform();
|
||||
|
||||
ss << "\t{\n"
|
||||
<< "\t\treal_t absV = Hypot(vIn.y, vIn.z);\n"
|
||||
@ -3554,7 +3582,7 @@ public:
|
||||
virtual string OpenCLString()
|
||||
{
|
||||
ostringstream ss;
|
||||
int i = 0, varIndex = IndexInXform();
|
||||
int varIndex = IndexInXform();
|
||||
|
||||
ss << "\t{\n"
|
||||
<< "\t\treal_t sysz = SQR(vIn.y) + SQR(vIn.z);\n"
|
||||
@ -3613,7 +3641,7 @@ public:
|
||||
virtual string OpenCLString()
|
||||
{
|
||||
ostringstream ss;
|
||||
int i = 0, varIndex = IndexInXform();
|
||||
int varIndex = IndexInXform();
|
||||
|
||||
ss << "\t{\n"
|
||||
<< "\t\treal_t sysz = SQR(vIn.y) + SQR(vIn.z);\n"
|
||||
@ -3667,7 +3695,7 @@ public:
|
||||
virtual string OpenCLString()
|
||||
{
|
||||
ostringstream ss;
|
||||
int i = 0, varIndex = IndexInXform();
|
||||
int varIndex = IndexInXform();
|
||||
|
||||
ss << "\t{\n"
|
||||
<< "\t\treal_t absV = Hypot(vIn.y, vIn.z);\n"
|
||||
@ -3716,7 +3744,7 @@ public:
|
||||
virtual string OpenCLString()
|
||||
{
|
||||
ostringstream ss;
|
||||
int i = 0, varIndex = IndexInXform();
|
||||
int varIndex = IndexInXform();
|
||||
|
||||
ss << "\t{\n"
|
||||
<< "\t\treal_t absV = Hypot(vIn.y, vIn.z);\n"
|
||||
@ -3763,7 +3791,7 @@ public:
|
||||
virtual string OpenCLString()
|
||||
{
|
||||
ostringstream ss;
|
||||
int i = 0, varIndex = IndexInXform();
|
||||
int varIndex = IndexInXform();
|
||||
|
||||
ss << "\t{\n"
|
||||
<< "\t\treal_t absV = Hypot(vIn.y, vIn.z);\n"
|
||||
@ -3837,7 +3865,7 @@ protected:
|
||||
string prefix = Prefix();
|
||||
|
||||
m_Params.clear();
|
||||
m_Params.push_back(ParamWithName<T>(&m_Base, prefix + "loq_base", T(M_E), REAL, EPS6, TMAX));
|
||||
m_Params.push_back(ParamWithName<T>(&m_Base, prefix + "loq_base", T(M_E), REAL, EPS, TMAX));
|
||||
m_Params.push_back(ParamWithName<T>(true, &m_Denom, prefix + "loq_denom"));//Precalc.
|
||||
}
|
||||
|
||||
@ -3859,18 +3887,20 @@ public:
|
||||
|
||||
void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand)
|
||||
{
|
||||
helper.Out.x = m_Weight / helper.m_PrecalcSqrtSumSquares;
|
||||
helper.Out.x = m_Weight / Zeps(helper.m_PrecalcSqrtSumSquares);
|
||||
helper.Out.y = helper.m_PrecalcAtanyx;
|
||||
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\tvOut.x = xform->m_VariationWeights[" << varIndex << "] / precalcSqrtSumSquares;\n"
|
||||
<< "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] / Zeps(precalcSqrtSumSquares);\n"
|
||||
<< "\t\tvOut.y = precalcAtanyx;\n"
|
||||
<< "\t\tvOut.z = " << ((m_VarType == VARTYPE_REG) ? "0" : "vIn.z") << ";\n"
|
||||
<< "\t}\n";
|
||||
|
||||
return ss.str();
|
||||
@ -3901,6 +3931,7 @@ public:
|
||||
(m_Q04 * xy + m_Q05 * helper.In.y + m_Q06 * sqy);
|
||||
helper.Out.y = (m_Q07 + m_Q08 * helper.In.x + m_Q09 * sqx) +
|
||||
(m_Q10 * xy + m_Weight * m_Q11 * helper.In.y + m_Q12 * sqy);
|
||||
helper.Out.z = (m_VarType == VARTYPE_REG) ? 0 : helper.In.z;
|
||||
}
|
||||
|
||||
virtual string OpenCLString()
|
||||
@ -3931,6 +3962,7 @@ public:
|
||||
<< "\t\t (" << q04 << " * xy + " << q05 << " * vIn.y + " << q06 << " * sqy);\n"
|
||||
<< "\t\tvOut.y = (" << q07 << " + " << q08 << " * vIn.x + " << q09 << " * sqx) + \n"
|
||||
<< "\t\t (" << q10 << " * xy + xform->m_VariationWeights[" << varIndex << "] * " << q11 << " * vIn.y + " << q12 << " * sqy);\n"
|
||||
<< "\t\tvOut.z = " << ((m_VarType == VARTYPE_REG) ? "0" : "vIn.z") << ";\n"
|
||||
<< "\t}\n";
|
||||
|
||||
return ss.str();
|
||||
@ -3989,11 +4021,11 @@ public:
|
||||
{
|
||||
T xx = (rand.Frand01<T>() - T(0.5)) * 2;
|
||||
T yy = (rand.Frand01<T>() - T(0.5)) * 2;
|
||||
T k = yy < 0 ? T(-1) : T(1);
|
||||
T k = SignNz(yy);
|
||||
T yymax = ((m_A * pow(fabs(xx), m_P) + k * m_B * sqrt(fabs(1 - SQR(xx)))) - m_A);
|
||||
|
||||
//The function must be in a range 0-1 to work properly.
|
||||
yymax /= (fabs(m_A) + fabs(m_B));
|
||||
yymax /= Zeps(fabs(m_A) + fabs(m_B));
|
||||
|
||||
//Quick and dirty way to force y to be in range without altering the density.
|
||||
if (k > 0)
|
||||
@ -4009,6 +4041,7 @@ public:
|
||||
|
||||
helper.Out.x = xx * m_Weight;
|
||||
helper.Out.y = yy * m_Weight;
|
||||
helper.Out.z = (m_VarType == VARTYPE_REG) ? 0 : helper.In.z;
|
||||
}
|
||||
|
||||
virtual string OpenCLString()
|
||||
@ -4024,10 +4057,10 @@ public:
|
||||
ss << "\t{\n"
|
||||
<< "\t\treal_t xx = (MwcNext01(mwc) - 0.5) * 2;\n"
|
||||
<< "\t\treal_t yy = (MwcNext01(mwc) - 0.5) * 2;\n"
|
||||
<< "\t\treal_t k = yy < 0 ? -1 : 1;\n"
|
||||
<< "\t\treal_t k = SignNz(yy);\n"
|
||||
<< "\t\treal_t yymax = ((" << a << " * pow(fabs(xx), " << p << ") + k * " << b << " * sqrt(fabs(1 - SQR(xx)))) - " << a << ");\n"
|
||||
<< "\n"
|
||||
<< "\t\tyymax /= (fabs(" << a << ") + fabs(" << b << "));\n"
|
||||
<< "\t\tyymax /= Zeps(fabs(" << a << ") + fabs(" << b << "));\n"
|
||||
<< "\n"
|
||||
<< "\t\tif (k > 0)\n"
|
||||
<< "\t\t{\n"
|
||||
@ -4042,6 +4075,7 @@ public:
|
||||
<< "\n"
|
||||
<< "\t\tvOut.x = xx * xform->m_VariationWeights[" << varIndex << "];\n"
|
||||
<< "\t\tvOut.y = yy * xform->m_VariationWeights[" << varIndex << "];\n"
|
||||
<< "\t\tvOut.z = " << ((m_VarType == VARTYPE_REG) ? "0" : "vIn.z") << ";\n"
|
||||
<< "\t}\n";
|
||||
|
||||
return ss.str();
|
||||
@ -4139,9 +4173,9 @@ public:
|
||||
randInt = seed + niter;
|
||||
randiter = 0;
|
||||
|
||||
while (randiter < niter)
|
||||
while (randiter < niter && randiter < 20)//Allow it to escape.
|
||||
{
|
||||
randiter += 1;
|
||||
randiter++;
|
||||
randInt = fmod((randInt * multiplier + offset), modBase);
|
||||
}
|
||||
}
|
||||
@ -4194,6 +4228,8 @@ public:
|
||||
helper.Out.x += m_Size * (x + Floor<T>(helper.In.x));//The += is intended here.
|
||||
helper.Out.y += m_Size * (y + Floor<T>(helper.In.y));
|
||||
}
|
||||
|
||||
helper.Out.z = (m_VarType == VARTYPE_REG) ? 0 : helper.In.z;
|
||||
}
|
||||
|
||||
virtual string OpenCLString()
|
||||
@ -4273,9 +4309,9 @@ public:
|
||||
<< "\t\t randInt = seed + niter;\n"
|
||||
<< "\t\t randiter = 0;\n"
|
||||
<< "\n"
|
||||
<< "\t\t while (randiter < niter)\n"
|
||||
<< "\t\t while (randiter < niter && randiter < 20)\n"
|
||||
<< "\t\t {\n"
|
||||
<< "\t\t randiter += 1;\n"
|
||||
<< "\t\t randiter++;\n"
|
||||
<< "\t\t randInt = fmod((randInt * multiplier + offset), modBase);\n"
|
||||
<< "\t\t }\n"
|
||||
<< "\t\t }\n"
|
||||
@ -4327,6 +4363,8 @@ public:
|
||||
<< "\t\t vOut.x += " << size << " * (x + floor(vIn.x));\n"
|
||||
<< "\t\t vOut.y += " << size << " * (y + floor(vIn.y));\n"
|
||||
<< "\t\t}\n"
|
||||
<< "\n"
|
||||
<< "\t\tvOut.z = " << ((m_VarType == VARTYPE_REG) ? "0" : "vIn.z") << ";\n"
|
||||
<< "\t}\n";
|
||||
|
||||
return ss.str();
|
||||
@ -4336,7 +4374,7 @@ public:
|
||||
{
|
||||
m_OneOverEx = 1 / m_Exponent;
|
||||
m_AbsSeed = fabs(m_Seed);
|
||||
m_Seed2 = sqrt(m_AbsSeed + (m_AbsSeed / 2) + EPS6) / ((m_AbsSeed * T(0.5)) + EPS6) * T(0.25);
|
||||
m_Seed2 = sqrt(Zeps(m_AbsSeed + (m_AbsSeed / 2))) / Zeps((m_AbsSeed * T(0.5))) * T(0.25);
|
||||
m_OneOverRmax = 1 / (T(0.5) * (pow(T(2), 1 / m_Exponent) - 1) * m_ArcWidth);
|
||||
m_Scale = (cos(-m_Rotation) - sin(-m_Rotation)) / m_Weight;
|
||||
}
|
||||
@ -4551,7 +4589,7 @@ public:
|
||||
|
||||
void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand)
|
||||
{
|
||||
T r = m_Weight / ((SQR(SQR(helper.In.x)) + SQR(helper.In.z) + SQR(SQR(helper.In.y)) + SQR(helper.In.z)) + EPS6);
|
||||
T r = m_Weight / Zeps((SQR(SQR(helper.In.x)) + SQR(helper.In.z) + SQR(SQR(helper.In.y)) + SQR(helper.In.z)));
|
||||
|
||||
if (r < 2)
|
||||
{
|
||||
@ -4565,7 +4603,7 @@ public:
|
||||
helper.Out.y = m_Weight * helper.In.y;
|
||||
helper.Out.z = m_Weight * helper.In.z;
|
||||
|
||||
T t = m_Weight / ((sqrt(SQR(helper.In.x)) + sqrt(helper.In.z) + sqrt(SQR(helper.In.y)) + sqrt(helper.In.z)) + EPS6);
|
||||
T t = m_Weight / Zeps((sqrt(SQR(helper.In.x)) + sqrt(helper.In.z) + sqrt(SQR(helper.In.y)) + sqrt(helper.In.z)));
|
||||
|
||||
if (r >= 0)
|
||||
{
|
||||
@ -4608,7 +4646,7 @@ public:
|
||||
string z = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
|
||||
ss << "\t{\n"
|
||||
<< "\t\treal_t r = xform->m_VariationWeights[" << varIndex << "] / ((SQR(SQR(vIn.x)) + SQR(vIn.z) + SQR(SQR(vIn.y)) + SQR(vIn.z)) + EPS6);\n"
|
||||
<< "\t\treal_t r = xform->m_VariationWeights[" << varIndex << "] / Zeps((SQR(SQR(vIn.x)) + SQR(vIn.z) + SQR(SQR(vIn.y)) + SQR(vIn.z)));\n"
|
||||
<< "\n"
|
||||
<< "\t\tif (r < 2)\n"
|
||||
<< "\t\t{\n"
|
||||
@ -4622,7 +4660,7 @@ public:
|
||||
<< "\t\t vOut.y = xform->m_VariationWeights[" << varIndex << "] * vIn.y;\n"
|
||||
<< "\t\t vOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n"
|
||||
<< "\n"
|
||||
<< "\t\t real_t t = xform->m_VariationWeights[" << varIndex << "] / ((sqrt(SQR(vIn.x)) + sqrt(vIn.z) + sqrt(SQR(vIn.y)) + sqrt(vIn.z)) + EPS6);\n"
|
||||
<< "\t\t real_t t = xform->m_VariationWeights[" << varIndex << "] / Zeps((sqrt(SQR(vIn.x)) + sqrt(vIn.z) + sqrt(SQR(vIn.y)) + sqrt(vIn.z)));\n"
|
||||
<< "\n"
|
||||
<< "\t\t if (r >= 0)\n"
|
||||
<< "\t\t {\n"
|
||||
@ -4730,6 +4768,8 @@ public:
|
||||
helper.Out.y = m_Weight * helper.In.y;
|
||||
}
|
||||
}
|
||||
|
||||
helper.Out.z = (m_VarType == VARTYPE_REG) ? 0 : helper.In.z;
|
||||
}
|
||||
|
||||
virtual string OpenCLString()
|
||||
@ -4786,6 +4826,8 @@ public:
|
||||
<< "\t\t vOut.y = xform->m_VariationWeights[" << varIndex << "] * vIn.y;\n"
|
||||
<< "\t\t }\n"
|
||||
<< "\t\t}\n"
|
||||
<< "\n"
|
||||
<< "\t\tvOut.z = " << ((m_VarType == VARTYPE_REG) ? "0" : "vIn.z") << ";\n"
|
||||
<< "\t}\n";
|
||||
|
||||
return ss.str();
|
||||
@ -4803,9 +4845,9 @@ protected:
|
||||
string prefix = Prefix();
|
||||
|
||||
m_Params.clear();
|
||||
m_Params.push_back(ParamWithName<T>(&m_R1, prefix + "trade_r1", 1, REAL, EPS6, TMAX));
|
||||
m_Params.push_back(ParamWithName<T>(&m_R1, prefix + "trade_r1", 1, REAL, EPS, TMAX));
|
||||
m_Params.push_back(ParamWithName<T>(&m_D1, prefix + "trade_d1", 1, REAL, 0, TMAX));
|
||||
m_Params.push_back(ParamWithName<T>(&m_R2, prefix + "trade_r2", 1, REAL, EPS6, TMAX));
|
||||
m_Params.push_back(ParamWithName<T>(&m_R2, prefix + "trade_r2", 1, REAL, EPS, TMAX));
|
||||
m_Params.push_back(ParamWithName<T>(&m_D2, prefix + "trade_d2", 1, REAL, 0, TMAX));
|
||||
m_Params.push_back(ParamWithName<T>(true, &m_C1, prefix + "trade_c1"));
|
||||
m_Params.push_back(ParamWithName<T>(true, &m_C2, prefix + "trade_c2"));
|
||||
@ -4843,6 +4885,7 @@ public:
|
||||
|
||||
helper.Out.x = m_Weight * mod2 * cos(temp);
|
||||
helper.Out.y = m_Weight * mod2 * sin(temp);
|
||||
helper.Out.z = (m_VarType == VARTYPE_REG) ? 0 : helper.In.z;
|
||||
}
|
||||
|
||||
virtual string OpenCLString()
|
||||
@ -4865,6 +4908,7 @@ public:
|
||||
<< "\n"
|
||||
<< "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * mod2 * cos(temp);\n"
|
||||
<< "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * mod2 * sin(temp);\n"
|
||||
<< "\t\tvOut.z = " << ((m_VarType == VARTYPE_REG) ? "0" : "vIn.z") << ";\n"
|
||||
<< "\t}\n";
|
||||
|
||||
return ss.str();
|
||||
@ -4872,7 +4916,7 @@ public:
|
||||
|
||||
virtual void Precalc()
|
||||
{
|
||||
m_ReInv = 1 / (m_Re + EPS6);
|
||||
m_ReInv = 1 / Zeps(m_Re);
|
||||
m_Im100 = m_Im * T(0.01);
|
||||
}
|
||||
|
||||
@ -4922,7 +4966,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"
|
||||
@ -5030,22 +5074,23 @@ public:
|
||||
|
||||
void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand)
|
||||
{
|
||||
T t = ((cos(helper.In.x) + cos(helper.In.y)) / m_Mp + 1);
|
||||
T t = Zeps((cos(helper.In.x) + cos(helper.In.y)) / m_Mp + 1);
|
||||
T r = m_Weight / t;
|
||||
T tmp = helper.m_PrecalcSumSquares + 1;
|
||||
T x2 = 2 * helper.In.x;
|
||||
T y2 = 2 * helper.In.y;
|
||||
T xmax = T(0.5) * (sqrt(tmp + x2) + sqrt(tmp - x2));
|
||||
T ymax = T(0.5) * (sqrt(tmp + y2) + sqrt(tmp - y2));
|
||||
T a = helper.In.x / xmax;
|
||||
T a = helper.In.x / Zeps(xmax);
|
||||
T b = SafeSqrt(1 - SQR(a));
|
||||
|
||||
helper.Out.x = m_Vx * atan2(a, b) * r;
|
||||
|
||||
a = helper.In.y / ymax;
|
||||
a = helper.In.y / Zeps(ymax);
|
||||
b = SafeSqrt(1 - SQR(a));
|
||||
|
||||
helper.Out.y = m_Vy * atan2(a, b) * r;
|
||||
helper.Out.z = (m_VarType == VARTYPE_REG) ? 0 : helper.In.z;
|
||||
}
|
||||
|
||||
virtual string OpenCLString()
|
||||
@ -5062,22 +5107,23 @@ public:
|
||||
string vy = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
|
||||
ss << "\t{\n"
|
||||
<< "\t\treal_t t = ((cos(vIn.x) + cos(vIn.y)) / " << mp << " + 1);\n"
|
||||
<< "\t\treal_t t = Zeps((cos(vIn.x) + cos(vIn.y)) / " << mp << " + 1);\n"
|
||||
<< "\t\treal_t r = xform->m_VariationWeights[" << varIndex << "] / t;\n"
|
||||
<< "\t\treal_t tmp = precalcSumSquares + 1;\n"
|
||||
<< "\t\treal_t x2 = 2 * vIn.x;\n"
|
||||
<< "\t\treal_t y2 = 2 * vIn.y;\n"
|
||||
<< "\t\treal_t xmax = 0.5 * (sqrt(tmp + x2) + sqrt(tmp - x2));\n"
|
||||
<< "\t\treal_t ymax = 0.5 * (sqrt(tmp + y2) + sqrt(tmp - y2));\n"
|
||||
<< "\t\treal_t a = vIn.x / xmax;\n"
|
||||
<< "\t\treal_t a = vIn.x / Zeps(xmax);\n"
|
||||
<< "\t\treal_t b = SafeSqrt(1 - SQR(a));\n"
|
||||
<< "\n"
|
||||
<< "\t\tvOut.x = " << vx << " * atan2(a, b) * r;\n"
|
||||
<< "\n"
|
||||
<< "\t\ta = vIn.y / ymax;\n"
|
||||
<< "\t\ta = vIn.y / Zeps(ymax);\n"
|
||||
<< "\t\tb = SafeSqrt(1 - SQR(a));\n"
|
||||
<< "\n"
|
||||
<< "\t\tvOut.y = " << vy << " * atan2(a, b) * r;\n"
|
||||
<< "\t\tvOut.z = " << ((m_VarType == VARTYPE_REG) ? "0" : "vIn.z") << ";\n"
|
||||
<< "\t}\n";
|
||||
|
||||
return ss.str();
|
||||
@ -5098,7 +5144,7 @@ protected:
|
||||
m_Params.clear();
|
||||
m_Params.push_back(ParamWithName<T>(&m_X, prefix + "blocky_x", 1));
|
||||
m_Params.push_back(ParamWithName<T>(&m_Y, prefix + "blocky_y", 1));
|
||||
m_Params.push_back(ParamWithName<T>(&m_Mp, prefix + "blocky_mp", 4));
|
||||
m_Params.push_back(ParamWithName<T>(&m_Mp, prefix + "blocky_mp", 4, REAL_NONZERO));
|
||||
m_Params.push_back(ParamWithName<T>(true, &m_V, prefix + "blocky_v"));//Precalc.
|
||||
m_Params.push_back(ParamWithName<T>(true, &m_Vx, prefix + "blocky_vx"));
|
||||
m_Params.push_back(ParamWithName<T>(true, &m_Vy, prefix + "blocky_vy"));
|
||||
@ -5189,7 +5235,7 @@ MAKEPREPOSTPARVAR(Blocky, blocky, BLOCKY)
|
||||
// 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"
|
||||
@ -5220,7 +5266,7 @@ MAKEPREPOSTPARVAR(Blocky, blocky, BLOCKY)
|
||||
// virtual string OpenCLString()
|
||||
// {
|
||||
// ostringstream ss;
|
||||
// int i = 0, varIndex = IndexInXform();
|
||||
// int varIndex = IndexInXform();
|
||||
//
|
||||
// ss << "\t{\n"
|
||||
// << "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * vIn.y;\n"
|
||||
|
@ -99,7 +99,7 @@ public:
|
||||
int n = Floor<T>(T(0.5) * helper.In.y / m_Sc);
|
||||
T x = helper.In.x - (m * 2 + 1) * m_Sc;
|
||||
T y = helper.In.y - (n * 2 + 1) * m_Sc;
|
||||
T u = Hypot(x, y);
|
||||
T u = Zeps(Hypot(x, y));
|
||||
T v = (T(0.3) + T(0.7) * DiscreteNoise2(m + 10, n + 3)) * m_Sc;
|
||||
T z1 = DiscreteNoise2(int(m + m_Seed), n);
|
||||
|
||||
@ -139,6 +139,7 @@ public:
|
||||
|
||||
helper.Out.x = m_Weight * (x + (m * 2 + 1) * m_Sc);
|
||||
helper.Out.y = m_Weight * (y + (n * 2 + 1) * m_Sc);
|
||||
helper.Out.z = (m_VarType == VARTYPE_REG) ? 0 : helper.In.z;
|
||||
}
|
||||
|
||||
virtual string OpenCLString()
|
||||
@ -161,7 +162,7 @@ public:
|
||||
<< "\t\tint n = (int)floor(0.5 * vIn.y / " << sc << ");\n"
|
||||
<< "\t\treal_t x = vIn.x - (m * 2 + 1) * " << sc << ";\n"
|
||||
<< "\t\treal_t y = vIn.y - (n * 2 + 1) * " << sc << ";\n"
|
||||
<< "\t\treal_t u = Hypot(x, y);\n"
|
||||
<< "\t\treal_t u = Zeps(Hypot(x, y));\n"
|
||||
<< "\t\treal_t v = (0.3 + 0.7 * CircleLinearDiscreteNoise2(m + 10, n + 3)) * " << sc << ";\n"
|
||||
<< "\t\treal_t z1 = CircleLinearDiscreteNoise2((int)(m + " << seed << "), n);\n"
|
||||
<< "\n"
|
||||
@ -201,6 +202,7 @@ public:
|
||||
<< "\n"
|
||||
<< "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * (x + (m * 2 + 1) * " << sc << ");\n"
|
||||
<< "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * (y + (n * 2 + 1) * " << sc << ");\n"
|
||||
<< "\t\tvOut.z = " << ((m_VarType == VARTYPE_REG) ? "0" : "vIn.z") << ";\n"
|
||||
<< "\t}\n";
|
||||
|
||||
return ss.str();
|
||||
@ -227,7 +229,7 @@ protected:
|
||||
string prefix = Prefix();
|
||||
|
||||
m_Params.clear();
|
||||
m_Params.push_back(ParamWithName<T>(&m_Sc, prefix + "CircleLinear_Sc", 1));
|
||||
m_Params.push_back(ParamWithName<T>(&m_Sc, prefix + "CircleLinear_Sc", 1, REAL_NONZERO));
|
||||
m_Params.push_back(ParamWithName<T>(&m_K, prefix + "CircleLinear_K", T(0.5)));
|
||||
m_Params.push_back(ParamWithName<T>(&m_Dens1, prefix + "CircleLinear_Dens1", T(0.5)));
|
||||
m_Params.push_back(ParamWithName<T>(&m_Dens2, prefix + "CircleLinear_Dens2", T(0.5)));
|
||||
@ -295,6 +297,7 @@ public:
|
||||
|
||||
helper.Out.x = m_Weight * (x + (m * 2 + 1) * m_Sc);
|
||||
helper.Out.y = m_Weight * (y + (n * 2 + 1) * m_Sc);
|
||||
helper.Out.z = (m_VarType == VARTYPE_REG) ? 0 : helper.In.z;
|
||||
}
|
||||
|
||||
virtual string OpenCLString()
|
||||
@ -330,6 +333,7 @@ public:
|
||||
<< "\n"
|
||||
<< "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * (x + (m * 2 + 1) * " << sc << ");\n"
|
||||
<< "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * (y + (n * 2 + 1) * " << sc << ");\n"
|
||||
<< "\t\tvOut.z = " << ((m_VarType == VARTYPE_REG) ? "0" : "vIn.z") << ";\n"
|
||||
<< "\t}\n";
|
||||
|
||||
return ss.str();
|
||||
@ -356,7 +360,7 @@ protected:
|
||||
string prefix = Prefix();
|
||||
|
||||
m_Params.clear();
|
||||
m_Params.push_back(ParamWithName<T>(&m_Sc, prefix + "CircleRand_Sc", 1));
|
||||
m_Params.push_back(ParamWithName<T>(&m_Sc, prefix + "CircleRand_Sc", 1, REAL_NONZERO));
|
||||
m_Params.push_back(ParamWithName<T>(&m_Dens, prefix + "CircleRand_Dens", T(0.5)));
|
||||
m_Params.push_back(ParamWithName<T>(&m_X, prefix + "CircleRand_X", 10));
|
||||
m_Params.push_back(ParamWithName<T>(&m_Y, prefix + "CircleRand_Y", 10));
|
||||
@ -421,6 +425,7 @@ public:
|
||||
|
||||
helper.Out.x = m_Weight * ux;
|
||||
helper.Out.y = m_Weight * uy;
|
||||
helper.Out.z = (m_VarType == VARTYPE_REG) ? 0 : helper.In.z;
|
||||
}
|
||||
|
||||
virtual string OpenCLString()
|
||||
@ -459,6 +464,7 @@ public:
|
||||
<< "\n"
|
||||
<< "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * ux;\n"
|
||||
<< "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * uy;\n"
|
||||
<< "\t\tvOut.z = " << ((m_VarType == VARTYPE_REG) ? "0" : "vIn.z") << ";\n"
|
||||
<< "\t}\n";
|
||||
|
||||
return ss.str();
|
||||
@ -516,7 +522,7 @@ protected:
|
||||
string prefix = Prefix();
|
||||
|
||||
m_Params.clear();
|
||||
m_Params.push_back(ParamWithName<T>(&m_Sc, prefix + "CircleTrans1_Sc", 1));
|
||||
m_Params.push_back(ParamWithName<T>(&m_Sc, prefix + "CircleTrans1_Sc", 1, REAL_NONZERO));
|
||||
m_Params.push_back(ParamWithName<T>(&m_Dens, prefix + "CircleTrans1_Dens", T(0.5)));
|
||||
m_Params.push_back(ParamWithName<T>(&m_X, prefix + "CircleTrans1_X", 10));
|
||||
m_Params.push_back(ParamWithName<T>(&m_Y, prefix + "CircleTrans1_Y", 10));
|
||||
@ -1034,7 +1040,7 @@ public:
|
||||
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"
|
||||
@ -1070,10 +1076,6 @@ public:
|
||||
T uu = SQR(helper.In.x);
|
||||
T vv = SQR(helper.In.y);
|
||||
T ww = SQR(helper.In.z);
|
||||
T alpha = (vv + uu + EPS6);
|
||||
T beta = (uu + ww + EPS6);
|
||||
T delta = (vv + ww + EPS6);
|
||||
T epsilon = (vv + uu + ww + EPS6);
|
||||
T atOmegaX = atan2(vv, ww);
|
||||
T atOmegaY = atan2(uu, ww);
|
||||
T atOmegaZ = atan2(vv, uu);
|
||||
@ -1083,9 +1085,9 @@ public:
|
||||
T cv = cos(helper.In.y);
|
||||
T cucv = cu * cv;
|
||||
T sucv = su * cv;
|
||||
T x = pow(ClampGte<T>(cucv, EPS6), m_XPow) + (cucv * m_XPow) + (T(0.25) * atOmegaX);//Must clamp first argument to pow, because negative values will return NaN.
|
||||
T y = pow(ClampGte<T>(sucv, EPS6), m_YPow) + (sucv * m_YPow) + (T(0.25) * atOmegaY);//Original did not do this and would frequently return bad values.
|
||||
T z = pow(ClampGte<T>(sv, EPS6), m_ZPow) + sv * m_ZPow;
|
||||
T x = pow(ClampGte<T>(cucv, EPS), m_XPow) + (cucv * m_XPow) + (T(0.25) * atOmegaX);//Must clamp first argument to pow, because negative values will return NaN.
|
||||
T y = pow(ClampGte<T>(sucv, EPS), m_YPow) + (sucv * m_YPow) + (T(0.25) * atOmegaY);//Original did not do this and would frequently return bad values.
|
||||
T z = pow(ClampGte<T>(sv, EPS), m_ZPow) + sv * m_ZPow;
|
||||
|
||||
helper.Out.x = m_Weight * x;
|
||||
helper.Out.y = m_Weight * y;
|
||||
@ -1106,10 +1108,6 @@ public:
|
||||
<< "\t\treal_t uu = SQR(vIn.x);\n"
|
||||
<< "\t\treal_t vv = SQR(vIn.y);\n"
|
||||
<< "\t\treal_t ww = SQR(vIn.z);\n"
|
||||
<< "\t\treal_t alpha = (vv + uu + EPS6);\n"
|
||||
<< "\t\treal_t beta = (uu + ww + EPS6);\n"
|
||||
<< "\t\treal_t delta = (vv + ww + EPS6);\n"
|
||||
<< "\t\treal_t epsilon = (vv + uu + ww + EPS6);\n"
|
||||
<< "\t\treal_t atOmegaX = atan2(vv, ww);\n"
|
||||
<< "\t\treal_t atOmegaY = atan2(uu, ww);\n"
|
||||
<< "\t\treal_t atOmegaZ = atan2(vv, uu);\n"
|
||||
@ -1119,9 +1117,9 @@ public:
|
||||
<< "\t\treal_t cv = cos(vIn.y);\n"
|
||||
<< "\t\treal_t cucv = cu * cv;\n"
|
||||
<< "\t\treal_t sucv = su * cv;\n"
|
||||
<< "\t\treal_t x = pow(ClampGte(cucv, EPS6), " << xpow << ") + (cucv * " << xpow << ") + (0.25 * atOmegaX);\n"
|
||||
<< "\t\treal_t y = pow(ClampGte(sucv, EPS6), " << ypow << ") + (sucv * " << ypow << ") + (0.25 * atOmegaY);\n"
|
||||
<< "\t\treal_t z = pow(ClampGte(sv, EPS6), " << zpow << ") + sv * " << zpow << ";\n"
|
||||
<< "\t\treal_t x = pow(ClampGte(cucv, EPS), " << xpow << ") + (cucv * " << xpow << ") + (0.25 * atOmegaX);\n"
|
||||
<< "\t\treal_t y = pow(ClampGte(sucv, EPS), " << ypow << ") + (sucv * " << ypow << ") + (0.25 * atOmegaY);\n"
|
||||
<< "\t\treal_t z = pow(ClampGte(sv, EPS), " << zpow << ") + sv * " << zpow << ";\n"
|
||||
<< "\n"
|
||||
<< "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * x;\n"
|
||||
<< "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * y;\n"
|
||||
@ -1431,6 +1429,7 @@ public:
|
||||
helper.Out.y = helper.In.y * r * m_Y;
|
||||
helper.Out.x += (1 - (m_Twist * SQR(helper.In.x)) + helper.In.y) * m_Weight;//The += is intentional.
|
||||
helper.Out.y += m_Tilt * helper.In.x * m_Weight;
|
||||
helper.Out.z = (m_VarType == VARTYPE_REG) ? 0 : helper.In.z;
|
||||
}
|
||||
|
||||
virtual string OpenCLString()
|
||||
@ -1452,6 +1451,7 @@ public:
|
||||
<< "\t\tvOut.y = vIn.y * r * " << y << ";\n"
|
||||
<< "\t\tvOut.x += (1 - (" << twist << " * SQR(vIn.x)) + vIn.y) * xform->m_VariationWeights[" << varIndex << "];\n"
|
||||
<< "\t\tvOut.y += " << tilt << " * vIn.x * xform->m_VariationWeights[" << varIndex << "];\n"
|
||||
<< "\t\tvOut.z = " << ((m_VarType == VARTYPE_REG) ? "0" : "vIn.z") << ";\n"
|
||||
<< "\t}\n";
|
||||
|
||||
return ss.str();
|
||||
@ -1740,7 +1740,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"
|
||||
@ -1800,7 +1800,7 @@ public:
|
||||
|
||||
virtual void Precalc()
|
||||
{
|
||||
m_InvWeight = 1 / (m_Weight + EPS6);
|
||||
m_InvWeight = 1 / Zeps(m_Weight);
|
||||
}
|
||||
|
||||
protected:
|
||||
@ -1836,10 +1836,12 @@ public:
|
||||
const int ypos = helper.In.y < 0;
|
||||
const T xrng = helper.In.x / m_XDistance;
|
||||
const T yrng = helper.In.y / m_YDistance;
|
||||
|
||||
|
||||
helper.Out.x = m_Xw * ((xrng - (int)xrng) * m_XWidth + (int)xrng + (T(0.5) - xpos) * m_1mX);
|
||||
helper.Out.y = m_Yw * ((yrng - (int)yrng) * m_YWidth + (int)yrng + (T(0.5) - ypos) * m_1mY);
|
||||
helper.Out.z = m_Weight * helper.In.z;
|
||||
//outPoint.m_X = 0;
|
||||
//outPoint.m_Y = 0;
|
||||
}
|
||||
|
||||
virtual string OpenCLString()
|
||||
@ -1968,6 +1970,7 @@ public:
|
||||
|
||||
helper.Out.x += helper.In.x * m_Px;
|
||||
helper.Out.y += helper.In.y * m_Py;
|
||||
helper.Out.z = (m_VarType == VARTYPE_REG) ? 0 : helper.In.z;
|
||||
}
|
||||
|
||||
virtual string OpenCLString()
|
||||
@ -1976,10 +1979,10 @@ public:
|
||||
int i = 0, varIndex = IndexInXform();
|
||||
ss2 << "_" << XformIndexInEmber() << "]";
|
||||
string index = ss2.str();
|
||||
string x = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
string y = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
string px = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
string py = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
string x = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
string y = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
string px = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
string py = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
|
||||
ss << "\t{\n"
|
||||
<< "\t\treal_t b = xform->m_VariationWeights[" << varIndex << "] / (precalcSumSquares * 0.25 + 1);\n"
|
||||
@ -2028,6 +2031,7 @@ public:
|
||||
<< "\n"
|
||||
<< "\t\tvOut.x += vIn.x * " << px << ";\n"
|
||||
<< "\t\tvOut.y += vIn.y * " << py << ";\n"
|
||||
<< "\t\tvOut.z = " << ((m_VarType == VARTYPE_REG) ? "0" : "vIn.z") << ";\n"
|
||||
<< "\t}\n";
|
||||
|
||||
return ss.str();
|
||||
@ -2073,12 +2077,13 @@ public:
|
||||
|
||||
helper.Out.x = m_Weight * r * cos(a);
|
||||
helper.Out.y = m_Weight * r * sin(a);
|
||||
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 a = M_PI / (precalcSqrtSumSquares + 1);\n"
|
||||
@ -2089,6 +2094,7 @@ public:
|
||||
<< "\n"
|
||||
<< "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * r * cos(a);\n"
|
||||
<< "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * r * sin(a);\n"
|
||||
<< "\t\tvOut.z = " << ((m_VarType == VARTYPE_REG) ? "0" : "vIn.z") << ";\n"
|
||||
<< "\t}\n";
|
||||
|
||||
return ss.str();
|
||||
@ -2227,7 +2233,7 @@ protected:
|
||||
string prefix = Prefix();
|
||||
|
||||
m_Params.clear();
|
||||
m_Params.push_back(ParamWithName<T>(&m_Scatter, prefix + "falloff_scatter", 1, REAL, EPS6, TMAX));
|
||||
m_Params.push_back(ParamWithName<T>(&m_Scatter, prefix + "falloff_scatter", 1, REAL, EPS, TMAX));
|
||||
m_Params.push_back(ParamWithName<T>(&m_MinDist, prefix + "falloff_mindist", T(0.5), REAL, 0, TMAX));
|
||||
m_Params.push_back(ParamWithName<T>(&m_MulX, prefix + "falloff_mul_x", 1, REAL, 0, 1));
|
||||
m_Params.push_back(ParamWithName<T>(&m_MulY, prefix + "falloff_mul_y", 1, REAL, 0, 1));
|
||||
@ -2350,7 +2356,6 @@ public:
|
||||
string rMax = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
|
||||
ss << "\t{\n"
|
||||
|
||||
<< "\t\tconst real_t randx = MwcNextNeg1Pos1(mwc);\n"
|
||||
<< "\t\tconst real_t randy = MwcNextNeg1Pos1(mwc);\n"
|
||||
<< "\t\tconst real_t randz = MwcNextNeg1Pos1(mwc);\n"
|
||||
@ -2424,7 +2429,7 @@ protected:
|
||||
string prefix = Prefix();
|
||||
|
||||
m_Params.clear();
|
||||
m_Params.push_back(ParamWithName<T>(&m_Scatter, prefix + "falloff2_scatter", 1, REAL, EPS6, TMAX));
|
||||
m_Params.push_back(ParamWithName<T>(&m_Scatter, prefix + "falloff2_scatter", 1, REAL, EPS, TMAX));
|
||||
m_Params.push_back(ParamWithName<T>(&m_MinDist, prefix + "falloff2_mindist", T(0.5), REAL, 0, TMAX));
|
||||
m_Params.push_back(ParamWithName<T>(&m_MulX, prefix + "falloff2_mul_x", 1, REAL, 0, 1));
|
||||
m_Params.push_back(ParamWithName<T>(&m_MulY, prefix + "falloff2_mul_y", 1, REAL, 0, 1));
|
||||
@ -2528,7 +2533,7 @@ public:
|
||||
break;
|
||||
case 2://Log.
|
||||
{
|
||||
const T coeff = m_RMax <= EPS6 ? dist : dist + m_Alpha * (LogMap(dist) - dist);
|
||||
const T coeff = m_RMax <= EPS ? dist : dist + m_Alpha * (LogMap(dist) - dist);
|
||||
|
||||
helper.Out.x = helper.In.x + LogMap(m_MulX) * LogScale(random.x) * coeff,
|
||||
helper.Out.y = helper.In.y + LogMap(m_MulY) * LogScale(random.y) * coeff,
|
||||
@ -2623,7 +2628,7 @@ public:
|
||||
<< "\t\t break;\n"
|
||||
<< "\t\tcase 2:\n"
|
||||
<< "\t\t {\n"
|
||||
<< "\t\t real_t coeff = " << rMax << " <= EPS6 ? dist : dist + " << alpha << " * (LogMap(dist) - dist);\n"
|
||||
<< "\t\t real_t coeff = " << rMax << " <= EPS ? dist : dist + " << alpha << " * (LogMap(dist) - dist);\n"
|
||||
<< "\n"
|
||||
<< "\t\t vOut.x = vIn.x + LogMap(" << mulX << ") * LogScale(randx) * coeff,\n"
|
||||
<< "\t\t vOut.y = vIn.y + LogMap(" << mulY << ") * LogScale(randy) * coeff,\n"
|
||||
@ -2650,7 +2655,7 @@ protected:
|
||||
m_Params.clear();
|
||||
m_Params.push_back(ParamWithName<T>(&m_BlurType, prefix + "falloff3_blur_type", 0, INTEGER, 0, 3));
|
||||
m_Params.push_back(ParamWithName<T>(&m_BlurShape, prefix + "falloff3_blur_shape", 0, INTEGER, 0, 1));
|
||||
m_Params.push_back(ParamWithName<T>(&m_BlurStrength, prefix + "falloff3_blur_strength", 1, REAL, EPS6, TMAX));
|
||||
m_Params.push_back(ParamWithName<T>(&m_BlurStrength, prefix + "falloff3_blur_strength", 1, REAL, EPS, TMAX));
|
||||
m_Params.push_back(ParamWithName<T>(&m_MinDistance, prefix + "falloff3_min_distance", T(0.5), REAL, 0, TMAX));
|
||||
m_Params.push_back(ParamWithName<T>(&m_InvertDistance, prefix + "falloff3_invert_distance", 0, INTEGER, 0, 1));
|
||||
m_Params.push_back(ParamWithName<T>(&m_MulX, prefix + "falloff3_mul_x", 1, REAL, 0, 1));
|
||||
@ -2729,6 +2734,7 @@ public:
|
||||
InverseTrilinear(alpha, beta, x, y, rand);
|
||||
helper.Out.x = m_Weight * x;
|
||||
helper.Out.y = m_Weight * y;
|
||||
helper.Out.z = (m_VarType == VARTYPE_REG) ? 0 : helper.In.z;
|
||||
}
|
||||
|
||||
virtual string OpenCLString()
|
||||
@ -2850,6 +2856,7 @@ public:
|
||||
<< "\n"
|
||||
<< "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * x;\n"
|
||||
<< "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * y;\n"
|
||||
<< "\t\tvOut.z = " << ((m_VarType == VARTYPE_REG) ? "0" : "vIn.z") << ";\n"
|
||||
<< "\t}\n";
|
||||
|
||||
return ss.str();
|
||||
|
@ -114,6 +114,7 @@ public:
|
||||
|
||||
helper.Out.x = m_Weight * (m_Xform->m_Affine.A() * x + m_Xform->m_Affine.B() * y + m_Xform->m_Affine.E());
|
||||
helper.Out.y = m_Weight * (m_Xform->m_Affine.C() * x + m_Xform->m_Affine.D() * y + m_Xform->m_Affine.F());
|
||||
helper.Out.z = (m_VarType == VARTYPE_REG) ? 0 : helper.In.z;
|
||||
outPoint.m_ColorX = fmod(fabs(outPoint.m_ColorX * T(0.5) * (1 + h) + x0_xor_y0 * (1 - h) * T(0.5)), T(1.0));
|
||||
}
|
||||
|
||||
@ -136,6 +137,7 @@ public:
|
||||
<< "\n"
|
||||
<< "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * (xform->m_A * x + xform->m_B * y + xform->m_E);\n"
|
||||
<< "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * (xform->m_C * x + xform->m_D * y + xform->m_F);\n"
|
||||
<< "\t\tvOut.z = " << ((m_VarType == VARTYPE_REG) ? "0" : "vIn.z") << ";\n"
|
||||
<< "\t\toutPoint->m_ColorX = fmod(fabs(outPoint->m_ColorX * 0.5 * (1 + h) + x0_xor_y0 * (1 - h) * 0.5), 1.0);\n"
|
||||
<< "\t}\n";
|
||||
|
||||
@ -548,7 +550,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"
|
||||
@ -1001,7 +1003,7 @@ public:
|
||||
{
|
||||
m_X0_ = m_X0 < m_X1 ? m_X0 : m_X1;
|
||||
m_X1_ = m_X0 > m_X1 ? m_X0 : m_X1;
|
||||
m_X1_m_x0 = m_X1_ - m_X0_ == 0 ? EPS6 : m_X1_ - m_X0_;
|
||||
m_X1_m_x0 = Zeps(m_X1_ - m_X0_);
|
||||
}
|
||||
|
||||
protected:
|
||||
|
@ -267,6 +267,17 @@ public:
|
||||
if (vec->size() < MAX_VARS_PER_XFORM)
|
||||
{
|
||||
vec->push_back(variation);
|
||||
|
||||
//Flatten must always be last.
|
||||
for (size_t i = 0; i < vec->size(); i++)
|
||||
{
|
||||
if ((i != vec->size() - 1) && ((*vec)[i]->Name().find("flatten") != string::npos))
|
||||
{
|
||||
std::swap((*vec)[i], (*vec)[vec->size() - 1]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
SetPrecalcFlags();
|
||||
return true;
|
||||
}
|
||||
@ -540,8 +551,8 @@ public:
|
||||
{
|
||||
T norm = 0;
|
||||
|
||||
std::for_each(variations.begin(), variations.end(), [&](Variation<T>* var) { norm += var->m_Weight; });
|
||||
std::for_each(variations.begin(), variations.end(), [&](Variation<T>* var) { var->m_Weight /= norm; });
|
||||
ForEach(variations, [&](Variation<T>* var) { norm += var->m_Weight; });
|
||||
ForEach(variations, [&](Variation<T>* var) { var->m_Weight /= norm; });
|
||||
});
|
||||
}
|
||||
|
||||
@ -843,8 +854,8 @@ public:
|
||||
|
||||
if (m_NeedPrecalcAngles)
|
||||
{
|
||||
helper.m_PrecalcSina = helper.m_TransX / helper.m_PrecalcSqrtSumSquares;
|
||||
helper.m_PrecalcCosa = helper.m_TransY / helper.m_PrecalcSqrtSumSquares;
|
||||
helper.m_PrecalcSina = helper.m_TransX / Zeps(helper.m_PrecalcSqrtSumSquares);
|
||||
helper.m_PrecalcCosa = helper.m_TransY / Zeps(helper.m_PrecalcSqrtSumSquares);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -856,6 +867,68 @@ public:
|
||||
helper.m_PrecalcAtanyx = atan2(helper.m_TransY, helper.m_TransX);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Flatten this xform by adding a flatten variation if none is present, and if any of the
|
||||
/// variations or parameters in the vector are present.
|
||||
/// </summary>
|
||||
/// <param name="names">Vector of variation and parameter names</param>
|
||||
/// <returns>True if flatten was added, false if it already was present or if none of the specified variations or parameters were present.</returns>
|
||||
bool Flatten(vector<string>& names)
|
||||
{
|
||||
bool shouldFlatten = true;
|
||||
|
||||
if (GetVariationById(VAR_FLATTEN) == NULL)
|
||||
{
|
||||
AllVarsFunc([&] (vector<Variation<T>*>& variations, bool& keepGoing)
|
||||
{
|
||||
for (size_t i = 0; i < variations.size(); i++)
|
||||
{
|
||||
Variation<T>* var = variations[i];
|
||||
|
||||
if (var->m_Weight != 0)//This should never happen, but just to be safe.
|
||||
{
|
||||
if (FindIf(names, [&] (const string& s) -> bool { return !_stricmp(s.c_str(), var->Name().c_str()); }))
|
||||
{
|
||||
shouldFlatten = false;
|
||||
keepGoing = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//Now traverse the parameters for this variation.
|
||||
if (ParametricVariation<T>* parVar = dynamic_cast<ParametricVariation<T>*>(var))
|
||||
{
|
||||
ForEach(names, [&] (const string& s)
|
||||
{
|
||||
if (parVar->GetParamVal(s.c_str()) != 0)
|
||||
{
|
||||
shouldFlatten = false;
|
||||
keepGoing = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (shouldFlatten)
|
||||
{
|
||||
Variation<T>* var = new FlattenVariation<T>();
|
||||
|
||||
if (AddVariation(var))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
delete var;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Generate the OpenCL string for reading input values to
|
||||
/// be passed to a variation.
|
||||
|
@ -75,6 +75,7 @@ public:
|
||||
|
||||
if (!m_Init)
|
||||
{
|
||||
m_BadParamNames.reserve(100);
|
||||
m_BadParamNames.push_back(pair<string, string>("swtin_distort", "stwin_distort"));//stwin.
|
||||
m_BadParamNames.push_back(pair<string, string>("pow_numerator", "pow_block_numerator"));//pow_block.
|
||||
m_BadParamNames.push_back(pair<string, string>("pow_denominator", "pow_block_denominator"));
|
||||
@ -130,9 +131,111 @@ public:
|
||||
m_BadParamNames.push_back(pair<string, string>("mobius_rect_y", "mobius_strip_rect_y"));
|
||||
m_BadParamNames.push_back(pair<string, string>("mobius_rotate_x", "mobius_strip_rotate_x"));
|
||||
m_BadParamNames.push_back(pair<string, string>("mobius_rotate_y", "mobius_strip_rotate_y"));
|
||||
m_BadParamNames.push_back(pair<string, string>("bwraps2_cellsize", "bwraps_cellsize"));//bwraps2.
|
||||
m_BadParamNames.push_back(pair<string, string>("bwraps2_space", "bwraps_space"));
|
||||
m_BadParamNames.push_back(pair<string, string>("bwraps2_gain", "bwraps_gain"));
|
||||
m_BadParamNames.push_back(pair<string, string>("bwraps2_inner_twist", "bwraps_inner_twist"));
|
||||
m_BadParamNames.push_back(pair<string, string>("bwraps2_outer_twist", "bwraps_outer_twist"));
|
||||
m_BadParamNames.push_back(pair<string, string>("bwraps7_cellsize", "bwraps_cellsize"));//bwraps7.
|
||||
m_BadParamNames.push_back(pair<string, string>("bwraps7_space", "bwraps_space"));
|
||||
m_BadParamNames.push_back(pair<string, string>("bwraps7_gain", "bwraps_gain"));
|
||||
m_BadParamNames.push_back(pair<string, string>("bwraps7_inner_twist", "bwraps_inner_twist"));
|
||||
m_BadParamNames.push_back(pair<string, string>("bwraps7_outer_twist", "bwraps_outer_twist"));
|
||||
m_BadParamNames.push_back(pair<string, string>("pre_bwraps2_cellsize", "pre_bwraps_cellsize"));
|
||||
m_BadParamNames.push_back(pair<string, string>("pre_bwraps2_space", "pre_bwraps_space"));
|
||||
m_BadParamNames.push_back(pair<string, string>("pre_bwraps2_gain", "pre_bwraps_gain"));
|
||||
m_BadParamNames.push_back(pair<string, string>("pre_bwraps2_inner_twist", "pre_bwraps_inner_twist"));
|
||||
m_BadParamNames.push_back(pair<string, string>("pre_bwraps2_outer_twist", "pre_bwraps_outer_twist"));
|
||||
m_BadParamNames.push_back(pair<string, string>("post_bwraps2_cellsize", "post_bwraps_cellsize"));
|
||||
m_BadParamNames.push_back(pair<string, string>("post_bwraps2_space", "post_bwraps_space"));
|
||||
m_BadParamNames.push_back(pair<string, string>("post_bwraps2_gain", "post_bwraps_gain"));
|
||||
m_BadParamNames.push_back(pair<string, string>("post_bwraps2_inner_twist", "post_bwraps_inner_twist"));
|
||||
m_BadParamNames.push_back(pair<string, string>("post_bwraps2_outer_twist", "post_bwraps_outer_twist"));
|
||||
|
||||
m_FlattenNames.reserve(24);
|
||||
m_FlattenNames.push_back("linear3D");
|
||||
m_FlattenNames.push_back("bubble");
|
||||
m_FlattenNames.push_back("cylinder");
|
||||
m_FlattenNames.push_back("zblur");
|
||||
m_FlattenNames.push_back("blur3D");
|
||||
m_FlattenNames.push_back("pre_ztranslate");
|
||||
m_FlattenNames.push_back("pre_rotate_x");
|
||||
m_FlattenNames.push_back("pre_rotate_y");
|
||||
m_FlattenNames.push_back("ztranslate");
|
||||
m_FlattenNames.push_back("zcone");
|
||||
m_FlattenNames.push_back("post_rotate_x");
|
||||
m_FlattenNames.push_back("post_rotate_y");
|
||||
m_FlattenNames.push_back("julia3D");
|
||||
m_FlattenNames.push_back("julia3Dz");
|
||||
m_FlattenNames.push_back("curl3D_cz");
|
||||
m_FlattenNames.push_back("hemisphere");
|
||||
m_FlattenNames.push_back("bwraps");
|
||||
m_FlattenNames.push_back("bwraps2");
|
||||
m_FlattenNames.push_back("falloff2");
|
||||
m_FlattenNames.push_back("crop");
|
||||
m_FlattenNames.push_back("pre_falloff2");
|
||||
m_FlattenNames.push_back("pre_crop");
|
||||
m_FlattenNames.push_back("post_falloff2");
|
||||
m_FlattenNames.push_back("post_crop");
|
||||
|
||||
//This is a vector of the param names as they are in the legacy, badly named flam3/Apophysis code.
|
||||
vector<string> badParams;
|
||||
|
||||
badParams.reserve(6);
|
||||
|
||||
badParams.push_back("bwraps7_cellsize");
|
||||
badParams.push_back("bwraps7_space");
|
||||
badParams.push_back("bwraps7_gain");
|
||||
badParams.push_back("bwraps7_inner_twist");
|
||||
badParams.push_back("bwraps7_outer_twist");
|
||||
m_BadVariationNames.push_back(make_pair(make_pair(string("bwraps7"), string("bwraps")), badParams));//bwraps7 is the same as bwraps.
|
||||
badParams.clear();
|
||||
|
||||
badParams.push_back("bwraps2_cellsize");
|
||||
badParams.push_back("bwraps2_space");
|
||||
badParams.push_back("bwraps2_gain");
|
||||
badParams.push_back("bwraps2_inner_twist");
|
||||
badParams.push_back("bwraps2_outer_twist");
|
||||
m_BadVariationNames.push_back(make_pair(make_pair(string("bwraps2"), string("bwraps")), badParams));//bwraps2 is the same as bwraps.
|
||||
badParams.clear();
|
||||
|
||||
badParams.push_back("pre_bwraps2_cellsize");
|
||||
badParams.push_back("pre_bwraps2_space");
|
||||
badParams.push_back("pre_bwraps2_gain");
|
||||
badParams.push_back("pre_bwraps2_inner_twist");
|
||||
badParams.push_back("pre_bwraps2_outer_twist");
|
||||
m_BadVariationNames.push_back(make_pair(make_pair(string("pre_bwraps2"), string("pre_bwraps")), badParams));
|
||||
badParams.clear();
|
||||
|
||||
badParams.push_back("post_bwraps2_cellsize");
|
||||
badParams.push_back("post_bwraps2_space");
|
||||
badParams.push_back("post_bwraps2_gain");
|
||||
badParams.push_back("post_bwraps2_inner_twist");
|
||||
badParams.push_back("post_bwraps2_outer_twist");
|
||||
m_BadVariationNames.push_back(make_pair(make_pair(string("post_bwraps2"), string("post_bwraps")), badParams));
|
||||
badParams.clear();
|
||||
|
||||
badParams.push_back("mobius_radius");
|
||||
badParams.push_back("mobius_width");
|
||||
badParams.push_back("mobius_rect_x");
|
||||
badParams.push_back("mobius_rect_y");
|
||||
badParams.push_back("mobius_rotate_x");
|
||||
badParams.push_back("mobius_rotate_y");
|
||||
m_BadVariationNames.push_back(make_pair(make_pair(string("mobius"), string("mobius_strip")), badParams));//mobius_strip clashes with Mobius.
|
||||
badParams.clear();
|
||||
|
||||
badParams.push_back("post_dcztransl_x0");
|
||||
badParams.push_back("post_dcztransl_x1");
|
||||
badParams.push_back("post_dcztransl_factor");
|
||||
badParams.push_back("post_dcztransl_overwrite");
|
||||
badParams.push_back("post_dcztransl_clamp");
|
||||
m_BadVariationNames.push_back(make_pair(make_pair(string("post_dcztransl"), string("post_dc_ztransl")), badParams));
|
||||
badParams.clear();
|
||||
|
||||
m_BadVariationNames.push_back(make_pair(make_pair(string("pre_blur"), string("pre_gaussian_blur")), badParams));
|
||||
m_BadVariationNames.push_back(make_pair(make_pair(string("pre_spin_z"), string("pre_rotate_z")), badParams));
|
||||
m_BadVariationNames.push_back(make_pair(make_pair(string("post_spin_z"), string("post_rotate_z")), badParams));
|
||||
|
||||
m_BadVariationNames.push_back(pair<string, string>("post_dcztransl", "post_dc_ztransl"));//dc_ztransl.
|
||||
m_BadVariationNames.push_back(pair<string, string>("mobius", "mobius_strip"));//mobius_strip, case sensitive to not clash with Mobius.
|
||||
m_Init = true;
|
||||
}
|
||||
}
|
||||
@ -360,6 +463,8 @@ public:
|
||||
return string(ch);
|
||||
}
|
||||
|
||||
static vector<string> m_FlattenNames;
|
||||
|
||||
private:
|
||||
/// <summary>
|
||||
/// Scan the file for ember nodes, and parse them out into the vector of embers.
|
||||
@ -425,6 +530,7 @@ private:
|
||||
bool ParseEmberElement(xmlNode* emberNode, Ember<T>& currentEmber)
|
||||
{
|
||||
bool b = true;
|
||||
unsigned int newLinear = 0;
|
||||
char* attStr;
|
||||
const char* loc = __FUNCTION__;
|
||||
int soloXform = -1;
|
||||
@ -475,36 +581,37 @@ private:
|
||||
else if (ParseAndAssignInt(curAtt->name, attStr, "oversample", currentEmber.m_Supersample , b)) { }
|
||||
else if (ParseAndAssignInt(curAtt->name, attStr, "supersample", currentEmber.m_Supersample , b)) { }
|
||||
else if (ParseAndAssignInt(curAtt->name, attStr, "temporal_samples", currentEmber.m_TemporalSamples, b)) { }
|
||||
else if (ParseAndAssignInt(curAtt->name, attStr, "soloxform", soloXform , b)) { }
|
||||
else if (ParseAndAssignInt(curAtt->name, attStr, "soloxform", soloXform , b)) { }
|
||||
else if (ParseAndAssignInt(curAtt->name, attStr, "new_linear", newLinear , b)) { }
|
||||
|
||||
//Parse more complicated reads that have multiple possible values.
|
||||
else if (!Compare(curAtt->name, "interpolation"))
|
||||
{
|
||||
if (!strcmp("linear", attStr))
|
||||
if (!_stricmp("linear", attStr))
|
||||
currentEmber.m_Interp = EMBER_INTERP_LINEAR;
|
||||
else if (!strcmp("smooth", attStr))
|
||||
else if (!_stricmp("smooth", attStr))
|
||||
currentEmber.m_Interp = EMBER_INTERP_SMOOTH;
|
||||
else
|
||||
m_ErrorReport.push_back(string(loc) + " : Unrecognized interpolation type " + string(attStr));
|
||||
}
|
||||
else if (!Compare(curAtt->name, "palette_interpolation"))
|
||||
{
|
||||
if (!strcmp("hsv", attStr))
|
||||
if (!_stricmp("hsv", attStr))
|
||||
currentEmber.m_PaletteInterp = INTERP_HSV;
|
||||
else if (!strcmp("sweep", attStr))
|
||||
else if (!_stricmp("sweep", attStr))
|
||||
currentEmber.m_PaletteInterp = INTERP_SWEEP;
|
||||
else
|
||||
m_ErrorReport.push_back(string(loc) + " : Unrecognized palette interpolation type " + string(attStr));
|
||||
}
|
||||
else if (!Compare(curAtt->name, "interpolation_space") || !Compare(curAtt->name, "interpolation_type"))
|
||||
{
|
||||
if (!strcmp("linear", attStr))
|
||||
if (!_stricmp("linear", attStr))
|
||||
currentEmber.m_AffineInterp = INTERP_LINEAR;
|
||||
else if (!strcmp("log", attStr))
|
||||
else if (!_stricmp("log", attStr))
|
||||
currentEmber.m_AffineInterp = INTERP_LOG;
|
||||
else if (!strcmp("old", attStr))
|
||||
else if (!_stricmp("old", attStr))
|
||||
currentEmber.m_AffineInterp = INTERP_COMPAT;
|
||||
else if (!strcmp("older", attStr))
|
||||
else if (!_stricmp("older", attStr))
|
||||
currentEmber.m_AffineInterp = INTERP_OLDER;
|
||||
else
|
||||
m_ErrorReport.push_back(string(loc) + " : Unrecognized interpolation type " + string(attStr));
|
||||
@ -551,9 +658,9 @@ private:
|
||||
}
|
||||
else if (!Compare(curAtt->name, "palette_mode"))
|
||||
{
|
||||
if (!strcmp("step", attStr))
|
||||
if (!_stricmp("step", attStr))
|
||||
currentEmber.m_PaletteMode = PALETTE_STEP;
|
||||
else if (!strcmp("linear", attStr))
|
||||
else if (!_stricmp("linear", attStr))
|
||||
currentEmber.m_PaletteMode = PALETTE_LINEAR;
|
||||
else
|
||||
{
|
||||
@ -750,9 +857,9 @@ private:
|
||||
{
|
||||
newFormat = true;
|
||||
|
||||
if (!strcmp(attStr, "RGB"))
|
||||
if (!_stricmp(attStr, "RGB"))
|
||||
numBytes = 3;
|
||||
else if (!strcmp(attStr, "RGBA"))
|
||||
else if (!_stricmp(attStr, "RGBA"))
|
||||
numBytes = 4;
|
||||
else
|
||||
{
|
||||
@ -898,6 +1005,9 @@ private:
|
||||
}
|
||||
}
|
||||
|
||||
//if (!newLinear)
|
||||
// currentEmber.Flatten(m_FlattenNames);
|
||||
|
||||
for (i = 0; i < currentEmber.XformCount(); i++)
|
||||
if (soloXform >= 0 && i != soloXform)
|
||||
currentEmber.GetXform(i)->m_Opacity = 0;//Will calc the cached adjusted viz value later.
|
||||
@ -963,11 +1073,11 @@ private:
|
||||
}
|
||||
else if (!Compare(curAtt->name, "motion_function"))
|
||||
{
|
||||
if (!strcmp("sin", attStr))
|
||||
if (!_stricmp("sin", attStr))
|
||||
xform.m_MotionFunc = MOTION_SIN;
|
||||
else if (!strcmp("triangle", attStr))
|
||||
else if (!_stricmp("triangle", attStr))
|
||||
xform.m_MotionFunc = MOTION_TRIANGLE;
|
||||
else if (!strcmp("hill", attStr))
|
||||
else if (!_stricmp("hill", attStr))
|
||||
xform.m_MotionFunc = MOTION_HILL;
|
||||
else
|
||||
{
|
||||
@ -1013,7 +1123,7 @@ private:
|
||||
{
|
||||
m_ErrorReport.push_back(string(loc) + " : Motion element cannot have a plotmode attribute");
|
||||
}
|
||||
else if (!strcmp("off", attStr))
|
||||
else if (!_stricmp("off", attStr))
|
||||
xform.m_Opacity = 0;
|
||||
}
|
||||
else if (!Compare(curAtt->name, "coefs"))
|
||||
@ -1048,7 +1158,7 @@ private:
|
||||
}
|
||||
else
|
||||
{
|
||||
string s = GetCorrectedName(m_BadVariationNames, (const char*)curAtt->name);
|
||||
string s = GetCorrectedVariationName(m_BadVariationNames, curAtt);
|
||||
const char* name = s.c_str();
|
||||
|
||||
if (Variation<T>* var = m_VariationList.GetVariation(s))
|
||||
@ -1130,7 +1240,7 @@ private:
|
||||
{
|
||||
for (curAtt = attPtr; curAtt; curAtt = curAtt->next)
|
||||
{
|
||||
string s = GetCorrectedName(m_BadParamNames, (const char*)curAtt->name);
|
||||
string s = GetCorrectedParamName(m_BadParamNames, (const char*)curAtt->name);
|
||||
const char* name = s.c_str();
|
||||
|
||||
if (parVar->ContainsParam(name))
|
||||
@ -1160,17 +1270,72 @@ private:
|
||||
/// Some Apophysis plugins use an inconsistent naming scheme for the parametric variation variables.
|
||||
/// This function identifies and converts them to Ember's consistent naming convention.
|
||||
/// </summary>
|
||||
/// <param name="ember">The name of the variable found in the Xml</param>
|
||||
/// <param name="vec">The vector of corrected names to search</param>
|
||||
/// <param name="att">The current Xml node to check</param>
|
||||
/// <returns>The corrected name if one was found, else the passed in name.</returns>
|
||||
static string GetCorrectedName(vector<pair<string, string>>& vec, const char* name)
|
||||
static string GetCorrectedParamName(vector<pair<string, string>>& vec, const char* name)
|
||||
{
|
||||
for (size_t i = 0; i < vec.size(); i++)
|
||||
if (!strcmp(vec[i].first.c_str(), name))//Case sensitive is intentional.
|
||||
{
|
||||
if (!_stricmp(vec[i].first.c_str(), name))
|
||||
return vec[i].second;
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Some Apophysis plugins use an inconsistent naming scheme for variation names.
|
||||
/// This function identifies and converts them to Ember's consistent naming convention.
|
||||
/// It uses some additional intelligence to ensure the variation is the expected one,
|
||||
/// by examining the rest of the xform for the existence of parameter names.
|
||||
/// </summary>
|
||||
/// <param name="vec">The vector of corrected names to search</param>
|
||||
/// <param name="att">The current Xml node to check</param>
|
||||
/// <returns>The corrected name if one was found, else the passed in name.</returns>
|
||||
static string GetCorrectedVariationName(vector<pair<pair<string, string>, vector<string>>>& vec, xmlAttrPtr att)
|
||||
{
|
||||
for (size_t i = 0; i < vec.size(); i++)
|
||||
{
|
||||
if (!_stricmp(vec[i].first.first.c_str(), (const char*)att->name))//Do case insensitive here.
|
||||
{
|
||||
if (!vec[i].second.empty())
|
||||
{
|
||||
for (size_t j = 0; j < vec[i].second.size(); j++)
|
||||
{
|
||||
if (XmlContainsTag(att, vec[i].second[j].c_str()))
|
||||
return vec[i].first.second;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return vec[i].first.second;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return string((const char*)att->name);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determine if an Xml node contains a given tag.
|
||||
/// </summary>
|
||||
/// <param name="att">The Xml node to search</param>
|
||||
/// <param name="name">The node name to search for</param>
|
||||
/// <returns>True if name was found, else false.</returns>
|
||||
static bool XmlContainsTag(xmlAttrPtr att, const char* name)
|
||||
{
|
||||
xmlAttrPtr temp = att;
|
||||
|
||||
do
|
||||
{
|
||||
if (!_stricmp(name, (const char*)temp->name))
|
||||
return true;
|
||||
} while (temp = temp->next);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Parse hexadecimal colors.
|
||||
/// This can read RGB and RGBA, however only RGB will be stored.
|
||||
@ -1331,10 +1496,12 @@ private:
|
||||
bool ParseAndAssignInt(const xmlChar* name, char* attStr, char* str, int& val, bool& b)
|
||||
{
|
||||
bool ret = false;
|
||||
T fval = 0;
|
||||
|
||||
if (!Compare(name, str))
|
||||
{
|
||||
b &= Atoi(attStr, val);
|
||||
b &= Atof(attStr, fval);
|
||||
val = (int)fval;
|
||||
ret = true;//Means the strcmp() was right, but doesn't necessarily mean the conversion went ok.
|
||||
}
|
||||
|
||||
@ -1343,7 +1510,7 @@ private:
|
||||
|
||||
static bool m_Init;
|
||||
static vector<pair<string, string>> m_BadParamNames;
|
||||
static vector<pair<string, string>> m_BadVariationNames;
|
||||
static vector<pair<pair<string, string>, vector<string>>> m_BadVariationNames;
|
||||
VariationList<T> m_VariationList;//The variation list used to make copies of variations to populate the embers with.
|
||||
PaletteList<T> m_PaletteList;
|
||||
};
|
||||
|
Reference in New Issue
Block a user