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:
mfeemster 2014-07-18 23:33:18 -07:00
parent 1884934b9d
commit e3b207c562
53 changed files with 1611 additions and 778 deletions

29
.gitignore vendored Normal file
View File

@ -0,0 +1,29 @@
*.user
*.opensdf
*.sdf
*.suo
*.obj
*.tlog
*.def
*.dll
*.manifest
*.exp
*.lastbuildstate
*.lib
*.log
*.map
*.pdb
*.cache
*.res
*.ipch
*.bsc
Builds/MSVC/VS2010/GeneratedFiles/Release/moc_AboutDialog.cpp
*.exe
*.xml
*.ilk
*.wixobj
*.pch
*.txt
*.msi
*.idb
*.flam3

View File

@ -579,7 +579,6 @@ Global
{C8096C47-E358-438C-A520-146D46B0637D}.Release|Mixed Platforms.Build.0 = Release|x86
{C8096C47-E358-438C-A520-146D46B0637D}.Release|Win32.ActiveCfg = Release|x86
{C8096C47-E358-438C-A520-146D46B0637D}.Release|x64.ActiveCfg = Release|x64
{C8096C47-E358-438C-A520-146D46B0637D}.Release|x64.Build.0 = Release|x64
{C8096C47-E358-438C-A520-146D46B0637D}.Release|x86.ActiveCfg = Release|x86
{C8096C47-E358-438C-A520-146D46B0637D}.Release|x86.Build.0 = Release|x86
{C8096C47-E358-438C-A520-146D46B0637D}.Release-MT|Mixed Platforms.ActiveCfg = Release|x86

View File

@ -952,6 +952,7 @@ xcopy /F /Y /R /D "$(SolutionDir)..\..\..\Data\flam3-palettes.xml" "$(OutDir)"</
<Outputs Condition="'$(Configuration)|$(Platform)'=='ReleaseNvidia|x64'">.\GeneratedFiles\qrc_%(Filename).cpp;%(Outputs)</Outputs>
<Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">"$(QTDIR)\bin\rcc.exe" -name "%(Filename)" -no-compress "%(FullPath)" -o .\GeneratedFiles\qrc_%(Filename).cpp</Command>
<Command Condition="'$(Configuration)|$(Platform)'=='ReleaseNvidia|x64'">"$(QTDIR)\bin\rcc.exe" -name "%(Filename)" -no-compress "%(FullPath)" -o .\GeneratedFiles\qrc_%(Filename).cpp</Command>
<SubType>Designer</SubType>
</CustomBuild>
</ItemGroup>
<ItemGroup>

View File

@ -6,7 +6,7 @@
<ProductVersion>3.7</ProductVersion>
<ProjectGuid>{c8096c47-e358-438c-a520-146d46b0637d}</ProjectGuid>
<SchemaVersion>2.0</SchemaVersion>
<OutputName>Fractorium_Beta_0.4.0.4</OutputName>
<OutputName>Fractorium_Beta_0.4.0.5</OutputName>
<OutputType>Package</OutputType>
<WixTargetsPath Condition=" '$(WixTargetsPath)' == '' AND '$(MSBuildExtensionsPath32)' != '' ">$(MSBuildExtensionsPath32)\Microsoft\WiX\v3.x\Wix.targets</WixTargetsPath>
<WixTargetsPath Condition=" '$(WixTargetsPath)' == '' ">$(MSBuildExtensionsPath)\Microsoft\WiX\v3.x\Wix.targets</WixTargetsPath>

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<?define ProductVersion="0.4.0.4" ?>
<?define ProductVersion="0.4.0.5" ?>
<?define ProductName="Fractorium Beta $(var.ProductVersion) ($(var.GpuType))" ?>
<?define UpgradeCode="{4714cd15-bfba-44f6-8059-9e1466ebfa6e}"?>
<?define Manufacturer="Fractorium"?>
@ -13,7 +13,7 @@
<!--
Change this for every release.
-->
<?define ProductCode="{E6D5252D-C1B0-4A95-B718-E099E39BE077}"?>
<?define ProductCode="{9059E2AE-AC08-44B1-93D5-AAAC258506E6}"?>
<Product Id="$(var.ProductCode)" Name="$(var.ProductName)" Language="1033" Version="$(var.ProductVersion)" Manufacturer="$(var.Manufacturer)" UpgradeCode="$(var.UpgradeCode)">
<Package

View File

@ -1,3 +1,23 @@
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.
0.4.0.1 Beta 07/06/2014
--Bug Fixes
Fix name collision of mobius and Mobius. The former is treated as mobius_strip.

View File

@ -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)

View File

@ -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;

View File

@ -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>

View File

@ -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;

View File

@ -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;

View File

@ -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.
{

View File

@ -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();

View File

@ -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>

View File

@ -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();
}

View File

@ -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

View File

@ -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)

View File

@ -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"

View File

@ -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"

View File

@ -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();

View File

@ -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:

View File

@ -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.

View File

@ -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;
};

View File

@ -49,8 +49,8 @@ END
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 0,4,0,4
PRODUCTVERSION 0,4,0,4
FILEVERSION 0,4,0,5
PRODUCTVERSION 0,4,0,5
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
@ -67,12 +67,12 @@ BEGIN
BEGIN
VALUE "CompanyName", "Open Source"
VALUE "FileDescription", "Renders fractal flames as animations with motion blur"
VALUE "FileVersion", "0.4.0.4"
VALUE "FileVersion", "0.4.0.5"
VALUE "InternalName", "EmberAnimate.rc"
VALUE "LegalCopyright", "Copyright (C) Matt Feemster 2013, GPL v3"
VALUE "OriginalFilename", "EmberAnimate.rc"
VALUE "ProductName", "Ember Animate"
VALUE "ProductVersion", "0.4.0.4"
VALUE "ProductVersion", "0.4.0.5"
END
END
BLOCK "VarFileInfo"

View File

@ -168,8 +168,8 @@ static const char* RandFunctionString =
"\n"
"inline real_t MwcNextNeg1Pos1(uint2* s)\n"
"{\n"
" real_t f = (real_t)MwcNext(s) / UINT_MAX;\n"
" return -1.0 + (f * (1.0 - (-1.0)));\n"
" real_t f = (real_t)MwcNext(s) / (real_t)UINT_MAX;\n"
" return -1.0 + (f * 2.0);\n"
"}\n"
"\n";
@ -266,7 +266,7 @@ static const char* InlineMathFunctionsString =
"\n"
"inline real_t Zeps(real_t x)\n"
"{\n"
" return x == 0.0 ? EPS6 : x;\n"
" return x == 0.0 ? EPS : x;\n"
"}\n"
"\n"
"inline real_t Lerp(real_t a, real_t b, real_t p)\n"

View File

@ -36,4 +36,5 @@
using namespace std;
using namespace EmberNs;
//#define TEST_CL 1
//#define TEST_CL 1
//#define TEST_CL_BUFFERS 1

View File

@ -35,21 +35,24 @@ static string ConstantDefinesString(bool doublePrecision)
<< "typedef long intPrec;\n"
<< "typedef ulong atomi;\n"
<< "typedef double real_t;\n"
<< "typedef double4 real4;\n";
<< "typedef double4 real4;\n"
<< "#define EPS (DBL_EPSILON)\n"
;
}
else
{
os << "typedef int intPrec;\n"
"typedef unsigned int atomi;\n"
"typedef float real_t;\n"
"typedef float4 real4;\n";
"typedef float4 real4;\n"
"#define EPS (FLT_EPSILON)\n"
;
}
os <<
"typedef long int int64;\n"
"typedef unsigned long int uint64;\n"
"\n"
"#define EPS ((1e-10))\n"//May need to change this, it might not be enough in some cases. Maybe try 1e-9 if things look funny when close to zero.
"#define EPS6 ((1e-6))\n"
"\n"
"//The number of threads per block used in the iteration function. Don't change\n"
@ -122,7 +125,7 @@ struct ALIGN PointCL
T m_Y;
T m_Z;
T m_ColorX;
T m_LastXfUsed;
unsigned int m_LastXfUsed;
};
/// <summary>
@ -188,7 +191,6 @@ static const char* XformCLStructString =
template <typename T>
struct ALIGN EmberCL
{
unsigned int m_FinalXformIndex;
XformCL<T> m_Xforms[MAX_CL_XFORM];
T m_CamZPos;
T m_CamPerspective;
@ -207,7 +209,6 @@ struct ALIGN EmberCL
static const char* EmberCLStructString =
"typedef struct __attribute__ " ALIGN_CL " _EmberCL\n"
"{\n"
" uint m_FinalXformIndex;\n"
" XformCL m_Xforms[" MAX_CL_XFORM_STRING "];\n"
" real_t m_CamZPos;\n"
" real_t m_CamPerspective;\n"

View File

@ -52,7 +52,7 @@ string IterOpenCLKernelCreator<T>::CreateIterKernelString(Ember<T>& ember, strin
xformFuncs << "\n" << parVarDefines << endl;
ember.GetPresentVariations(variations);
std::for_each(variations.begin(), variations.end(), [&](Variation<T>* var) { if (var) xformFuncs << var->OpenCLFuncsString(); });
ForEach(variations, [&](Variation<T>* var) { if (var) xformFuncs << var->OpenCLFuncsString(); });
for (i = 0; i < totalXformCount; i++)
{
@ -99,7 +99,7 @@ string IterOpenCLKernelCreator<T>::CreateIterKernelString(Ember<T>& ember, strin
if (needPrecalcAtanYX)
xformFuncs << "\treal_t precalcAtanyx;\n";
xformFuncs << "\treal_t tempColor = outPoint->m_ColorX = xform->m_ColorSpeedCache + (xform->m_OneMinusColorCache * inPoint->m_ColorX);\n";
xformFuncs << "\treal_t tempColor = outPoint->m_ColorX = xform->m_ColorSpeedCache + (xform->m_OneMinusColorCache * inPoint->m_ColorX);\n\n";
if (xform->PreVariationCount() + xform->VariationCount() == 0)
{
@ -145,8 +145,8 @@ string IterOpenCLKernelCreator<T>::CreateIterKernelString(Ember<T>& ember, strin
if (xform->NeedPrecalcAngles())
{
xformFuncs << "\tprecalcSina = transX / precalcSqrtSumSquares;\n";
xformFuncs << "\tprecalcCosa = transY / precalcSqrtSumSquares;\n";
xformFuncs << "\tprecalcSina = transX / Zeps(precalcSqrtSumSquares);\n";
xformFuncs << "\tprecalcCosa = transY / Zeps(precalcSqrtSumSquares);\n";
}
if (xform->NeedPrecalcAtanXY())
@ -268,9 +268,9 @@ string IterOpenCLKernelCreator<T>::CreateIterKernelString(Ember<T>& ember, strin
" __local Point swap[NTHREADS];\n"
" __local uint xfsel[NWARPS];\n"
"\n"
" unsigned int pointsIndex = INDEX_IN_GRID_2D;\n"
" mwc.x = (pointsIndex + 1 * seed) & 0x7FFFFFFF;\n"
" mwc.y = ((BLOCK_ID_X + 1) + (pointsIndex + 1) * seed) & 0x7FFFFFFF;\n"
" uint pointsIndex = INDEX_IN_GRID_2D;\n"
" mwc.x = (pointsIndex + 1 * seed);\n"
" mwc.y = ((BLOCK_ID_X + 1) * (pointsIndex + 1) * seed);\n"
" iPaletteCoord.y = 0;\n"
"\n"
" if (fuseCount > 0)\n"
@ -308,14 +308,18 @@ string IterOpenCLKernelCreator<T>::CreateIterKernelString(Ember<T>& ember, strin
"\n"
" do\n"
" {\n";
//If xaos is present, the cuburn method is effectively ceased. Every thread will be picking a random xform.
if (ember.XaosPresent())
{
os <<
" secondPoint.m_LastXfUsed = xformDistributions[xfsel[THREAD_ID_Y] + (" << CHOOSE_XFORM_GRAIN << " * (firstPoint.m_LastXfUsed + 1u))];\n\n";
" secondPoint.m_LastXfUsed = xformDistributions[MwcNext(&mwc) % " << CHOOSE_XFORM_GRAIN << " + (" << CHOOSE_XFORM_GRAIN << " * (firstPoint.m_LastXfUsed + 1u))];\n\n";
//" secondPoint.m_LastXfUsed = xformDistributions[xfsel[THREAD_ID_Y] + (" << CHOOSE_XFORM_GRAIN << " * (firstPoint.m_LastXfUsed + 1u))];\n\n";//Partial cuburn hybrid.
}
else
{
os <<
//" secondPoint.m_LastXfUsed = xformDistributions[MwcNext(&mwc) % " << CHOOSE_XFORM_GRAIN << "];\n\n";//For testing, using straight rand flam4/fractron style instead of cuburn.
" secondPoint.m_LastXfUsed = xformDistributions[xfsel[THREAD_ID_Y]];\n\n";
}
@ -391,12 +395,15 @@ string IterOpenCLKernelCreator<T>::CreateIterKernelString(Ember<T>& ember, strin
if (ember.UseFinalXform())
{
unsigned int finalIndex = ember.TotalXformCount() - 1;
//CPU takes an extra step here to preserve the opacity of the randomly selected xform, rather than the final xform's opacity.
//The same thing takes place here automatically because secondPoint.m_LastXfUsed is used below to retrieve the opacity when accumulating.
os <<
" if ((ember->m_Xforms[ember->m_FinalXformIndex].m_Opacity == 1) || (MwcNext01(&mwc) < ember->m_Xforms[ember->m_FinalXformIndex].m_Opacity))\n"
" if ((ember->m_Xforms[" << finalIndex << "].m_Opacity == 1) || (MwcNext01(&mwc) < ember->m_Xforms[" << finalIndex << "].m_Opacity))\n"
" {\n"
" Xform" << (ember.TotalXformCount() - 1) << "(&(ember->m_Xforms[ember->m_FinalXformIndex]), parVars, &secondPoint, &tempPoint, &mwc);\n"
" tempPoint.m_LastXfUsed = secondPoint.m_LastXfUsed;\n"
" Xform" << finalIndex << "(&(ember->m_Xforms[" << finalIndex << "]), parVars, &secondPoint, &tempPoint, &mwc);\n"
" secondPoint = tempPoint;\n"
" }\n"
"\n";
@ -511,7 +518,14 @@ string IterOpenCLKernelCreator<T>::CreateIterKernelString(Ember<T>& ember, strin
//At this point, iterating for this round is done, so write the final points back out
//to the global points buffer to be used as inputs for the next round. This preserves point trajectory
//between kernel calls.
#ifdef TEST_CL_BUFFERS//Use this to populate with test values and read back in EmberTester.
" points[pointsIndex].m_X = MwcNextNeg1Pos1(&mwc);\n"
" points[pointsIndex].m_Y = MwcNextNeg1Pos1(&mwc);\n"
" points[pointsIndex].m_Z = MwcNextNeg1Pos1(&mwc);\n"
" points[pointsIndex].m_ColorX = MwcNextNeg1Pos1(&mwc);\n"
#else
" points[pointsIndex] = firstPoint;\n"
#endif
" barrier(CLK_GLOBAL_MEM_FENCE);\n"
"}\n";
@ -562,7 +576,6 @@ void IterOpenCLKernelCreator<T>::ParVarIndexDefines(Ember<T>& ember, pair<string
{
unsigned int i, j, k, size = 0, xformCount = ember.TotalXformCount();
Xform<T>* xform;
ParametricVariation<T>* parVar;
ostringstream os;
if (doVals)
@ -576,7 +589,7 @@ void IterOpenCLKernelCreator<T>::ParVarIndexDefines(Ember<T>& ember, pair<string
for (j = 0; j < varCount; j++)
{
if (parVar = dynamic_cast<ParametricVariation<T>*>(xform->GetVariation(j)))
if (ParametricVariation<T>* parVar = dynamic_cast<ParametricVariation<T>*>(xform->GetVariation(j)))
{
for (k = 0; k < parVar->ParamCount(); k++)
{
@ -711,7 +724,7 @@ string IterOpenCLKernelCreator<T>::CreateProjectionString(Ember<T>& ember)
"\n"
" z = ember->m_C02 * secondPoint.m_X + ember->m_C12 * secondPoint.m_Y + ember->m_C22 * z;\n"
"\n"
" real_t zr = 1 - ember->m_CamPerspective * z;\n"
" real_t zr = Zeps(1 - ember->m_CamPerspective * z);\n"
" real_t dr = MwcNext01(&mwc) * ember->m_BlurCoef * z;\n"
"\n"
" dsin = sin(t);\n"
@ -731,7 +744,7 @@ string IterOpenCLKernelCreator<T>::CreateProjectionString(Ember<T>& ember)
" z = secondPoint.m_Z - ember->m_CamZPos;\n"
" y = ember->m_C11 * secondPoint.m_Y + ember->m_C21 * z;\n"
" z = ember->m_C12 * secondPoint.m_Y + ember->m_C22 * z;\n"
" zr = 1 - ember->m_CamPerspective * z;\n"
" zr = Zeps(1 - ember->m_CamPerspective * z);\n"
"\n"
" dsin = sin(t);\n"
" dcos = cos(t);\n"
@ -751,7 +764,7 @@ string IterOpenCLKernelCreator<T>::CreateProjectionString(Ember<T>& ember)
" real_t z = secondPoint.m_Z - ember->m_CamZPos;\n"
" real_t x = ember->m_C00 * secondPoint.m_X + ember->m_C10 * secondPoint.m_Y;\n"
" real_t y = ember->m_C01 * secondPoint.m_X + ember->m_C11 * secondPoint.m_Y + ember->m_C21 * z;\n"
" real_t zr = 1 - ember->m_CamPerspective * (ember->m_C02 * secondPoint.m_X + ember->m_C12 * secondPoint.m_Y + ember->m_C22 * z);\n"
" real_t zr = Zeps(1 - ember->m_CamPerspective * (ember->m_C02 * secondPoint.m_X + ember->m_C12 * secondPoint.m_Y + ember->m_C22 * z));\n"
"\n"
" secondPoint.m_X = x / zr;\n"
" secondPoint.m_Y = y / zr;\n"
@ -762,7 +775,7 @@ string IterOpenCLKernelCreator<T>::CreateProjectionString(Ember<T>& ember)
os <<
" real_t z = secondPoint.m_Z - ember->m_CamZPos;\n"
" real_t y = ember->m_C11 * secondPoint.m_Y + ember->m_C21 * z;\n"
" real_t zr = 1 - ember->m_CamPerspective * (ember->m_C12 * secondPoint.m_Y + ember->m_C22 * z);\n"
" real_t zr = Zeps(1 - ember->m_CamPerspective * (ember->m_C12 * secondPoint.m_Y + ember->m_C22 * z));\n"
"\n"
" secondPoint.m_X /= zr;\n"
" secondPoint.m_Y = y / zr;\n"
@ -772,7 +785,7 @@ string IterOpenCLKernelCreator<T>::CreateProjectionString(Ember<T>& ember)
else
{
os <<
" real_t zr = 1 - ember->m_CamPerspective * (secondPoint.m_Z - ember->m_CamZPos);\n"
" real_t zr = Zeps(1 - ember->m_CamPerspective * (secondPoint.m_Z - ember->m_CamZPos));\n"
"\n"
" secondPoint.m_X /= zr;\n"
" secondPoint.m_Y /= zr;\n"

View File

@ -1262,6 +1262,8 @@ bool OpenCLWrapper::CreateSPK(std::string& name, std::string& program, std::stri
err = spk.m_Program.build(m_DeviceVec, "-cl-mad-enable");//Tinker with other options later.
else
err = spk.m_Program.build(m_DeviceVec, "-cl-mad-enable -cl-no-signed-zeros -cl-single-precision-constant");
//err = spk.m_Program.build(m_DeviceVec, "-cl-single-precision-constant");
//err = spk.m_Program.build(m_DeviceVec, "-cl-mad-enable -cl-single-precision-constant");
//err = spk.m_Program.build(m_DeviceVec, "-cl-mad-enable -cl-no-signed-zeros -cl-fast-relaxed-math -cl-single-precision-constant");//This can cause some rounding.
//err = spk.m_Program.build(m_DeviceVec, "-cl-mad-enable -cl-single-precision-constant");

View File

@ -40,6 +40,7 @@ RendererCL<T>::RendererCL(unsigned int platform, unsigned int device, bool share
//based on the cuburn model of each kernel launch containing
//256 threads. 32 wide by 8 high. Everything done in the OpenCL
//iteraion kernel depends on these dimensions.
m_IterCountPerKernel = 256;
m_IterBlockWidth = 32;
m_IterBlockHeight = 8;
m_IterBlocksWide = 64;
@ -125,6 +126,7 @@ bool RendererCL<T>::Init(unsigned int platform, unsigned int device, bool shared
/// OpenCL property accessors, getters only.
/// </summary>
template <typename T> unsigned int RendererCL<T>::IterCountPerKernel() { return m_IterCountPerKernel; }
template <typename T> unsigned int RendererCL<T>::IterBlocksWide() { return m_IterBlocksWide; }
template <typename T> unsigned int RendererCL<T>::IterBlocksHigh() { return m_IterBlocksHigh; }
template <typename T> unsigned int RendererCL<T>::IterBlockWidth() { return m_IterBlockWidth; }
@ -322,7 +324,7 @@ void RendererCL<T>::ClearErrorReport()
template <typename T>
unsigned int RendererCL<T>::SubBatchSize() const
{
return m_IterBlocksWide * m_IterBlocksHigh * 256 * 256;
return m_IterBlocksWide * m_IterBlocksHigh * SQR(m_IterCountPerKernel);
}
/// <summary>
@ -614,7 +616,7 @@ EmberStats RendererCL<T>::Iterate(unsigned __int64 iterCount, unsigned int pass,
if (b)
{
if (m_ProcessState == ITER_STARTED)
if (m_Stats.m_Iters == 0)//Only reset the call count on the beginning of a new render. Do not reset on KEEP_ITERATING.
m_Calls = 0;
b = RunIter(iterCount, pass, temporalSample, stats.m_Iters);
@ -684,9 +686,10 @@ bool RendererCL<T>::RunIter(unsigned __int64 iterCount, unsigned int pass, unsig
Timing t;//, t2(4);
bool b = false;
unsigned int fuse, argIndex;
unsigned int iterCountPerKernel = 256;
unsigned int iterCountPerKernel = m_IterCountPerKernel;
unsigned int iterCountPerBlock = iterCountPerKernel * m_IterBlockWidth * m_IterBlockHeight;
unsigned int seed;
unsigned int fuseFreq = m_SubBatchSize / m_IterCountPerKernel;
unsigned __int64 itersRemaining, localIterCount = 0;
int kernelIndex = m_Wrapper.FindKernelIndex(m_IterOpenCLKernelCreator.IterEntryPoint());
double percent, etaMs;
@ -707,7 +710,7 @@ bool RendererCL<T>::RunIter(unsigned __int64 iterCount, unsigned int pass, unsig
if (!m_Wrapper.AddAndWriteBuffer(m_DistBufferName, (void*)XformDistributions(), XformDistributionsSize())) { m_ErrorReport.push_back(loc); return false; }//Will be resized for xaos.
if (!m_Wrapper.WriteBuffer (m_CarToRasBufferName, (void*)&m_CarToRasCL, sizeof(m_CarToRasCL))) { m_ErrorReport.push_back(loc); return false; }
if (!m_Wrapper.AddAndWriteImage("Palette", CL_MEM_READ_ONLY, m_PaletteFormat, 256, 1, 0, m_Dmap.m_Entries.data())) { m_ErrorReport.push_back(loc); return false; }
if (!m_Wrapper.AddAndWriteImage("Palette", CL_MEM_READ_ONLY, m_PaletteFormat, m_Dmap.m_Entries.size(), 1, 0, m_Dmap.m_Entries.data())) { m_ErrorReport.push_back(loc); return false; }
//If animating, treat each temporal sample as a newly started render for fusing purposes.
if (temporalSample > 0)
@ -718,11 +721,12 @@ bool RendererCL<T>::RunIter(unsigned __int64 iterCount, unsigned int pass, unsig
argIndex = 0;
seed = m_Rand[0].Rand();
#ifdef TEST_CL
fuse = false;
fuse = 0;
#else
fuse = ((m_Calls % 4) == 0 ? 100 : 0);
#endif
//fuse = 100;
fuse = ((m_Calls % fuseFreq) == 0 ? (EarlyClip() ? 100u : 15u) : 0u);
//fuse = ((m_Calls % 4) == 0 ? 100u : 0u);
#endif
itersRemaining = iterCount - itersRan;
unsigned int gridW = (unsigned int)min(ceil((double)itersRemaining / (double)iterCountPerBlock), (double)IterBlocksWide());
unsigned int gridH = (unsigned int)min(ceil((double)itersRemaining / ((double)gridW * iterCountPerBlock)), (double)IterBlocksHigh());
@ -736,17 +740,17 @@ bool RendererCL<T>::RunIter(unsigned __int64 iterCount, unsigned int pass, unsig
iterCountThisLaunch = iterCountPerKernel * (gridW * gridH * m_IterBlockWidth * m_IterBlockHeight);
}
if (!m_Wrapper.SetArg (kernelIndex, argIndex, iterCountPerKernel)) { m_ErrorReport.push_back(loc); return false; } argIndex++;//Number of iters for each thread to run.
if (!m_Wrapper.SetArg (kernelIndex, argIndex, fuse)) { m_ErrorReport.push_back(loc); return false; } argIndex++;//Number of iters to fuse.
if (!m_Wrapper.SetArg (kernelIndex, argIndex, seed)) { m_ErrorReport.push_back(loc); return false; } argIndex++;//Seed.
if (!m_Wrapper.SetBufferArg(kernelIndex, argIndex, m_EmberBufferName)) { m_ErrorReport.push_back(loc); return false; } argIndex++;//Flame.
if (!m_Wrapper.SetBufferArg(kernelIndex, argIndex, m_ParVarsBufferName)) { m_ErrorReport.push_back(loc); return false; } argIndex++;//Parametric variation parameters.
if (!m_Wrapper.SetBufferArg(kernelIndex, argIndex, m_DistBufferName)) { m_ErrorReport.push_back(loc); return false; } argIndex++;//Xform distributions.
if (!m_Wrapper.SetBufferArg(kernelIndex, argIndex, m_CarToRasBufferName)) { m_ErrorReport.push_back(loc); return false; } argIndex++;//Coordinate converter.
if (!m_Wrapper.SetBufferArg(kernelIndex, argIndex, m_HistBufferName)) { m_ErrorReport.push_back(loc); return false; } argIndex++;//Histogram.
if (!m_Wrapper.SetArg (kernelIndex, argIndex, SuperSize())) { m_ErrorReport.push_back(loc); return false; } argIndex++;//Histogram size.
if (!m_Wrapper.SetImageArg (kernelIndex, argIndex, false, "Palette")) { m_ErrorReport.push_back(loc); return false; } argIndex++;//Palette.
if (!m_Wrapper.SetBufferArg(kernelIndex, argIndex, m_PointsBufferName)) { m_ErrorReport.push_back(loc); return false; } argIndex++;//Random start points.
if (!m_Wrapper.SetArg (kernelIndex, argIndex++, iterCountPerKernel)) { m_ErrorReport.push_back(loc); return false; }//Number of iters for each thread to run.
if (!m_Wrapper.SetArg (kernelIndex, argIndex++, fuse)) { m_ErrorReport.push_back(loc); return false; }//Number of iters to fuse.
if (!m_Wrapper.SetArg (kernelIndex, argIndex++, seed)) { m_ErrorReport.push_back(loc); return false; }//Seed.
if (!m_Wrapper.SetBufferArg(kernelIndex, argIndex++, m_EmberBufferName)) { m_ErrorReport.push_back(loc); return false; }//Flame.
if (!m_Wrapper.SetBufferArg(kernelIndex, argIndex++, m_ParVarsBufferName)) { m_ErrorReport.push_back(loc); return false; }//Parametric variation parameters.
if (!m_Wrapper.SetBufferArg(kernelIndex, argIndex++, m_DistBufferName)) { m_ErrorReport.push_back(loc); return false; }//Xform distributions.
if (!m_Wrapper.SetBufferArg(kernelIndex, argIndex++, m_CarToRasBufferName)) { m_ErrorReport.push_back(loc); return false; }//Coordinate converter.
if (!m_Wrapper.SetBufferArg(kernelIndex, argIndex++, m_HistBufferName)) { m_ErrorReport.push_back(loc); return false; }//Histogram.
if (!m_Wrapper.SetArg (kernelIndex, argIndex++, SuperSize())) { m_ErrorReport.push_back(loc); return false; }//Histogram size.
if (!m_Wrapper.SetImageArg (kernelIndex, argIndex++, false, "Palette")) { m_ErrorReport.push_back(loc); return false; }//Palette.
if (!m_Wrapper.SetBufferArg(kernelIndex, argIndex++, m_PointsBufferName)) { m_ErrorReport.push_back(loc); return false; }//Random start points.
if (!m_Wrapper.RunKernel(kernelIndex,
gridW * IterBlockWidth(),//Total grid dims.
@ -837,9 +841,9 @@ eRenderStatus RendererCL<T>::RunLogScaleFilter()
if (!m_Wrapper.AddAndWriteBuffer(m_DEFilterParamsBufferName, (void*)&m_DensityFilterCL, sizeof(m_DensityFilterCL))) { m_ErrorReport.push_back(loc); return RENDER_ERROR; }
if (!m_Wrapper.SetBufferArg(kernelIndex, argIndex, m_HistBufferName)) { m_ErrorReport.push_back(loc); return RENDER_ERROR; } argIndex++;//Histogram.
if (!m_Wrapper.SetBufferArg(kernelIndex, argIndex, m_AccumBufferName)) { m_ErrorReport.push_back(loc); return RENDER_ERROR; } argIndex++;//Accumulator.
if (!m_Wrapper.SetBufferArg(kernelIndex, argIndex, m_DEFilterParamsBufferName)) { m_ErrorReport.push_back(loc); return RENDER_ERROR; } argIndex++;//DensityFilterCL.
if (!m_Wrapper.SetBufferArg(kernelIndex, argIndex++, m_HistBufferName)) { m_ErrorReport.push_back(loc); return RENDER_ERROR; }//Histogram.
if (!m_Wrapper.SetBufferArg(kernelIndex, argIndex++, m_AccumBufferName)) { m_ErrorReport.push_back(loc); return RENDER_ERROR; }//Accumulator.
if (!m_Wrapper.SetBufferArg(kernelIndex, argIndex++, m_DEFilterParamsBufferName)) { m_ErrorReport.push_back(loc); return RENDER_ERROR; }//DensityFilterCL.
//t.Tic();
if (!m_Wrapper.RunKernel(kernelIndex, gridW, gridH, 1, blockW, blockH, 1)) { m_ErrorReport.push_back(loc); return RENDER_ERROR; }
@ -981,8 +985,8 @@ eRenderStatus RendererCL<T>::RunFinalAccum()
gridH = m_SpatialFilterCL.m_SuperRasH;
OpenCLWrapper::MakeEvenGridDims(blockW, blockH, gridW, gridH);
if (!m_Wrapper.SetBufferArg(gammaCorrectKernelIndex, argIndex, m_AccumBufferName)) { m_ErrorReport.push_back(loc); return RENDER_ERROR; } argIndex++;//Accumulator.
if (!m_Wrapper.SetBufferArg(gammaCorrectKernelIndex, argIndex, m_SpatialFilterParamsBufferName)) { m_ErrorReport.push_back(loc); return RENDER_ERROR; } argIndex++;//SpatialFilterCL.
if (!m_Wrapper.SetBufferArg(gammaCorrectKernelIndex, argIndex++, m_AccumBufferName)) { m_ErrorReport.push_back(loc); return RENDER_ERROR; }//Accumulator.
if (!m_Wrapper.SetBufferArg(gammaCorrectKernelIndex, argIndex++, m_SpatialFilterParamsBufferName)) { m_ErrorReport.push_back(loc); return RENDER_ERROR; }//SpatialFilterCL.
if (!m_Wrapper.RunKernel(gammaCorrectKernelIndex, gridW, gridH, 1, blockW, blockH, 1)) { m_ErrorReport.push_back(loc); return RENDER_ERROR; }
}
@ -1000,12 +1004,12 @@ eRenderStatus RendererCL<T>::RunFinalAccum()
gridH = m_SpatialFilterCL.m_FinalRasH;
OpenCLWrapper::MakeEvenGridDims(blockW, blockH, gridW, gridH);
if (!m_Wrapper.SetBufferArg(accumKernelIndex, argIndex, m_AccumBufferName)) { m_ErrorReport.push_back(loc); return RENDER_ERROR; } argIndex++;//Accumulator.
if (!m_Wrapper.SetImageArg(accumKernelIndex, argIndex, m_Wrapper.Shared(), m_FinalImageName)) { m_ErrorReport.push_back(loc); return RENDER_ERROR; } argIndex++;//Final image.
if (!m_Wrapper.SetBufferArg(accumKernelIndex, argIndex, m_SpatialFilterParamsBufferName)) { m_ErrorReport.push_back(loc); return RENDER_ERROR; } argIndex++;//SpatialFilterCL.
if (!m_Wrapper.SetBufferArg(accumKernelIndex, argIndex, m_SpatialFilterCoefsBufferName)) { m_ErrorReport.push_back(loc); return RENDER_ERROR; } argIndex++;//Filter coefs.
if (!m_Wrapper.SetArg(accumKernelIndex, argIndex, alphaBase)) { m_ErrorReport.push_back(loc); return RENDER_ERROR; } argIndex++;//Alpha base.
if (!m_Wrapper.SetArg(accumKernelIndex, argIndex, alphaScale)) { m_ErrorReport.push_back(loc); return RENDER_ERROR; } argIndex++;//Alpha scale.
if (!m_Wrapper.SetBufferArg(accumKernelIndex, argIndex++, m_AccumBufferName)) { m_ErrorReport.push_back(loc); return RENDER_ERROR; }//Accumulator.
if (!m_Wrapper.SetImageArg(accumKernelIndex, argIndex++, m_Wrapper.Shared(), m_FinalImageName)) { m_ErrorReport.push_back(loc); return RENDER_ERROR; }//Final image.
if (!m_Wrapper.SetBufferArg(accumKernelIndex, argIndex++, m_SpatialFilterParamsBufferName)) { m_ErrorReport.push_back(loc); return RENDER_ERROR; }//SpatialFilterCL.
if (!m_Wrapper.SetBufferArg(accumKernelIndex, argIndex++, m_SpatialFilterCoefsBufferName)) { m_ErrorReport.push_back(loc); return RENDER_ERROR; }//Filter coefs.
if (!m_Wrapper.SetArg (accumKernelIndex, argIndex++, alphaBase)) { m_ErrorReport.push_back(loc); return RENDER_ERROR; }//Alpha base.
if (!m_Wrapper.SetArg (accumKernelIndex, argIndex++, alphaScale)) { m_ErrorReport.push_back(loc); return RENDER_ERROR; }//Alpha scale.
if (m_Wrapper.Shared())
if (!m_Wrapper.EnqueueAcquireGLObjects(m_FinalImageName)) { m_ErrorReport.push_back(loc); return RENDER_ERROR; }
@ -1050,9 +1054,9 @@ bool RendererCL<T>::ClearBuffer(string bufferName, unsigned int width, unsigned
OpenCLWrapper::MakeEvenGridDims(blockW, blockH, gridW, gridH);
if (!m_Wrapper.SetBufferArg(kernelIndex, argIndex, bufferName)) { m_ErrorReport.push_back(loc); return false; } argIndex++;//Buffer of unsigned char.
if (!m_Wrapper.SetArg (kernelIndex, argIndex, width * elementSize)) { m_ErrorReport.push_back(loc); return false; } argIndex++;//Width.
if (!m_Wrapper.SetArg (kernelIndex, argIndex, height)) { m_ErrorReport.push_back(loc); return false; } argIndex++;//Height.
if (!m_Wrapper.SetBufferArg(kernelIndex, argIndex++, bufferName)) { m_ErrorReport.push_back(loc); return false; }//Buffer of unsigned char.
if (!m_Wrapper.SetArg (kernelIndex, argIndex++, width * elementSize)) { m_ErrorReport.push_back(loc); return false; }//Width.
if (!m_Wrapper.SetArg (kernelIndex, argIndex++, height)) { m_ErrorReport.push_back(loc); return false; }//Height.
if (!m_Wrapper.RunKernel(kernelIndex, gridW, gridH, 1, blockW, blockH, 1)) { m_ErrorReport.push_back(loc); return false; }
return true;
@ -1281,7 +1285,6 @@ EmberCL<T> RendererCL<T>::ConvertEmber(Ember<T>& ember)
emberCL.m_CamPitch = ember.m_CamPitch;
emberCL.m_CamDepthBlur = ember.m_CamDepthBlur;
emberCL.m_BlurCoef = ember.BlurCoef();
emberCL.m_FinalXformIndex = ember.UseFinalXform() ? ember.TotalXformCount() - 1 : -1;
for (unsigned int i = 0; i < ember.TotalXformCount() && i < MAX_CL_XFORM; i++)//Copy the relevant values for each xform, capped at the max.
{

View File

@ -38,6 +38,7 @@ public:
//Ordinary member functions for OpenCL specific tasks.
bool Init(unsigned int platform, unsigned int device, bool shared, GLuint outputTexID);
inline unsigned int IterCountPerKernel();
inline unsigned int IterBlocksWide();
inline unsigned int IterBlocksHigh();
inline unsigned int IterBlockWidth();
@ -106,6 +107,7 @@ private:
bool m_Init;
bool m_NVidia;
bool m_DoublePrecision;
unsigned int m_IterCountPerKernel;
unsigned int m_IterBlocksWide, m_IterBlockWidth;
unsigned int m_IterBlocksHigh, m_IterBlockHeight;
unsigned int m_MaxDEBlockSizeW;

View File

@ -41,7 +41,7 @@ public:
if (m_LastStage != stage)
cout << endl;
cout << "\r" << string(m_S.length(), ' ');//Clear what was previously here.
cout << "\r" << string(m_S.length() * 2, ' ');//Clear what was previously here, * 2 just to be safe because the end parts of previous strings might be longer.
m_SS.str("");//Begin new output.
m_SS << "\rStage = " << (stage ? "filtering" : "chaos");
m_SS << ", progress = " << int(fraction) << "%";

View File

@ -302,7 +302,7 @@ public:
INITUINTOPTION(ThreadCount, Eou(OPT_USE_ALL, OPT_NTHREADS, _T("--nthreads"), 0, SO_REQ_SEP, "\t--nthreads=<val> The number of threads to use [default: use all available cores].\n"));
INITUINTOPTION(Strips, Eou(OPT_USE_RENDER, OPT_STRIPS, _T("--nstrips"), 1, SO_REQ_SEP, "\t--nstrips=<val> The number of fractions to split a single render frame into. Useful for print size renders or low memory systems [default: 1].\n"));
INITUINTOPTION(BitsPerChannel, Eou(OPT_RENDER_ANIM, OPT_BPC, _T("--bpc"), 8, SO_REQ_SEP, "\t--bpc=<val> Bits per channel. 8 or 16 for PNG, 8 for all others [default: 8].\n"));
INITUINTOPTION(SubBatchSize, Eou(OPT_USE_ALL, OPT_SBS, _T("--sub_batch_size"), 10000, SO_REQ_SEP, "\t--sub_batch_size=<val> The chunk size that iterating will be broken into [default: 10000].\n"));
INITUINTOPTION(SubBatchSize, Eou(OPT_USE_ALL, OPT_SBS, _T("--sub_batch_size"), 10240, SO_REQ_SEP, "\t--sub_batch_size=<val> The chunk size that iterating will be broken into [default: 10k].\n"));
INITUINTOPTION(Bits, Eou(OPT_USE_ALL, OPT_BITS, _T("--bits"), 33, SO_REQ_SEP, "\t--bits=<val> Determines the types used for the histogram and accumulator [default: 33].\n"
"\t\t\t\t\t32: Histogram: float, Accumulator: float.\n"
"\t\t\t\t\t33: Histogram: float, Accumulator: float.\n"//This differs from the original which used an int hist for bits 33.
@ -510,11 +510,11 @@ public:
CSimpleOpt::SOption endOption = SO_END_OF_OPTIONS;
entries.reserve(75);
std::for_each(m_BoolArgs.begin(), m_BoolArgs.end(), [&](Eob* entry) { if (entry->m_OptionUse & optUsage) entries.push_back(entry->m_Option); });
std::for_each(m_IntArgs.begin(), m_IntArgs.end(), [&](Eoi* entry) { if (entry->m_OptionUse & optUsage) entries.push_back(entry->m_Option); });
std::for_each(m_UintArgs.begin(), m_UintArgs.end(), [&](Eou* entry) { if (entry->m_OptionUse & optUsage) entries.push_back(entry->m_Option); });
std::for_each(m_DoubleArgs.begin(), m_DoubleArgs.end(), [&](Eod* entry) { if (entry->m_OptionUse & optUsage) entries.push_back(entry->m_Option); });
std::for_each(m_StringArgs.begin(), m_StringArgs.end(), [&](Eos* entry) { if (entry->m_OptionUse & optUsage) entries.push_back(entry->m_Option); });
ForEach(m_BoolArgs, [&](Eob* entry) { if (entry->m_OptionUse & optUsage) entries.push_back(entry->m_Option); });
ForEach(m_IntArgs, [&](Eoi* entry) { if (entry->m_OptionUse & optUsage) entries.push_back(entry->m_Option); });
ForEach(m_UintArgs, [&](Eou* entry) { if (entry->m_OptionUse & optUsage) entries.push_back(entry->m_Option); });
ForEach(m_DoubleArgs, [&](Eod* entry) { if (entry->m_OptionUse & optUsage) entries.push_back(entry->m_Option); });
ForEach(m_StringArgs, [&](Eos* entry) { if (entry->m_OptionUse & optUsage) entries.push_back(entry->m_Option); });
entries.push_back(endOption);
return entries;
@ -529,11 +529,11 @@ public:
{
ostringstream os;
std::for_each(m_BoolArgs.begin(), m_BoolArgs.end(), [&](Eob* entry) { if (entry->m_OptionUse & optUsage) os << entry->m_DocString << endl; });
std::for_each(m_IntArgs.begin(), m_IntArgs.end(), [&](Eoi* entry) { if (entry->m_OptionUse & optUsage) os << entry->m_DocString << endl; });
std::for_each(m_UintArgs.begin(), m_UintArgs.end(), [&](Eou* entry) { if (entry->m_OptionUse & optUsage) os << entry->m_DocString << endl; });
std::for_each(m_DoubleArgs.begin(), m_DoubleArgs.end(), [&](Eod* entry) { if (entry->m_OptionUse & optUsage) os << entry->m_DocString << endl; });
std::for_each(m_StringArgs.begin(), m_StringArgs.end(), [&](Eos* entry) { if (entry->m_OptionUse & optUsage) os << entry->m_DocString << endl; });
ForEach(m_BoolArgs, [&](Eob* entry) { if (entry->m_OptionUse & optUsage) os << entry->m_DocString << endl; });
ForEach(m_IntArgs, [&](Eoi* entry) { if (entry->m_OptionUse & optUsage) os << entry->m_DocString << endl; });
ForEach(m_UintArgs, [&](Eou* entry) { if (entry->m_OptionUse & optUsage) os << entry->m_DocString << endl; });
ForEach(m_DoubleArgs, [&](Eod* entry) { if (entry->m_OptionUse & optUsage) os << entry->m_DocString << endl; });
ForEach(m_StringArgs, [&](Eos* entry) { if (entry->m_OptionUse & optUsage) os << entry->m_DocString << endl; });
return os.str();
}
@ -548,11 +548,11 @@ public:
ostringstream os;
os << std::boolalpha;
std::for_each(m_BoolArgs.begin(), m_BoolArgs.end(), [&](Eob* entry) { if (entry->m_OptionUse & optUsage) os << entry->m_NameWithoutDashes << ": " << (*entry)() << endl; });
std::for_each(m_IntArgs.begin(), m_IntArgs.end(), [&](Eoi* entry) { if (entry->m_OptionUse & optUsage) os << entry->m_NameWithoutDashes << ": " << (*entry)() << endl; });
std::for_each(m_UintArgs.begin(), m_UintArgs.end(), [&](Eou* entry) { if (entry->m_OptionUse & optUsage) os << entry->m_NameWithoutDashes << ": " << (*entry)() << endl; });
std::for_each(m_DoubleArgs.begin(), m_DoubleArgs.end(), [&](Eod* entry) { if (entry->m_OptionUse & optUsage) os << entry->m_NameWithoutDashes << ": " << (*entry)() << endl; });
std::for_each(m_StringArgs.begin(), m_StringArgs.end(), [&](Eos* entry) { if (entry->m_OptionUse & optUsage) os << entry->m_NameWithoutDashes << ": " << (*entry)() << endl; });
ForEach(m_BoolArgs, [&](Eob* entry) { if (entry->m_OptionUse & optUsage) os << entry->m_NameWithoutDashes << ": " << (*entry)() << endl; });
ForEach(m_IntArgs, [&](Eoi* entry) { if (entry->m_OptionUse & optUsage) os << entry->m_NameWithoutDashes << ": " << (*entry)() << endl; });
ForEach(m_UintArgs, [&](Eou* entry) { if (entry->m_OptionUse & optUsage) os << entry->m_NameWithoutDashes << ": " << (*entry)() << endl; });
ForEach(m_DoubleArgs, [&](Eod* entry) { if (entry->m_OptionUse & optUsage) os << entry->m_NameWithoutDashes << ": " << (*entry)() << endl; });
ForEach(m_StringArgs, [&](Eos* entry) { if (entry->m_OptionUse & optUsage) os << entry->m_NameWithoutDashes << ": " << (*entry)() << endl; });
return os.str();
}

View File

@ -49,8 +49,8 @@ END
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 0,4,0,4
PRODUCTVERSION 0,4,0,4
FILEVERSION 0,4,0,5
PRODUCTVERSION 0,4,0,5
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
@ -67,12 +67,12 @@ BEGIN
BEGIN
VALUE "CompanyName", "Open Source"
VALUE "FileDescription", "Manipulates fractal flames parameter files"
VALUE "FileVersion", "0.4.0.4"
VALUE "FileVersion", "0.4.0.5"
VALUE "InternalName", "EmberGenome.rc"
VALUE "LegalCopyright", "Copyright (C) Matt Feemster 2013, GPL v3"
VALUE "OriginalFilename", "EmberGenome.rc"
VALUE "ProductName", "Ember Genome"
VALUE "ProductVersion", "0.4.0.4"
VALUE "ProductVersion", "0.4.0.5"
END
END
BLOCK "VarFileInfo"

View File

@ -157,7 +157,7 @@ bool EmberRender(EmberOptions& opt)
if (opt.Verbose() && embers.size() > 1)
cout << "\nFlame = " << i + 1 << "/" << embers.size() << endl;
else
cout << endl;
VerbosePrint(endl);
embers[i].m_TemporalSamples = 1;//Force temporal samples to 1 for render.
embers[i].m_Quality *= T(opt.QualityScale());

View File

@ -49,8 +49,8 @@ END
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 0,4,0,4
PRODUCTVERSION 0,4,0,4
FILEVERSION 0,4,0,5
PRODUCTVERSION 0,4,0,5
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
@ -67,12 +67,12 @@ BEGIN
BEGIN
VALUE "CompanyName", "Open Source"
VALUE "FileDescription", "Renders fractal flames as single images"
VALUE "FileVersion", "0.4.0.4"
VALUE "FileVersion", "0.4.0.5"
VALUE "InternalName", "EmberRender.rc"
VALUE "LegalCopyright", "Copyright (C) Matt Feemster 2013, GPL v3"
VALUE "OriginalFilename", "EmberRender.rc"
VALUE "ProductName", "Ember Render"
VALUE "ProductVersion", "0.4.0.4"
VALUE "ProductVersion", "0.4.0.5"
END
END
BLOCK "VarFileInfo"

View File

@ -1028,7 +1028,7 @@ bool TestVarAssignVals()
{
bool success = true;
VariationList<float> vlf;
vector<string> xout, yout;
vector<string> xout, yout, zout;
xout.push_back("vOut.x =");
xout.push_back("vOut.x +=");
@ -1041,6 +1041,12 @@ bool TestVarAssignVals()
yout.push_back("vOut.y -=");
yout.push_back("vOut.y *=");
yout.push_back("vOut.y /=");
zout.push_back("vOut.z =");
zout.push_back("vOut.z +=");
zout.push_back("vOut.z -=");
zout.push_back("vOut.z *=");
zout.push_back("vOut.z /=");
for (size_t i = 0; i < vlf.Size(); i++)
{
@ -1057,6 +1063,12 @@ bool TestVarAssignVals()
cout << "Variation " << var->Name() << " did not set its y output point. If unused, at least pass through or set to 0." << endl;
success = false;
}
if (!SearchVar(var, zout, false))
{
cout << "Variation " << var->Name() << " did not set its z output point. If unused, at least pass through or set to 0." << endl;
success = false;
}
}
return success;
@ -1278,7 +1290,7 @@ void TestVarTime()
}
std::sort(times.begin(), times.end(), &SortPairByTime);
//std::for_each(times.begin(), times.end(), [&](pair<string, double>& p) { cout << p.first << "\t" << p.second << "" << endl; });
//ForEach(times, [&](pair<string, double>& p) { cout << p.first << "\t" << p.second << "" << endl; });
}
template <typename T>
@ -1384,13 +1396,13 @@ void TestVarsSimilar()
if (parVar)
{
for (unsigned int v = 0; v < parVar->ParamCount(); v++)
parVar->SetParamVal(v, iter);
parVar->SetParamVal(v, (T)iter);
}
if (parVarComp)
{
for (unsigned int v = 0; v < parVarComp->ParamCount(); v++)
parVarComp->SetParamVal(v, iter);
parVarComp->SetParamVal(v, (T)iter);
}
//For debugging.
@ -1400,13 +1412,13 @@ void TestVarsSimilar()
}
helper.Out = v4T(0);
var->m_Weight = iter + 1;
var->m_Weight = T(iter + 1);
var->Precalc();
var->Func(helper, p, rand);
v4T varOut = helper.Out;
helper.Out = v4T(0);
varComp->m_Weight = iter + 1;
varComp->m_Weight = T(iter + 1);
varComp->Precalc();
varComp->Func(helper, pComp, rand);
v4T varCompOut = helper.Out;
@ -1437,6 +1449,7 @@ void TestVarsSimilar()
//std::sort(times.begin(), times.end(), &SortPairByTime);
}
#ifdef TEST_CL
template <typename T>
void TestCpuGpuResults()
{
@ -1537,9 +1550,179 @@ void TestCpuGpuResults()
cout << "Skipped " << skipped << endl;
}
template <typename T>
void TestGpuVectorRead()
{
T minx = TMAX, miny = TMAX, minz = TMAX, mincolorx = TMAX;
T maxx = TLOW, maxy = TLOW, maxz = TLOW, maxcolorx = TLOW;
double sumx = 0, avgx = 0;
double sumy = 0, avgy = 0;
double sumz = 0, avgz = 0;
double sumcolorx = 0, avgcolorx = 0;
Timing t;
VariationList<T> vlf;
QTIsaac<ISAAC_SIZE, ISAAC_INT> rand;
vector<PointCL<T>> points;
RendererCL<T> renderer;
if (!renderer.Init(1, 0, false, 0))
return;
points.resize(renderer.TotalIterKernelCount());
Variation<T>* var = vlf.GetVariation(VAR_LINEAR);
bool newAlloc = false;
Point<T> p, p2;
Ember<T> ember;
Xform<T> xform;
Variation<T>* varCopy = var->Copy();
p.m_X = rand.Frand<T>(-5, 5);
p.m_Y = rand.Frand<T>(-5, 5);
p.m_Z = rand.Frand<T>(-5, 5);
p.m_ColorX = rand.Frand01<T>();
p.m_VizAdjusted = rand.Frand01<T>();
varCopy->Random(rand);
xform.AddVariation(varCopy);
ember.AddXform(xform);
ember.CacheXforms();
renderer.SetEmber(ember);
renderer.CreateSpatialFilter(newAlloc);
renderer.CreateDEFilter(newAlloc);
renderer.ComputeBounds();
renderer.ComputeCamera();
renderer.AssignIterator();
if (!renderer.Alloc())
return;
unsigned int i, iters = renderer.IterCountPerKernel() * renderer.TotalIterKernelCount();//Make each thread in each block run at least once.
renderer.Iterate(iters, 0, 1);
renderer.ReadPoints(points);
cout << __FUNCTION__ << ": GPU point test value results:" << endl;
for (i = 0; i < points.size(); i++)
{
cout << "point[" << i << "].m_X = " << points[i].m_X << endl;
cout << "point[" << i << "].m_Y = " << points[i].m_Y << endl;
cout << "point[" << i << "].m_Z = " << points[i].m_Z << endl;
cout << "point[" << i << "].m_ColorX = " << points[i].m_ColorX << endl << endl;
minx = min<T>(points[i].m_X, minx);
miny = min<T>(points[i].m_Y, miny);
minz = min<T>(points[i].m_Z, minz);
mincolorx = min<T>(points[i].m_ColorX, mincolorx);
maxx = max<T>(points[i].m_X, maxx);
maxy = max<T>(points[i].m_Y, maxy);
maxz = max<T>(points[i].m_Z, maxz);
maxcolorx = max<T>(points[i].m_ColorX, maxcolorx);
sumx += points[i].m_X;
sumy += points[i].m_Y;
sumz += points[i].m_Z;
sumcolorx += points[i].m_ColorX;
}
avgx = sumx / i;
avgy = sumy / i;
avgz = sumz / i;
avgcolorx = sumcolorx / i;
cout << "avgx = " << avgx << endl;
cout << "avgy = " << avgy << endl;
cout << "avgz = " << avgz << endl;
cout << "avgcolorx = " << avgcolorx << endl;
cout << "minx = " << minx << endl;
cout << "miny = " << miny << endl;
cout << "minz = " << minz << endl;
cout << "mincolorx = " << mincolorx << endl << endl;
cout << "maxx = " << maxx << endl;
cout << "maxy = " << maxy << endl;
cout << "maxz = " << maxz << endl;
cout << "maxcolorx = " << maxcolorx << endl << endl << endl;
}
#endif
template <typename T>
void TestRandomAccess(size_t vsize, size_t ipp, bool cache)
{
size_t iters = vsize * ipp;
vector<v4T> vec;
QTIsaac<ISAAC_SIZE, ISAAC_INT> rand;
vec.resize(vsize);
v4T* vdata = vec.data();
if (cache)
{
for (size_t i = 0; i < iters; i++)
{
v4T v4(rand.Frand11<T>(), rand.Frand11<T>(), rand.Frand11<T>(), rand.Frand11<T>());
int index = rand.Rand((ISAAC_INT)vsize);
v4T v42 = vdata[index];
v4.x = log(v4.x);
v4.y = sqrt(v4.y);
v4.z = sin(v4.z);
v4.w = cos(v4.w);
v4 += T(1.234);
v4 *= T(55.55);
v4 /= T(0.0045);
vdata[index] = v4 + v42;
}
}
else
{
for (size_t i = 0; i < iters; i++)
{
v4T v4(rand.Frand11<T>(), rand.Frand11<T>(), rand.Frand11<T>(), rand.Frand11<T>());
int index = rand.Rand((ISAAC_INT)vsize);
v4.x = log(v4.x);
v4.y = sqrt(v4.y);
v4.z = sin(v4.z);
v4.w = cos(v4.w);
v4 += T(1.234);
v4 *= T(55.55);
v4 /= T(0.0045);
vdata[index] += v4;
}
}
}
template <typename T>
void TestCross(T x, T y, T weight)
{
T s = x * x - y * y;
T r = weight * sqrt(1 / (s * s + EPS));
T outX = x * r;
T outY = y * r;
cout << "First way, outX, outY == " << outX << ", " << outY << endl;
r = fabs((x - y) * (x + y) + EPS);
if (r < 0)
r = -r;
r = weight / r;
outX = x * r;
outY = y * r;
cout << "Second way, outX, outY == " << outX << ", " << outY << endl;
}
int _tmain(int argc, _TCHAR* argv[])
{
Timing t(4);
QTIsaac<ISAAC_SIZE, ISAAC_INT> rand;
//cout << pow(-1, 5.1) << endl;
@ -1560,9 +1743,40 @@ int _tmain(int argc, _TCHAR* argv[])
cout << preLinV->BaseName() << endl;
cout << postLinV->BaseName() << endl;*/
//auto_ptr<PreFarblurVariation<float>> preFarblurV(new PreFarblurVariation<float>());
//float num = 1;
//float denom = 4294967296.0f;
//float frac = num / denom;
//
//cout << "num, denom, frac = " << num << ", " << denom << ", " << frac << endl;
//TestGpuVectorRead<double>();
//TestGpuVectorRead<float>();
//return 0;
//auto_ptr<PreFarblurVariation<float>> preFarblurV(new PreFarblurVariation<float>());
//size_t vsize = 1024 * 1024;
//
//t.Tic();
//TestRandomAccess<float>(vsize, 10, true);
//t.Toc("TestRandomAccess<float>(true)");
//
//t.Tic();
//TestRandomAccess<float>(vsize, 10, false);
//t.Toc("TestRandomAccess<float>(false)");
//
//t.Tic();
//TestRandomAccess<double>(vsize, 10, true);
//t.Toc("TestRandomAccess<double>(true)");
//
//t.Tic();
//TestRandomAccess<double>(vsize, 10, false);
//t.Toc("TestRandomAccess<double>(false)");
//TestCross<double>(rand.Frand<double>(-5, 5), rand.Frand<double>(-5, 5), rand.Frand<double>(-5, 5));
//TestCross<double>(rand.Frand<double>(-5, 5), rand.Frand<double>(-5, 5), rand.Frand<double>(-5, 5));
//TestCross<double>(rand.Frand<double>(-5, 5), rand.Frand<double>(-5, 5), rand.Frand<double>(-5, 5));
//TestCross<double>(rand.Frand<double>(-5, 5), rand.Frand<double>(-5, 5), rand.Frand<double>(-5, 5));
//TestCross<double>(rand.Frand<double>(-5, 5), rand.Frand<double>(-5, 5), rand.Frand<double>(-5, 5));
//MakeTestAllVarsRegPrePostComboFile("testallvarsout.flame");
//return 0;
//std::complex<double> cd, cd2;
@ -1611,58 +1825,60 @@ int _tmain(int argc, _TCHAR* argv[])
TestVarCopy<double, float>();
t.Toc("TestVarCopy<double, float>()");
#endif
//t.Tic();
//TestVarRegPrePost();
//t.Toc("TestVarRegPrePost()");
//
//t.Tic();
//TestParVars();
//t.Toc("TestParVars()");
//
//t.Tic();
//TestVarPrePostNames();
//t.Toc("TestVarPrePostNames()");
//
//t.Tic();
//TestVarPrecalcUsedCL();
//t.Toc("TestVarPrecalcUsedCL()");
//
//t.Tic();
//TestVarAssignTypes();
//t.Toc("TestVarAssignTypes()");
//
//t.Tic();
//TestVarAssignVals();
//t.Toc("TestVarAssignVals()");
//
//t.Tic();
//TestConstants();
//t.Toc("TestConstants()");
//
//t.Tic();
//TestXformsInOutPoints();
//t.Toc("TestXformsInOutPoints()");
//
//t.Tic();
//TestVarTime<float>();
//t.Toc("TestVarTime()");
//
//t.Tic();
//TestOperations<float>();
//t.Toc("TestMod()");
t.Tic();
TestVarRegPrePost();
t.Toc("TestVarRegPrePost()");
t.Tic();
TestParVars();
t.Toc("TestParVars()");
t.Tic();
TestVarPrePostNames();
t.Toc("TestVarPrePostNames()");
t.Tic();
TestVarPrecalcUsedCL();
t.Toc("TestVarPrecalcUsedCL()");
t.Tic();
TestVarAssignTypes();
t.Toc("TestVarAssignTypes()");
t.Tic();
TestVarAssignVals();
t.Toc("TestVarAssignVals()");
t.Tic();
TestConstants();
t.Toc("TestConstants()");
t.Tic();
TestXformsInOutPoints();
t.Toc("TestXformsInOutPoints()");
t.Tic();
TestVarTime<float>();
t.Toc("TestVarTime()");
t.Tic();
TestOperations<float>();
t.Toc("TestOperations()");
//t.Tic();
//TestVarsSimilar<float>();
//t.Toc("TestVarsSimilar()");
/**/t.Tic();
TestCpuGpuResults<float>();
t.Toc("TestCpuGpuResults<float>()");
#ifdef TEST_CL
//t.Tic();
//TestCpuGpuResults<float>();
//t.Toc("TestCpuGpuResults<float>()");
#ifdef DO_DOUBLE
t.Tic();
TestCpuGpuResults<double>();
t.Toc("TestCpuGpuResults<double>()");
//t.Tic();
//TestCpuGpuResults<double>();
//t.Toc("TestCpuGpuResults<double>()");
#endif
#endif
//PrintAllVars();

View File

@ -52,7 +52,7 @@
</font>
</property>
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;center&quot;&gt;&lt;br/&gt;&lt;span style=&quot; font-size:12pt;&quot;&gt;Fractorium 0.4.0.4 Beta&lt;/span&gt;&lt;/p&gt;&lt;p align=&quot;center&quot;&gt;&lt;span style=&quot; font-size:10pt;&quot;&gt;&lt;br/&gt;A Qt-based fractal flame editor which uses a C++ re-write of the flam3 algorithm named Ember and a GPU capable version named EmberCL which implements a portion of the cuburn algorithm in OpenCL.&lt;/span&gt;&lt;/p&gt;&lt;p align=&quot;center&quot;&gt;&lt;span style=&quot; font-size:10pt;&quot;&gt;Matt Feemster&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;center&quot;&gt;&lt;br/&gt;&lt;span style=&quot; font-size:12pt;&quot;&gt;Fractorium 0.4.0.5 Beta&lt;/span&gt;&lt;/p&gt;&lt;p align=&quot;center&quot;&gt;&lt;span style=&quot; font-size:10pt;&quot;&gt;&lt;br/&gt;A Qt-based fractal flame editor which uses a C++ re-write of the flam3 algorithm named Ember and a GPU capable version named EmberCL which implements a portion of the cuburn algorithm in OpenCL.&lt;/span&gt;&lt;/p&gt;&lt;p align=&quot;center&quot;&gt;&lt;span style=&quot; font-size:10pt;&quot;&gt;Matt Feemster&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="textFormat">
<enum>Qt::RichText</enum>

View File

@ -117,12 +117,13 @@ public:
int counter = 2;
QString newPath;
QFileInfo original(filename);
QString path = original.absolutePath() + QDir::separator();
QString base = original.completeBaseName();
QString extension = original.suffix();
do
{
newPath = base + "_" + QString::number(counter++) + "." + extension;
newPath = path + base + "_" + QString::number(counter++) + "." + extension;
}
while (QFile::exists(newPath));

View File

@ -345,6 +345,9 @@ int FinalRenderEmberController<T>::ProgressFunc(Ember<T>& ember, void* foo, doub
}
m_FinishedImageCount++;
QMetaObject::invokeMethod(m_FinalRender->ui.FinalRenderIterationProgress, "setValue", Qt::QueuedConnection, Q_ARG(int, int(100)));//Just to be safe.
QMetaObject::invokeMethod(m_FinalRender->ui.FinalRenderFilteringProgress, "setValue", Qt::QueuedConnection, Q_ARG(int, int(100)));
QMetaObject::invokeMethod(m_FinalRender->ui.FinalRenderAccumProgress, "setValue", Qt::QueuedConnection, Q_ARG(int, int(100)));
QMetaObject::invokeMethod(m_FinalRender->ui.FinalRenderTotalProgress, "setValue", Qt::QueuedConnection, Q_ARG(int, int(((float)m_FinishedImageCount / (float)m_ImageCount) * 100)));
QMetaObject::invokeMethod(m_FinalRender->ui.FinalRenderImageCountLabel, "setText", Qt::QueuedConnection, Q_ARG(QString, QString::number(m_FinishedImageCount) + " / " + QString::number(m_ImageCount)));

View File

@ -325,7 +325,7 @@ void Fractorium::dropEvent(QDropEvent* e)
void Fractorium::SetupCombo(QTableWidget* table, const QObject* receiver, int& row, int col, StealthComboBox*& comboBox, vector<string>& vals, const char* signal, const char* slot, Qt::ConnectionType connectionType)
{
comboBox = new StealthComboBox(table);
std::for_each(vals.begin(), vals.end(), [&](string s) { comboBox->addItem(s.c_str()); });
ForEach(vals, [&](string s) { comboBox->addItem(s.c_str()); });
table->setCellWidget(row, col, comboBox);
connect(comboBox, signal, receiver, slot, connectionType);
row++;

View File

@ -109,6 +109,8 @@ public slots:
void OnActionAddReflectiveSymmetry(bool checked);//Tools.
void OnActionAddRotationalSymmetry(bool checked);
void OnActionAddBothSymmetry(bool checked);
void OnActionFlatten(bool checked);
void OnActionUnflatten(bool checked);
void OnActionClearFlame(bool checked);
void OnActionRenderPreviews(bool checked);
void OnActionStopRenderingPreviews(bool checked);

View File

@ -1,44 +1,46 @@
<RCC>
<qresource prefix="/Fractorium">
<file>Icons/arrow-undo.png</file>
<file>Icons/arrow-redo.png</file>
<file>Icons/stop.png</file>
<file>Icons/application_side_boxes.png</file>
<file>Icons/page_copy.png</file>
<file>Icons/page_paste.png</file>
<file>Icons/window-close.png</file>
<file>Icons/068123-3d-transparent-glass-icon-alphanumeric-question-mark3.png</file>
<file>Icons/layer--plus.png</file>
<file>Icons/layers.png</file>
<file>Icons/layers-stack.png</file>
<file>Icons/monitor.png</file>
<file>Icons/016938-3d-transparent-glass-icon-symbols-shapes-shape-square-clear-16.png</file>
<file>Icons/document-hf-insert.png</file>
<file>Icons/010425-3d-transparent-glass-icon-animals-spiderweb2.png</file>
<file>Icons/database-medium.png</file>
<file>Icons/databases.png</file>
<file>Icons/drive-harddisk-5.png</file>
<file>Icons/folder-visiting-4.png</file>
<file>Icons/display-brightness-off.png</file>
<file>Icons/cog.png</file>
<file>Icons/proxy.png</file>
<file>Icons/shape_flip_horizontal.png</file>
<file>Icons/shape_flip_vertical.png</file>
<file>Icons/arrow_down.png</file>
<file>Icons/arrow_in.png</file>
<file>Icons/arrow_left.png</file>
<file>Icons/arrow_out.png</file>
<file>Icons/arrow_right.png</file>
<file>Icons/arrow_rotate_anticlockwise.png</file>
<file>Icons/arrow_rotate_clockwise.png</file>
<file>Icons/arrow_turn_left.png</file>
<file>Icons/arrow_turn_right.png</file>
<file>Icons/arrow_up.png</file>
<file>Icons/configure.png</file>
<file>Icons/infomation.png</file>
<file>Icons/del.png</file>
<file>Icons/add.png</file>
<file>Icons/eraser.png</file>
<file>Icons/editraise.png</file>
</qresource>
<qresource prefix="/Fractorium">
<file>Icons/arrow-undo.png</file>
<file>Icons/arrow-redo.png</file>
<file>Icons/stop.png</file>
<file>Icons/application_side_boxes.png</file>
<file>Icons/page_copy.png</file>
<file>Icons/page_paste.png</file>
<file>Icons/window-close.png</file>
<file>Icons/068123-3d-transparent-glass-icon-alphanumeric-question-mark3.png</file>
<file>Icons/layer--plus.png</file>
<file>Icons/layers.png</file>
<file>Icons/layers-stack.png</file>
<file>Icons/monitor.png</file>
<file>Icons/016938-3d-transparent-glass-icon-symbols-shapes-shape-square-clear-16.png</file>
<file>Icons/document-hf-insert.png</file>
<file>Icons/010425-3d-transparent-glass-icon-animals-spiderweb2.png</file>
<file>Icons/database-medium.png</file>
<file>Icons/databases.png</file>
<file>Icons/drive-harddisk-5.png</file>
<file>Icons/folder-visiting-4.png</file>
<file>Icons/display-brightness-off.png</file>
<file>Icons/cog.png</file>
<file>Icons/proxy.png</file>
<file>Icons/shape_flip_horizontal.png</file>
<file>Icons/shape_flip_vertical.png</file>
<file>Icons/arrow_down.png</file>
<file>Icons/arrow_in.png</file>
<file>Icons/arrow_left.png</file>
<file>Icons/arrow_out.png</file>
<file>Icons/arrow_right.png</file>
<file>Icons/arrow_rotate_anticlockwise.png</file>
<file>Icons/arrow_rotate_clockwise.png</file>
<file>Icons/arrow_turn_left.png</file>
<file>Icons/arrow_turn_right.png</file>
<file>Icons/arrow_up.png</file>
<file>Icons/configure.png</file>
<file>Icons/infomation.png</file>
<file>Icons/del.png</file>
<file>Icons/add.png</file>
<file>Icons/eraser.png</file>
<file>Icons/editraise.png</file>
<file>Icons/square.png</file>
<file>Icons/cube.png</file>
</qresource>
</RCC>

Binary file not shown.

View File

@ -174,6 +174,9 @@
<addaction name="ActionAddRotationalSymmetry"/>
<addaction name="ActionAddBothSymmetry"/>
<addaction name="separator"/>
<addaction name="ActionFlatten"/>
<addaction name="ActionUnflatten"/>
<addaction name="separator"/>
<addaction name="ActionClearFlame"/>
<addaction name="separator"/>
<addaction name="ActionRenderPreviews"/>
@ -5282,6 +5285,30 @@ SpinBox
<string>Ctrl+V</string>
</property>
</action>
<action name="ActionFlatten">
<property name="icon">
<iconset resource="Fractorium.qrc">
<normaloff>:/Fractorium/Icons/square.png</normaloff>:/Fractorium/Icons/square.png</iconset>
</property>
<property name="text">
<string>&amp;Flatten</string>
</property>
<property name="toolTip">
<string>Add the Flatten variation to each xform</string>
</property>
</action>
<action name="ActionUnflatten">
<property name="icon">
<iconset resource="Fractorium.qrc">
<normaloff>:/Fractorium/Icons/cube.png</normaloff>:/Fractorium/Icons/cube.png</iconset>
</property>
<property name="text">
<string>&amp;Unflatten</string>
</property>
<property name="toolTip">
<string>Remove the Flatten variation from each xform</string>
</property>
</action>
</widget>
<layoutdefault spacing="6" margin="11"/>
<customwidgets>

View File

@ -91,6 +91,8 @@ public:
virtual void AddReflectiveSymmetry() { }//Tools.
virtual void AddRotationalSymmetry() { }
virtual void AddBothSymmetry() { }
virtual void Flatten() { }
virtual void Unflatten() { }
virtual void ClearFlame() { }
//Toolbar.
@ -298,6 +300,8 @@ public:
virtual void AddReflectiveSymmetry();
virtual void AddRotationalSymmetry();
virtual void AddBothSymmetry();
virtual void Flatten();
virtual void Unflatten();
virtual void ClearFlame();
//Toolbar.

View File

@ -31,6 +31,8 @@ void Fractorium::InitMenusUI()
connect(ui.ActionAddRotationalSymmetry, SIGNAL(triggered(bool)), this, SLOT(OnActionAddRotationalSymmetry(bool)), Qt::QueuedConnection);
connect(ui.ActionAddBothSymmetry, SIGNAL(triggered(bool)), this, SLOT(OnActionAddBothSymmetry(bool)), Qt::QueuedConnection);
connect(ui.ActionClearFlame, SIGNAL(triggered(bool)), this, SLOT(OnActionClearFlame(bool)), Qt::QueuedConnection);
connect(ui.ActionFlatten, SIGNAL(triggered(bool)), this, SLOT(OnActionFlatten(bool)), Qt::QueuedConnection);
connect(ui.ActionUnflatten, SIGNAL(triggered(bool)), this, SLOT(OnActionUnflatten(bool)), Qt::QueuedConnection);
connect(ui.ActionStopRenderingPreviews, SIGNAL(triggered(bool)), this, SLOT(OnActionStopRenderingPreviews(bool)), Qt::QueuedConnection);
connect(ui.ActionRenderPreviews, SIGNAL(triggered(bool)), this, SLOT(OnActionRenderPreviews(bool)), Qt::QueuedConnection);
connect(ui.ActionFinalRender, SIGNAL(triggered(bool)), this, SLOT(OnActionFinalRender(bool)), Qt::QueuedConnection);
@ -659,6 +661,22 @@ void FractoriumEmberController<T>::AddBothSymmetry()
void Fractorium::OnActionAddBothSymmetry(bool checked) { m_Controller->AddBothSymmetry(); }
/// <summary>
/// Adds a FlattenVariation to every xform in the current ember.
/// Resets the rendering process.
/// </summary>
template <typename T>
void FractoriumEmberController<T>::Flatten() { UpdateCurrentXform([&] (Xform<T>* xform) { m_Ember.Flatten(XmlToEmber<T>::m_FlattenNames); FillVariationTreeWithXform(xform); }); }
void Fractorium::OnActionFlatten(bool checked) { m_Controller->Flatten(); }
/// <summary>
/// Removes pre/reg/post FlattenVariation from every xform in the current ember.
/// Resets the rendering process.
/// </summary>
template <typename T>
void FractoriumEmberController<T>::Unflatten() { UpdateCurrentXform([&] (Xform<T>* xform) { m_Ember.Unflatten(); FillVariationTreeWithXform(xform); }); }
void Fractorium::OnActionUnflatten(bool checked) { m_Controller->Unflatten(); }
/// <summary>
/// Delete all but one xform in the current ember.
/// Clear that xform's variations.

View File

@ -22,12 +22,13 @@ void Fractorium::InitParamsUI()
SetFixedTableHeader(ui.IterationTableHeader->horizontalHeader());
//Color.
SetupSpinner<DoubleSpinBox, double>(table, this, row, 1, m_BrightnessSpin, spinHeight, 0.05, 100, 1, SIGNAL(valueChanged(double)), SLOT(OnBrightnessChanged(double)), true, 4.0, 4.0, 4.0);
SetupSpinner<DoubleSpinBox, double>(table, this, row, 1, m_GammaSpin, spinHeight, 1, 9999, 0.5, SIGNAL(valueChanged(double)), SLOT(OnGammaChanged(double)), true, 4.0, 4.0, 4.0);
SetupSpinner<DoubleSpinBox, double>(table, this, row, 1, m_GammaThresholdSpin, spinHeight, 0, 10, 0.1, SIGNAL(valueChanged(double)), SLOT(OnGammaThresholdChanged(double)), true, 0.1, 0.1, 0.1);
SetupSpinner<DoubleSpinBox, double>(table, this, row, 1, m_VibrancySpin, spinHeight, 0, 1, 0.01, SIGNAL(valueChanged(double)), SLOT(OnVibrancyChanged(double)), true, 1.0, 1.0, 1.0);
SetupSpinner<DoubleSpinBox, double>(table, this, row, 1, m_HighlightSpin, spinHeight, -1.0, 2.0, 0.1, SIGNAL(valueChanged(double)), SLOT(OnHighlightPowerChanged(double)), true, -1.0, -1.0, -1.0);
SetupSpinner<DoubleSpinBox, double>(table, this, row, 1, m_BrightnessSpin, spinHeight, 0.05, 100, 1, SIGNAL(valueChanged(double)), SLOT(OnBrightnessChanged(double)), true, 4.0, 4.0, 4.0);
SetupSpinner<DoubleSpinBox, double>(table, this, row, 1, m_GammaSpin, spinHeight, 1, 9999, 0.5, SIGNAL(valueChanged(double)), SLOT(OnGammaChanged(double)), true, 4.0, 4.0, 4.0);
SetupSpinner<DoubleSpinBox, double>(table, this, row, 1, m_GammaThresholdSpin, spinHeight, 0, 10, 0.01, SIGNAL(valueChanged(double)), SLOT(OnGammaThresholdChanged(double)), true, 0.1, 0.1, 0.0);
SetupSpinner<DoubleSpinBox, double>(table, this, row, 1, m_VibrancySpin, spinHeight, 0, 30, 0.01, SIGNAL(valueChanged(double)), SLOT(OnVibrancyChanged(double)), true, 1.0, 1.0, 0.0);
SetupSpinner<DoubleSpinBox, double>(table, this, row, 1, m_HighlightSpin, spinHeight, -1.0, 2.0, 0.1, SIGNAL(valueChanged(double)), SLOT(OnHighlightPowerChanged(double)), true, -1.0, -1.0, -1.0);
m_GammaThresholdSpin->setDecimals(4);
m_BackgroundColorButton = new QPushButton("...", table);
m_BackgroundColorButton->setMinimumWidth(21);
m_BackgroundColorButton->setMaximumWidth(21);
@ -47,7 +48,7 @@ void Fractorium::InitParamsUI()
SetupSpinner<SpinBox, int> (table, this, row, 1, m_HeightSpin, spinHeight, 10, 100000, 50, SIGNAL(valueChanged(int)), SLOT(OnHeightChanged(int)));
SetupSpinner<DoubleSpinBox, double>(table, this, row, 1, m_CenterXSpin, spinHeight, -10, 10, 0.05, SIGNAL(valueChanged(double)), SLOT(OnCenterXChanged(double)), true, 0, 0, 0);
SetupSpinner<DoubleSpinBox, double>(table, this, row, 1, m_CenterYSpin, spinHeight, -10, 10, 0.05, SIGNAL(valueChanged(double)), SLOT(OnCenterYChanged(double)), true, 0, 0, 0);
SetupSpinner<DoubleSpinBox, double>(table, this, row, 1, m_ScaleSpin, spinHeight, 10, 3000, 20, SIGNAL(valueChanged(double)), SLOT(OnScaleChanged(double)), true, 240, 240, 240);
SetupSpinner<DoubleSpinBox, double>(table, this, row, 1, m_ScaleSpin, spinHeight, 10, 5000, 20, SIGNAL(valueChanged(double)), SLOT(OnScaleChanged(double)), true, 240, 240, 240);
SetupSpinner<DoubleSpinBox, double>(table, this, row, 1, m_ZoomSpin, spinHeight, 0, 5, 0.2, SIGNAL(valueChanged(double)), SLOT(OnZoomChanged(double)), true, 0, 0, 0);
SetupSpinner<DoubleSpinBox, double>(table, this, row, 1, m_RotateSpin, spinHeight, -180, 180, 10, SIGNAL(valueChanged(double)), SLOT(OnRotateChanged(double)), true, 0, 0, 0);
SetupSpinner<DoubleSpinBox, double>(table, this, row, 1, m_ZPosSpin, spinHeight, -1000, 1000, 1, SIGNAL(valueChanged(double)), SLOT(OnZPosChanged(double)), true, 0, 1, 0);

View File

@ -55,6 +55,7 @@ void FractoriumEmberController<T>::SetupVariationTree()
spinBox->DoubleClickZero(1);
spinBox->DoubleClickNonZero(0);
spinBox->SmallStep(0.001);
spinBox->setDecimals(4);
tree->setItemWidget(item, 1, spinBox);
m_Fractorium->connect(spinBox, SIGNAL(valueChanged(double)), SLOT(OnVariationSpinBoxValueChanged(double)), Qt::QueuedConnection);
@ -85,6 +86,10 @@ void FractoriumEmberController<T>::SetupVariationTree()
varSpinBox->Step(1);
varSpinBox->SmallStep(1);
}
else
{
varSpinBox->setDecimals(4);
}
tree->setItemWidget(paramWidget, 1, varSpinBox);
m_Fractorium->connect(varSpinBox, SIGNAL(valueChanged(double)), SLOT(OnVariationSpinBoxValueChanged(double)), Qt::QueuedConnection);
@ -138,7 +143,7 @@ void FractoriumEmberController<T>::VariationSpinBoxValueChanged(double d)
{
Variation<T>* var = sender->GetVariation();//The variation attached to the sender, for reference only.
ParametricVariation<T>* parVar = dynamic_cast<ParametricVariation<T>*>(var);//The parametric cast of that variation.
Variation<T>* xformVar = xform->GetVariationByName(var->Name());//The corresponding variation in the currently selected xform.
Variation<T>* xformVar = xform->GetVariationById(var->VariationId());//The corresponding variation in the currently selected xform.
QList<QTreeWidgetItem*> items = tree->findItems(QString::fromStdString(var->Name()), Qt::MatchExactly);
bool isParam = parVar && sender->IsParam();
@ -222,6 +227,8 @@ void FractoriumEmberController<T>::FillVariationTreeWithXform(Xform<T>* xform)
{
QTreeWidget* tree = m_Fractorium->ui.VariationsTree;
tree->blockSignals(true);
for (unsigned int i = 0; i < tree->topLevelItemCount(); i++)
{
QTreeWidgetItem* item = tree->topLevelItem(i);
@ -263,6 +270,7 @@ void FractoriumEmberController<T>::FillVariationTreeWithXform(Xform<T>* xform)
}
}
tree->blockSignals(false);
m_Fractorium->OnTreeHeaderSectionClicked(m_Fractorium->m_VarSortMode);
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 621 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 410 B

View File

@ -16,6 +16,12 @@ int main(int argc, char *argv[])
QMessageBox::critical(QApplication::desktop(), "Error", "Fractorium cannot be run in test mode, undefine TEST_CL first.");
return 1;
#endif
#ifdef ISAAC_FLAM3_DEBUG
QMessageBox::critical(QApplication::desktop(), "Error", "Fractorium cannot be run in test mode, undefine ISAAC_FLAM3_DEBUG first.");
return 1;
#endif
//Required for large allocs, else GPU memory usage will be severely limited to small sizes.
//This must be done in the application and not in the EmberCL DLL.
_putenv_s("GPU_MAX_ALLOC_PERCENT", "100");