--Code changes

-Make usage of VarFuncs more consistent by moving some global functions there.
 -Make CircleTrans1 a little safer by calling Zeps() on m_Sc during precalc.
 -Begin prepping for 0.9.9.5 release.
This commit is contained in:
mfeemster 2016-03-04 18:54:06 -08:00
parent b6d9717d42
commit 0efb319b12
20 changed files with 266 additions and 99 deletions

View File

@ -6,7 +6,7 @@
<ProductVersion>3.7</ProductVersion> <ProductVersion>3.7</ProductVersion>
<ProjectGuid>{c8096c47-e358-438c-a520-146d46b0637d}</ProjectGuid> <ProjectGuid>{c8096c47-e358-438c-a520-146d46b0637d}</ProjectGuid>
<SchemaVersion>2.0</SchemaVersion> <SchemaVersion>2.0</SchemaVersion>
<OutputName>Fractorium_Beta_0.9.9.4</OutputName> <OutputName>Fractorium_Beta_0.9.9.5</OutputName>
<OutputType>Package</OutputType> <OutputType>Package</OutputType>
<WixTargetsPath Condition=" '$(WixTargetsPath)' == '' AND '$(MSBuildExtensionsPath32)' != '' ">$(MSBuildExtensionsPath32)\Microsoft\WiX\v3.x\Wix.targets</WixTargetsPath> <WixTargetsPath Condition=" '$(WixTargetsPath)' == '' AND '$(MSBuildExtensionsPath32)' != '' ">$(MSBuildExtensionsPath32)\Microsoft\WiX\v3.x\Wix.targets</WixTargetsPath>
<WixTargetsPath Condition=" '$(WixTargetsPath)' == '' ">$(MSBuildExtensionsPath)\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"?> <?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"> <Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<?define ProductVersion="0.9.9.4" ?> <?define ProductVersion="0.9.9.5" ?>
<?define ProductName="Fractorium Beta $(var.ProductVersion) ($(var.GpuType))" ?> <?define ProductName="Fractorium Beta $(var.ProductVersion) ($(var.GpuType))" ?>
<?define UpgradeCode="{4714cd15-bfba-44f6-8059-9e1466ebfa6e}"?> <?define UpgradeCode="{4714cd15-bfba-44f6-8059-9e1466ebfa6e}"?>
<?define Manufacturer="Fractorium"?> <?define Manufacturer="Fractorium"?>
@ -13,7 +13,7 @@
<!-- <!--
Change this for every release. Change this for every release.
--> -->
<?define ProductCode="{021AC37D-4402-41A9-9106-74FCECFB551D}"?> <?define ProductCode="{AB57D1D4-0703-450C-A3A5-A6C02DB69B10}"?>
<Product Id="$(var.ProductCode)" Name="$(var.ProductName)" Language="1033" Version="$(var.ProductVersion)" Manufacturer="$(var.Manufacturer)" UpgradeCode="$(var.UpgradeCode)"> <Product Id="$(var.ProductCode)" Name="$(var.ProductName)" Language="1033" Version="$(var.ProductVersion)" Manufacturer="$(var.Manufacturer)" UpgradeCode="$(var.UpgradeCode)">
<Package <Package

Binary file not shown.

View File

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

Binary file not shown.

View File

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

View File

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

Binary file not shown.

View File

@ -1,4 +1,4 @@
VERSION = 0.9.9.4 VERSION = 0.9.9.5
win32:CONFIG += skip_target_version_ext win32:CONFIG += skip_target_version_ext
#message(PWD: $$absolute_path($$PWD)) #message(PWD: $$absolute_path($$PWD))

View File

@ -40,7 +40,7 @@ static void sincos(float x, float* s, float* c)
namespace EmberNs namespace EmberNs
{ {
#define EMBER_VERSION "0.9.9.4" #define EMBER_VERSION "0.9.9.5"
#define EPS6 T(1e-6) #define EPS6 T(1e-6)
#define EPS std::numeric_limits<T>::epsilon()//Apoplugin.h uses -20, but it's more mathematically correct to do it this way. #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 ISAAC_SIZE 4

View File

@ -16,6 +16,176 @@ template <typename T>
class EMBER_API VarFuncs : public Singleton<VarFuncs<T>> class EMBER_API VarFuncs : public Singleton<VarFuncs<T>>
{ {
public: public:
/// <summary>
/// Return -1 if the value is less than 0, 1 if it's greater and
/// 0 if it's equal to 0.
/// </summary>
/// <param name="v">The value to inspect</param>
/// <returns>-1, 0 or 1</returns>
static inline T Sign(T v)
{
return (v < 0) ? static_cast<T>(-1) : (v > 0) ? static_cast<T>(1) : static_cast<T>(0);
}
/// <summary>
/// Return -1 if the value is less than 0, 1 if it's greater.
/// This differs from Sign() in that it doesn't return 0.
/// </summary>
/// <param name="v">The value to inspect</param>
/// <returns>-1 or 1</returns>
static inline T SignNz(T v)
{
return (v < 0) ? static_cast<T>(-1) : static_cast<T>(1);
}
/// <summary>
/// Thin wrapper around a call to modf that discards the integer portion
/// and returns the signed fractional portion.
/// </summary>
/// <param name="v">The value to retrieve the signed fractional portion of.</param>
/// <returns>The signed fractional portion of v.</returns>
static inline T Fabsmod(T v)
{
T dummy;
return modf(v, &dummy);
}
/// <summary>
/// Unsure.
/// </summary>
/// <param name="p">Unsure.</param>
/// <param name="amp">Unsure.</param>
/// <param name="ph">Unsure.</param>
/// <returns>Unsure.</returns>
static inline T Fosc(T p, T amp, T ph)
{
return T(0.5) - std::cos(p * amp + ph) * T(0.5);
}
/// <summary>
/// Unsure.
/// </summary>
/// <param name="p">Unsure.</param>
/// <param name="ph">Unsure.</param>
/// <returns>Unsure.</returns>
static inline T Foscn(T p, T ph)
{
return T(0.5) - std::cos(p + ph) * T(0.5);
}
/// <summary>
/// Log scale from Apophysis.
/// </summary>
/// <param name="x">The value to log scale</param>
/// <returns>The log scaled value</returns>
static inline T LogScale(T x)
{
return x == 0 ? 0 : std::log((fabs(x) + 1) * T(M_E)) * SignNz(x) / T(M_E);
}
/// <summary>
/// Log map from Apophysis.
/// </summary>
/// <param name="x">The value to log map</param>
/// <returns>The log mapped value</returns>
static inline T LogMap(T x)
{
return x == 0 ? 0 : (T(M_E) + std::log(x * T(M_E))) * T(0.25) * SignNz(x);
}
/// <summary>
/// Taking the square root of numbers close to zero is dangerous. If x is negative
/// due to floating point errors, it can return NaN results.
/// </summary>
static inline T SafeSqrt(T x)
{
if (x <= 0)
return 0;
return std::sqrt(x);
}
/// <summary>
/// If r < EPS, return 1 / r.
/// Else, return q / r.
/// </summary>
/// <param name="q">The numerator</param>
/// <param name="r">The denominator</param>
/// <returns>The quotient</returns>
static inline T SafeDivInv(T q, T r)
{
if (r < EPS)
return 1 / r;
return q / r;
}
/// <summary>
/// Return the hypotenuse of the passed in values.
/// </summary>
/// <param name="x">The x distance</param>
/// <param name="y">The y distance</param>
/// <returns>The hypotenuse</returns>
static inline T Hypot(T x, T y)
{
return std::sqrt(SQR(x) + SQR(y));
}
/// <summary>
/// Spread the values.
/// </summary>
/// <param name="x">The x distance</param>
/// <param name="y">The y distance</param>
/// <returns>The spread</returns>
static inline T Spread(T x, T y)
{
return Hypot(x, y) * ((x) > 0 ? T(1) : T(-1));
}
/// <summary>
/// Unsure.
/// </summary>
/// <param name="x">The x distance</param>
/// <param name="y">The y distance</param>
/// <returns>The powq4</returns>
static inline T Powq4(T x, T y)
{
return std::pow(std::abs(x), y) * SignNz(x);
}
/// <summary>
/// Unsure.
/// </summary>
/// <param name="x">The x distance</param>
/// <param name="y">The y distance</param>
/// <returns>The powq4c</returns>
static inline T Powq4c(T x, T y)
{
return y == 1 ? x : Powq4(x, y);
}
/// <summary>
/// Special rounding for certain variations, gotten from Apophysis.
/// </summary>
/// <param name="x">The value to round</param>
/// <returns>The rounded value</returns>
static inline float LRint(float x)
{
int temp = (x >= 0 ? static_cast<int>(x + 0.5f) : static_cast<int>(x - 0.5f));
return static_cast<float>(temp);
}
/// <summary>
/// Special rounding for certain variations, gotten from Apophysis.
/// </summary>
/// <param name="x">The value to round</param>
/// <returns>The rounded value</returns>
static inline double LRint(double x)
{
glm::int64_t temp = (x >= 0 ? static_cast<int64_t>(x + 0.5) : static_cast<int64_t>(x - 0.5));
return static_cast<double>(temp);
}
/// <summary> /// <summary>
/// Retrieve information about a piece of shared data by looking /// Retrieve information about a piece of shared data by looking
/// up its name. /// up its name.

View File

@ -1688,7 +1688,7 @@ public:
T vd = std::max(std::min(val, m_Max), m_Min); T vd = std::max(std::min(val, m_Max), m_Min);
if (IsNearZero(vd)) if (IsNearZero(vd))
*m_Param = EPS * SignNz(vd); *m_Param = EPS * VarFuncs<T>::SignNz(vd);
else else
*m_Param = vd; *m_Param = vd;
@ -1707,7 +1707,7 @@ public:
int vi = int(std::max(std::min<T>(T(Floor<T>(val + T(0.5))), m_Max), m_Min)); int vi = int(std::max(std::min<T>(T(Floor<T>(val + T(0.5))), m_Max), m_Min));
if (vi == 0) if (vi == 0)
vi = int(SignNz<T>(val)); vi = int(VarFuncs<T>::SignNz(val));
*m_Param = T(vi); *m_Param = T(vi);
break; break;

View File

@ -3200,7 +3200,7 @@ public:
{ {
if (!_stricmp(name, "bipolar_shift")) if (!_stricmp(name, "bipolar_shift"))
{ {
T temp = Fabsmod(T(0.5) * (val + 1)); T temp = VarFuncs<T>::Fabsmod(T(0.5) * (val + 1));
m_Shift = 2 * temp - 1; m_Shift = 2 * temp - 1;
Precalc(); Precalc();
return true; return true;
@ -3902,7 +3902,7 @@ public:
{ {
if (!_stricmp(name, "escher_beta")) if (!_stricmp(name, "escher_beta"))
{ {
m_Beta = Fabsmod((val + T(M_PI)) / (2 * T(M_PI))) * 2 * T(M_PI) - T(M_PI); m_Beta = VarFuncs<T>::Fabsmod((val + T(M_PI)) / (2 * T(M_PI))) * 2 * T(M_PI) - T(M_PI);
Precalc(); Precalc();
return true; return true;
} }
@ -4056,7 +4056,7 @@ public:
{ {
if (!_stricmp(name, "lazysusan_spin")) if (!_stricmp(name, "lazysusan_spin"))
{ {
m_Spin = Fabsmod(val / T(M_2PI)) * T(M_2PI); m_Spin = VarFuncs<T>::Fabsmod(val / T(M_2PI)) * T(M_2PI);
this->Precalc(); this->Precalc();
return true; return true;
} }

View File

@ -1523,7 +1523,7 @@ public:
T dx, dy; T dx, dy;
T rnx = m_Rnd * rand.Frand01<T>(); T rnx = m_Rnd * rand.Frand01<T>();
T rny = m_Rnd * rand.Frand01<T>(); T rny = m_Rnd * rand.Frand01<T>();
int isXY = int(LRint(helper.In.x * m_Cs) + LRint(helper.In.y * m_Cs)); int isXY = int(VarFuncs<T>::LRint(helper.In.x * m_Cs) + VarFuncs<T>::LRint(helper.In.y * m_Cs));
if (isXY & 1) if (isXY & 1)
{ {
@ -1852,12 +1852,12 @@ public:
{ {
T x = T(0.5) * helper.In.x + T(0.5); T x = T(0.5) * helper.In.x + T(0.5);
T y = T(0.5) * helper.In.y + T(0.5); T y = T(0.5) * helper.In.y + T(0.5);
T bx = Fabsmod<T>(m_Fr * x); T bx = VarFuncs<T>::Fabsmod(m_Fr * x);
T by = Fabsmod<T>(m_Fr * y); T by = VarFuncs<T>::Fabsmod(m_Fr * y);
T oscnapx = Foscn<T>(m_AmountX, m_Px); T oscnapx = VarFuncs<T>::Foscn(m_AmountX, m_Px);
T oscnapy = Foscn<T>(m_AmountY, m_Py); T oscnapy = VarFuncs<T>::Foscn(m_AmountY, m_Py);
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.x = -1 + m_Vv2 * Lerp<T>(Lerp<T>(x, VarFuncs<T>::Fosc(x, T(4), m_Px), oscnapx), VarFuncs<T>::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.y = -1 + m_Vv2 * Lerp<T>(Lerp<T>(y, VarFuncs<T>::Fosc(y, T(4), m_Py), oscnapy), VarFuncs<T>::Fosc(by, T(4), m_Py), oscnapy);
helper.Out.z = DefaultZ(helper); helper.Out.z = DefaultZ(helper);
} }
@ -2463,8 +2463,8 @@ public:
virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override
{ {
T x = LRint(helper.In.x); T x = VarFuncs<T>::LRint(helper.In.x);
T y = LRint(helper.In.y); T y = VarFuncs<T>::LRint(helper.In.y);
if (y <= 0) if (y <= 0)
{ {
@ -4210,8 +4210,8 @@ public:
{ {
T xp = std::pow(std::abs(m_Weight) * std::abs(helper.In.x), m_Powx);//Original did not fabs. T xp = std::pow(std::abs(m_Weight) * std::abs(helper.In.x), m_Powx);//Original did not fabs.
T yp = std::pow(std::abs(m_Weight) * std::abs(helper.In.y), m_Powy); T yp = std::pow(std::abs(m_Weight) * std::abs(helper.In.y), m_Powy);
helper.Out.x = xp * Sign(helper.In.x) + m_Lcx * helper.In.x + m_Scx; helper.Out.x = xp * VarFuncs<T>::Sign(helper.In.x) + m_Lcx * helper.In.x + m_Scx;
helper.Out.y = yp * Sign(helper.In.y) + m_Lcy * helper.In.y + m_Scy; helper.Out.y = yp * VarFuncs<T>::Sign(helper.In.y) + m_Lcy * helper.In.y + m_Scy;
helper.Out.z = m_Weight * helper.In.z; helper.Out.z = m_Weight * helper.In.z;
} }
@ -5199,8 +5199,8 @@ public:
T u = (dot11 * dot02 - dot01 * dot12) * invDenom; T u = (dot11 * dot02 - dot01 * dot12) * invDenom;
T v = (dot00 * dot12 - dot01 * dot02) * invDenom; T v = (dot00 * dot12 - dot01 * dot02) * invDenom;
// now combine with input // now combine with input
T um = std::sqrt(SQR(u) + SQR(helper.In.x)) * Sign<T>(u); T um = std::sqrt(SQR(u) + SQR(helper.In.x)) * VarFuncs<T>::Sign(u);
T vm = std::sqrt(SQR(v) + SQR(helper.In.y)) * Sign<T>(v); T vm = std::sqrt(SQR(v) + SQR(helper.In.y)) * VarFuncs<T>::Sign(v);
helper.Out.x = m_Weight * um; helper.Out.x = m_Weight * um;
helper.Out.y = m_Weight * vm; helper.Out.y = m_Weight * vm;
helper.Out.z = m_Weight * helper.In.z; helper.Out.z = m_Weight * helper.In.z;

View File

@ -1609,8 +1609,8 @@ public:
virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override
{ {
helper.Out.x = SignNz<T>(helper.In.x) * std::pow(std::abs(helper.In.x), m_PowX) * m_Weight; helper.Out.x = VarFuncs<T>::SignNz(helper.In.x) * std::pow(std::abs(helper.In.x), m_PowX) * m_Weight;
helper.Out.y = SignNz<T>(helper.In.y) * std::pow(std::abs(helper.In.y), m_PowY) * m_Weight; helper.Out.y = VarFuncs<T>::SignNz(helper.In.y) * std::pow(std::abs(helper.In.y), m_PowY) * m_Weight;
helper.Out.z = DefaultZ(helper); helper.Out.z = DefaultZ(helper);
} }
@ -2259,7 +2259,7 @@ public:
virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override
{ {
T dx, dy, r = m_Weight / (helper.m_PrecalcSumSquares + EPS); 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)); int isXY = int(VarFuncs<T>::LRint(helper.In.x * m_InvSize) + VarFuncs<T>::LRint(helper.In.y * m_InvSize));
if (isXY & 1) if (isXY & 1)
{ {
@ -3761,7 +3761,7 @@ public:
{ {
T tmp = helper.m_PrecalcSumSquares + 1; T tmp = helper.m_PrecalcSumSquares + 1;
T tmp2 = 2 * helper.In.x; T tmp2 = 2 * helper.In.x;
T xmax = (SafeSqrt(tmp + tmp2) + SafeSqrt(tmp - tmp2)) * T(0.5); T xmax = (VarFuncs<T>::SafeSqrt(tmp + tmp2) + VarFuncs<T>::SafeSqrt(tmp - tmp2)) * T(0.5);
int alt; int alt;
if (xmax < 1) if (xmax < 1)
@ -3911,7 +3911,7 @@ public:
T tmp = r2 + 1; T tmp = r2 + 1;
T tmp2 = 2 * x; T tmp2 = 2 * x;
T xmax = (SafeSqrt(tmp + tmp2) + SafeSqrt(tmp - tmp2)) * T(0.5); T xmax = (VarFuncs<T>::SafeSqrt(tmp + tmp2) + VarFuncs<T>::SafeSqrt(tmp - tmp2)) * T(0.5);
ClampGteRef<T>(xmax, 1); ClampGteRef<T>(xmax, 1);
T mu = std::acosh(xmax); T mu = std::acosh(xmax);
T nu = std::acos(Clamp<T>(x / xmax, -1, 1));//-Pi < nu < Pi. T nu = std::acos(Clamp<T>(x / xmax, -1, 1));//-Pi < nu < Pi.
@ -4015,7 +4015,7 @@ public:
{ {
T tmp = helper.m_PrecalcSumSquares + 1; T tmp = helper.m_PrecalcSumSquares + 1;
T tmp2 = 2 * helper.In.x; T tmp2 = 2 * helper.In.x;
T xmax = (SafeSqrt(tmp + tmp2) + SafeSqrt(tmp - tmp2)) * T(0.5); T xmax = (VarFuncs<T>::SafeSqrt(tmp + tmp2) + VarFuncs<T>::SafeSqrt(tmp - tmp2)) * T(0.5);
ClampGteRef<T>(xmax, 1); ClampGteRef<T>(xmax, 1);
T mu = std::acosh(xmax); T mu = std::acosh(xmax);
T nu = std::acos(Clamp<T>(helper.In.x / xmax, -1, 1));//-Pi < nu < Pi. T nu = std::acos(Clamp<T>(helper.In.x / xmax, -1, 1));//-Pi < nu < Pi.
@ -4110,7 +4110,7 @@ public:
{ {
T tmp = helper.m_PrecalcSumSquares + 1; T tmp = helper.m_PrecalcSumSquares + 1;
T tmp2 = 2 * helper.In.x; T tmp2 = 2 * helper.In.x;
T xmax = (SafeSqrt(tmp + tmp2) + SafeSqrt(tmp - tmp2)) * T(0.5); T xmax = (VarFuncs<T>::SafeSqrt(tmp + tmp2) + VarFuncs<T>::SafeSqrt(tmp - tmp2)) * T(0.5);
ClampGteRef<T>(xmax, 1); ClampGteRef<T>(xmax, 1);
T mu = std::acosh(xmax); T mu = std::acosh(xmax);
T nu = std::acos(Clamp<T>(helper.In.x / xmax, -1, 1));//-Pi < nu < Pi. T nu = std::acos(Clamp<T>(helper.In.x / xmax, -1, 1));//-Pi < nu < Pi.
@ -4214,7 +4214,7 @@ public:
{ {
T tmp = helper.m_PrecalcSumSquares + 1; T tmp = helper.m_PrecalcSumSquares + 1;
T tmp2 = 2 * helper.In.x; T tmp2 = 2 * helper.In.x;
T xmax = (SafeSqrt(tmp + tmp2) + SafeSqrt(tmp - tmp2)) * T(0.5); T xmax = (VarFuncs<T>::SafeSqrt(tmp + tmp2) + VarFuncs<T>::SafeSqrt(tmp - tmp2)) * T(0.5);
ClampGteRef<T>(xmax, 1); ClampGteRef<T>(xmax, 1);
T mu = std::acosh(xmax); T mu = std::acosh(xmax);
T nu = std::acos(Clamp<T>(helper.In.x / xmax, -1, 1));//-Pi < nu < Pi. T nu = std::acos(Clamp<T>(helper.In.x / xmax, -1, 1));//-Pi < nu < Pi.
@ -4303,7 +4303,7 @@ public:
{ {
T tmp = helper.m_PrecalcSumSquares + 1; T tmp = helper.m_PrecalcSumSquares + 1;
T tmp2 = 2 * helper.In.x; T tmp2 = 2 * helper.In.x;
T xmax = (SafeSqrt(tmp + tmp2) + SafeSqrt(tmp - tmp2)) * T(0.5); T xmax = (VarFuncs<T>::SafeSqrt(tmp + tmp2) + VarFuncs<T>::SafeSqrt(tmp - tmp2)) * T(0.5);
if (xmax < 1) if (xmax < 1)
xmax = 1; xmax = 1;
@ -4383,7 +4383,7 @@ public:
{ {
T tmp = helper.m_PrecalcSumSquares + 1; T tmp = helper.m_PrecalcSumSquares + 1;
T tmp2 = 2 * helper.In.x; T tmp2 = 2 * helper.In.x;
T xmax = (SafeSqrt(tmp + tmp2) + SafeSqrt(tmp - tmp2)) * T(0.5); T xmax = (VarFuncs<T>::SafeSqrt(tmp + tmp2) + VarFuncs<T>::SafeSqrt(tmp - tmp2)) * T(0.5);
ClampGteRef<T>(xmax, 1); ClampGteRef<T>(xmax, 1);
T mu = std::acosh(xmax); T mu = std::acosh(xmax);
T nu = std::acos(Clamp<T>(helper.In.x / xmax, -1, 1));//-Pi < nu < Pi. T nu = std::acos(Clamp<T>(helper.In.x / xmax, -1, 1));//-Pi < nu < Pi.

View File

@ -22,7 +22,7 @@ public:
{ {
T tmp = helper.m_PrecalcSumSquares + 1; T tmp = helper.m_PrecalcSumSquares + 1;
T tmp2 = 2 * helper.In.x; T tmp2 = 2 * helper.In.x;
T xmax = (SafeSqrt(tmp + tmp2) + SafeSqrt(tmp - tmp2)) * T(0.5); T xmax = (VarFuncs<T>::SafeSqrt(tmp + tmp2) + VarFuncs<T>::SafeSqrt(tmp - tmp2)) * T(0.5);
ClampGteRef<T>(xmax, -1); ClampGteRef<T>(xmax, -1);
T mu = std::acosh(xmax); T mu = std::acosh(xmax);
T nu = std::acos(Clamp<T>(helper.In.x / xmax, -1, 1));//-Pi < nu < Pi. T nu = std::acos(Clamp<T>(helper.In.x / xmax, -1, 1));//-Pi < nu < Pi.
@ -2519,7 +2519,7 @@ public:
virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override
{ {
const T zr = Hypot<T>(helper.In.z, helper.m_PrecalcSqrtSumSquares); const T zr = VarFuncs<T>::Hypot(helper.In.z, helper.m_PrecalcSqrtSumSquares);
const T phi = std::acos(Clamp<T>(helper.In.z / zr, -1, 1)); const T phi = std::acos(Clamp<T>(helper.In.z / zr, -1, 1));
const T ps = std::sin(phi); const T ps = std::sin(phi);
const T pc = std::cos(phi); const T pc = std::cos(phi);
@ -2670,13 +2670,13 @@ public:
virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override
{ {
const T x = Powq4c(helper.In.x, m_Power); const T x = VarFuncs<T>::Powq4c(helper.In.x, m_Power);
const T y = Powq4c(helper.In.y, m_Power); const T y = VarFuncs<T>::Powq4c(helper.In.y, m_Power);
const T z = Powq4c(helper.In.z, m_Power); const T z = VarFuncs<T>::Powq4c(helper.In.z, m_Power);
const T d = SQR(x) - SQR(y); const T d = SQR(x) - SQR(y);
const T re = Spread(m_C1 * x + m_C2 * d, m_Sx) + 1; const T re = VarFuncs<T>::Spread(m_C1 * x + m_C2 * d, m_Sx) + 1;
const T im = Spread(m_C1 * y + m_C2x2 * x * y, m_Sy); const T im = VarFuncs<T>::Spread(m_C1 * y + m_C2x2 * x * y, m_Sy);
T c = Zeps(Powq4c(SQR(re) + SQR(im), m_PowerInv)); T c = Zeps(VarFuncs<T>::Powq4c(SQR(re) + SQR(im), m_PowerInv));
const T r = m_Weight / c; const T r = m_Weight / c;
helper.Out.x = (x * re + y * im) * r; helper.Out.x = (x * re + y * im) * r;
helper.Out.y = (y * re - x * im) * r; helper.Out.y = (y * re - x * im) * r;
@ -3121,7 +3121,7 @@ public:
virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override
{ {
T absV = Hypot<T>(helper.In.y, helper.In.z); T absV = VarFuncs<T>::Hypot(helper.In.y, helper.In.z);
T s = std::sin(helper.In.x); T s = std::sin(helper.In.x);
T c = std::cos(helper.In.x); T c = std::cos(helper.In.x);
T sh = std::sinh(absV); T sh = std::sinh(absV);
@ -3170,7 +3170,7 @@ public:
virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override
{ {
T absV = Hypot<T>(helper.In.y, helper.In.z); T absV = VarFuncs<T>::Hypot(helper.In.y, helper.In.z);
T s = std::sin(absV); T s = std::sin(absV);
T c = std::cos(absV); T c = std::cos(absV);
T sh = std::sinh(helper.In.x); T sh = std::sinh(helper.In.x);
@ -3219,7 +3219,7 @@ public:
virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override
{ {
T absV = Hypot<T>(helper.In.y, helper.In.z); T absV = VarFuncs<T>::Hypot(helper.In.y, helper.In.z);
T ni = m_Weight / (helper.m_PrecalcSumSquares + SQR(helper.In.z)); T ni = m_Weight / (helper.m_PrecalcSumSquares + SQR(helper.In.z));
T s = std::sin(-helper.In.x); T s = std::sin(-helper.In.x);
T c = std::cos(-helper.In.x); T c = std::cos(-helper.In.x);
@ -3270,7 +3270,7 @@ public:
virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override
{ {
T absV = Hypot<T>(helper.In.y, helper.In.z); T absV = VarFuncs<T>::Hypot(helper.In.y, helper.In.z);
T ni = m_Weight / (helper.m_PrecalcSumSquares + SQR(helper.In.z)); T ni = m_Weight / (helper.m_PrecalcSumSquares + SQR(helper.In.z));
T s = std::sin(absV); T s = std::sin(absV);
T c = std::cos(absV); T c = std::cos(absV);
@ -3433,7 +3433,7 @@ public:
virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override
{ {
T absV = Hypot<T>(helper.In.y, helper.In.z); T absV = VarFuncs<T>::Hypot(helper.In.y, helper.In.z);
T s = std::sin(helper.In.x); T s = std::sin(helper.In.x);
T c = std::cos(helper.In.x); T c = std::cos(helper.In.x);
T sh = std::sinh(absV); T sh = std::sinh(absV);
@ -3482,7 +3482,7 @@ public:
virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override
{ {
T absV = Hypot<T>(helper.In.y, helper.In.z); T absV = VarFuncs<T>::Hypot(helper.In.y, helper.In.z);
T s = std::sin(absV); T s = std::sin(absV);
T c = std::cos(absV); T c = std::cos(absV);
T sh = std::sinh(helper.In.x); T sh = std::sinh(helper.In.x);
@ -3643,7 +3643,7 @@ public:
virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override
{ {
T absV = Hypot<T>(helper.In.y, helper.In.z); T absV = VarFuncs<T>::Hypot(helper.In.y, helper.In.z);
T ni = m_Weight / (helper.m_PrecalcSumSquares + SQR(helper.In.z)); T ni = m_Weight / (helper.m_PrecalcSumSquares + SQR(helper.In.z));
T s = std::sin(helper.In.x); T s = std::sin(helper.In.x);
T c = std::cos(helper.In.x); T c = std::cos(helper.In.x);
@ -3694,7 +3694,7 @@ public:
virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override
{ {
T absV = Hypot<T>(helper.In.y, helper.In.z); T absV = VarFuncs<T>::Hypot(helper.In.y, helper.In.z);
T ni = m_Weight / (helper.m_PrecalcSumSquares + SQR(helper.In.z)); T ni = m_Weight / (helper.m_PrecalcSumSquares + SQR(helper.In.z));
T s = std::sin(absV); T s = std::sin(absV);
T c = std::cos(absV); T c = std::cos(absV);
@ -3745,7 +3745,7 @@ public:
virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override
{ {
T absV = Hypot<T>(helper.In.y, helper.In.z); T absV = VarFuncs<T>::Hypot(helper.In.y, helper.In.z);
T e = std::exp(helper.In.x); T e = std::exp(helper.In.x);
T s = std::sin(absV); T s = std::sin(absV);
T c = std::cos(absV); T c = std::cos(absV);
@ -3795,7 +3795,7 @@ public:
virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override
{ {
T absV = Hypot<T>(helper.In.y, helper.In.z); T absV = VarFuncs<T>::Hypot(helper.In.y, helper.In.z);
T c = m_Weight * std::atan2(absV, helper.In.x) / absV; T c = m_Weight * std::atan2(absV, helper.In.x) / absV;
helper.Out.x = std::log(SQR(helper.In.x) + SQR(absV)) * m_Denom; helper.Out.x = std::log(SQR(helper.In.x) + SQR(absV)) * m_Denom;
helper.Out.y = c * helper.In.y; helper.Out.y = c * helper.In.y;
@ -3991,7 +3991,7 @@ public:
{ {
T xx = (rand.Frand01<T>() - T(0.5)) * 2; T xx = (rand.Frand01<T>() - T(0.5)) * 2;
T yy = (rand.Frand01<T>() - T(0.5)) * 2; T yy = (rand.Frand01<T>() - T(0.5)) * 2;
T k = SignNz(yy); T k = VarFuncs<T>::SignNz(yy);
T yymax = ((m_A * std::pow(std::abs(xx), m_P) + k * m_B * std::sqrt(std::abs(1 - SQR(xx)))) - m_A); T yymax = ((m_A * std::pow(std::abs(xx), m_P) + k * m_B * std::sqrt(std::abs(1 - SQR(xx)))) - m_A);
//The function must be in a range 0-1 to work properly. //The function must be in a range 0-1 to work properly.
yymax /= Zeps(std::abs(m_A) + std::abs(m_B)); yymax /= Zeps(std::abs(m_A) + std::abs(m_B));
@ -5039,10 +5039,10 @@ public:
T xmax = T(0.5) * (std::sqrt(tmp + x2) + std::sqrt(tmp - x2)); T xmax = T(0.5) * (std::sqrt(tmp + x2) + std::sqrt(tmp - x2));
T ymax = T(0.5) * (std::sqrt(tmp + y2) + std::sqrt(tmp - y2)); T ymax = T(0.5) * (std::sqrt(tmp + y2) + std::sqrt(tmp - y2));
T a = helper.In.x / Zeps(xmax); T a = helper.In.x / Zeps(xmax);
T b = SafeSqrt(1 - SQR(a)); T b = VarFuncs<T>::SafeSqrt(1 - SQR(a));
helper.Out.x = m_Vx * atan2(a, b) * r; helper.Out.x = m_Vx * atan2(a, b) * r;
a = helper.In.y / Zeps(ymax); a = helper.In.y / Zeps(ymax);
b = SafeSqrt(1 - SQR(a)); b = VarFuncs<T>::SafeSqrt(1 - SQR(a));
helper.Out.y = m_Vy * atan2(a, b) * r; helper.Out.y = m_Vy * atan2(a, b) * r;
helper.Out.z = DefaultZ(helper); helper.Out.z = DefaultZ(helper);
} }

View File

@ -95,7 +95,7 @@ public:
int n = int(Floor<T>(T(0.5) * helper.In.y / m_Sc)); int n = int(Floor<T>(T(0.5) * helper.In.y / m_Sc));
T x = helper.In.x - (m * 2 + 1) * m_Sc; T x = helper.In.x - (m * 2 + 1) * m_Sc;
T y = helper.In.y - (n * 2 + 1) * m_Sc; T y = helper.In.y - (n * 2 + 1) * m_Sc;
T u = Zeps(Hypot(x, y)); T u = Zeps(VarFuncs<T>::Hypot(x, y));
T v = (T(0.3) + T(0.7) * DiscreteNoise2(m + 10, n + 3)) * m_Sc; T v = (T(0.3) + T(0.7) * DiscreteNoise2(m + 10, n + 3)) * m_Sc;
T z1 = DiscreteNoise2(int(m + m_Seed), n); T z1 = DiscreteNoise2(int(m + m_Seed), n);
@ -283,7 +283,7 @@ public:
n = Floor<T>(T(0.5) * y / m_Sc); n = Floor<T>(T(0.5) * y / m_Sc);
x -= (m * 2 + 1) * m_Sc; x -= (m * 2 + 1) * m_Sc;
y -= (n * 2 + 1) * m_Sc; y -= (n * 2 + 1) * m_Sc;
u = Hypot(x, y); u = VarFuncs<T>::Hypot(x, y);
if (++iters > 10) if (++iters > 10)
break; break;
@ -404,7 +404,7 @@ public:
intmax_t n = Floor<T>(T(0.5) * uy / m_Sc); intmax_t n = Floor<T>(T(0.5) * uy / m_Sc);
x = ux - (m * 2 + 1) * m_Sc; x = ux - (m * 2 + 1) * m_Sc;
y = uy - (n * 2 + 1) * m_Sc; y = uy - (n * 2 + 1) * m_Sc;
u = Hypot(x, y); u = VarFuncs<T>::Hypot(x, y);
if ((DiscreteNoise2(int(m + m_Seed), int(n)) > m_Dens) || (u > (T(0.3) + T(0.7) * DiscreteNoise2(int(m + 10), int(n + 3))) * m_Sc)) if ((DiscreteNoise2(int(m + m_Seed), int(n)) > m_Dens) || (u > (T(0.3) + T(0.7) * DiscreteNoise2(int(m + 10), int(n + 3))) * m_Sc))
{ {
@ -512,6 +512,11 @@ public:
return vector<string> { "Hypot" }; return vector<string> { "Hypot" };
} }
virtual void Precalc() override
{
m_Sc = Zeps(m_Sc);
}
protected: protected:
void Init() void Init()
{ {
@ -2742,11 +2747,11 @@ public:
case 2://Log. case 2://Log.
default: default:
{ {
const T coeff = m_RMax <= EPS ? dist : dist + m_Alpha * (LogMap(dist) - dist); const T coeff = m_RMax <= EPS ? dist : dist + m_Alpha * (VarFuncs<T>::LogMap(dist) - dist);
helper.Out.x = helper.In.x + LogMap(m_MulX) * LogScale(random.x) * coeff; helper.Out.x = helper.In.x + VarFuncs<T>::LogMap(m_MulX) * VarFuncs<T>::LogScale(random.x) * coeff;
helper.Out.y = helper.In.y + LogMap(m_MulY) * LogScale(random.y) * coeff; helper.Out.y = helper.In.y + VarFuncs<T>::LogMap(m_MulY) * VarFuncs<T>::LogScale(random.y) * coeff;
helper.Out.z = helper.In.z + LogMap(m_MulZ) * LogScale(random.z) * coeff; helper.Out.z = helper.In.z + VarFuncs<T>::LogMap(m_MulZ) * VarFuncs<T>::LogScale(random.z) * coeff;
outPoint.m_ColorX = std::abs(fmod(outPoint.m_ColorX + LogMap(m_MulC) * LogScale(random.w) * coeff, T(1))); outPoint.m_ColorX = std::abs(fmod(outPoint.m_ColorX + VarFuncs<T>::LogMap(m_MulC) * VarFuncs<T>::LogScale(random.w) * coeff, T(1)));
} }
break; break;
} }

View File

@ -108,14 +108,14 @@ public:
T CsX = 1; T CsX = 1;
T CsY = 1; T CsY = 1;
T jcbSn = 0, jcbCn, jcbDn; T jcbSn = 0, jcbCn, jcbDn;
CsX = SafeDivInv(m_Unity, (m_Unity + Sqr(helper.In.x))); CsX = VarFuncs<T>::SafeDivInv(m_Unity, (m_Unity + Sqr(helper.In.x)));
CsX = CsX * m_Six + m_Scaleinfx; CsX = CsX * m_Six + m_Scaleinfx;
CsY = SafeDivInv(m_Unity, (m_Unity + Sqr(helper.In.y))); CsY = VarFuncs<T>::SafeDivInv(m_Unity, (m_Unity + Sqr(helper.In.y)));
CsY = CsY * m_Siy + m_Scaleinfy; CsY = CsY * m_Siy + m_Scaleinfy;
if (m_Pwx >= 0 && m_Pwx < 1e-4) if (m_Pwx >= 0 && m_Pwx < 1e-4)
{ {
m_VarFuncs->JacobiElliptic(helper.In.y * m_Freqx, m_Jacok, jcbSn, jcbCn, jcbDn); VarFuncs<T>::JacobiElliptic(helper.In.y * m_Freqx, m_Jacok, jcbSn, jcbCn, jcbDn);
helper.Out.x = m_Weight * (helper.In.x + CsX * jcbSn); helper.Out.x = m_Weight * (helper.In.x + CsX * jcbSn);
} }
else if (m_Pwx < 0 && m_Pwx > -1e-4) else if (m_Pwx < 0 && m_Pwx > -1e-4)
@ -126,11 +126,11 @@ public:
helper.Out.x = m_Weight * (helper.In.x + CsX * T(j1(helper.In.y * m_Freqx)));//This is not implemented in OpenCL. helper.Out.x = m_Weight * (helper.In.x + CsX * T(j1(helper.In.y * m_Freqx)));//This is not implemented in OpenCL.
#endif #endif
else else
helper.Out.x = m_Weight * (helper.In.x + CsX * std::sin(SignNz(helper.In.y) * std::pow(Zeps(std::abs(helper.In.y)), m_Pwx) * m_Freqx)); helper.Out.x = m_Weight * (helper.In.x + CsX * std::sin(VarFuncs<T>::SignNz(helper.In.y) * std::pow(Zeps(std::abs(helper.In.y)), m_Pwx) * m_Freqx));
if (m_Pwy >= 0 && m_Pwy < 1e-4) if (m_Pwy >= 0 && m_Pwy < 1e-4)
{ {
m_VarFuncs->JacobiElliptic(helper.In.x * m_Freqy, m_Jacok, jcbSn, jcbCn, jcbDn); VarFuncs<T>::JacobiElliptic(helper.In.x * m_Freqy, m_Jacok, jcbSn, jcbCn, jcbDn);
helper.Out.y = m_Weight * (helper.In.y + CsY * jcbSn); helper.Out.y = m_Weight * (helper.In.y + CsY * jcbSn);
} }
else if (m_Pwy < 0 && m_Pwy > -1e-4) else if (m_Pwy < 0 && m_Pwy > -1e-4)
@ -141,7 +141,7 @@ public:
helper.Out.y = m_Weight * (helper.In.y + CsY * T(j1(helper.In.x * m_Freqy))); helper.Out.y = m_Weight * (helper.In.y + CsY * T(j1(helper.In.x * m_Freqy)));
#endif #endif
else else
helper.Out.y = m_Weight * (helper.In.y + CsY * std::sin(SignNz(helper.In.x) * std::pow(Zeps(std::abs(helper.In.x)), m_Pwy) * m_Freqy)); helper.Out.y = m_Weight * (helper.In.y + CsY * std::sin(VarFuncs<T>::SignNz(helper.In.x) * std::pow(Zeps(std::abs(helper.In.x)), m_Pwy) * m_Freqy));
helper.Out.z = DefaultZ(helper); helper.Out.z = DefaultZ(helper);
} }
@ -213,7 +213,6 @@ protected:
void Init() void Init()
{ {
string prefix = Prefix(); string prefix = Prefix();
m_VarFuncs = VarFuncs<T>::Instance();
m_Params.clear(); m_Params.clear();
m_Params.push_back(ParamWithName<T>(&m_Freqx, prefix + "waves2b_freqx", 2)); m_Params.push_back(ParamWithName<T>(&m_Freqx, prefix + "waves2b_freqx", 2));
m_Params.push_back(ParamWithName<T>(&m_Freqy, prefix + "waves2b_freqy", 2)); m_Params.push_back(ParamWithName<T>(&m_Freqy, prefix + "waves2b_freqy", 2));
@ -242,7 +241,6 @@ private:
T m_Jacok; T m_Jacok;
T m_Six;//Precalc. T m_Six;//Precalc.
T m_Siy; T m_Siy;
shared_ptr<VarFuncs<T>> m_VarFuncs;
}; };
/// <summary> /// <summary>
@ -264,8 +262,8 @@ public:
T snx, cnx, dnx; T snx, cnx, dnx;
T sny, cny, dny; T sny, cny, dny;
T numX, numY, denom; T numX, numY, denom;
m_VarFuncs->JacobiElliptic(helper.In.x, m_K, snx, cnx, dnx); VarFuncs<T>::JacobiElliptic(helper.In.x, m_K, snx, cnx, dnx);
m_VarFuncs->JacobiElliptic(helper.In.y, 1 - m_K, sny, cny, dny); VarFuncs<T>::JacobiElliptic(helper.In.y, 1 - m_K, sny, cny, dny);
numX = cnx * cny; numX = cnx * cny;
numY = -dnx * snx * dny * sny; numY = -dnx * snx * dny * sny;
denom = SQR(snx) * SQR(sny) * m_K + SQR(cny); denom = SQR(snx) * SQR(sny) * m_K + SQR(cny);
@ -308,14 +306,12 @@ protected:
void Init() void Init()
{ {
string prefix = Prefix(); string prefix = Prefix();
m_VarFuncs = VarFuncs<T>::Instance();
m_Params.clear(); m_Params.clear();
m_Params.push_back(ParamWithName<T>(&m_K, prefix + "jac_cn_k", T(0.5), eParamType::REAL, -1, 1)); m_Params.push_back(ParamWithName<T>(&m_K, prefix + "jac_cn_k", T(0.5), eParamType::REAL, -1, 1));
} }
private: private:
T m_K; T m_K;
shared_ptr<VarFuncs<T>> m_VarFuncs;
}; };
/// <summary> /// <summary>
@ -337,8 +333,8 @@ public:
T snx, cnx, dnx; T snx, cnx, dnx;
T sny, cny, dny; T sny, cny, dny;
T numX, numY, denom; T numX, numY, denom;
m_VarFuncs->JacobiElliptic(helper.In.x, m_K, snx, cnx, dnx); VarFuncs<T>::JacobiElliptic(helper.In.x, m_K, snx, cnx, dnx);
m_VarFuncs->JacobiElliptic(helper.In.y, 1 - m_K, sny, cny, dny); VarFuncs<T>::JacobiElliptic(helper.In.y, 1 - m_K, sny, cny, dny);
numX = dnx * cny * dny; numX = dnx * cny * dny;
numY = -cnx * snx * sny * m_K; numY = -cnx * snx * sny * m_K;
denom = SQR(snx) * SQR(sny) * m_K + SQR(cny); denom = SQR(snx) * SQR(sny) * m_K + SQR(cny);
@ -381,14 +377,12 @@ protected:
void Init() void Init()
{ {
string prefix = Prefix(); string prefix = Prefix();
m_VarFuncs = VarFuncs<T>::Instance();
m_Params.clear(); m_Params.clear();
m_Params.push_back(ParamWithName<T>(&m_K, prefix + "jac_dn_k", T(0.5), eParamType::REAL, -1, 1)); m_Params.push_back(ParamWithName<T>(&m_K, prefix + "jac_dn_k", T(0.5), eParamType::REAL, -1, 1));
} }
private: private:
T m_K; T m_K;
shared_ptr<VarFuncs<T>> m_VarFuncs;
}; };
/// <summary> /// <summary>
@ -410,8 +404,8 @@ public:
T snx, cnx, dnx; T snx, cnx, dnx;
T sny, cny, dny; T sny, cny, dny;
T numX, numY, denom; T numX, numY, denom;
m_VarFuncs->JacobiElliptic(helper.In.x, m_K, snx, cnx, dnx); VarFuncs<T>::JacobiElliptic(helper.In.x, m_K, snx, cnx, dnx);
m_VarFuncs->JacobiElliptic(helper.In.y, 1 - m_K, sny, cny, dny); VarFuncs<T>::JacobiElliptic(helper.In.y, 1 - m_K, sny, cny, dny);
numX = snx * dny; numX = snx * dny;
numY = cnx * dnx * cny * sny; numY = cnx * dnx * cny * sny;
denom = SQR(snx) * SQR(sny) * m_K + SQR(cny); denom = SQR(snx) * SQR(sny) * m_K + SQR(cny);
@ -454,14 +448,12 @@ protected:
void Init() void Init()
{ {
string prefix = Prefix(); string prefix = Prefix();
m_VarFuncs = VarFuncs<T>::Instance();
m_Params.clear(); m_Params.clear();
m_Params.push_back(ParamWithName<T>(&m_K, prefix + "jac_sn_k", T(0.5), eParamType::REAL, -1, 1)); m_Params.push_back(ParamWithName<T>(&m_K, prefix + "jac_sn_k", T(0.5), eParamType::REAL, -1, 1));
} }
private: private:
T m_K; T m_K;
shared_ptr<VarFuncs<T>> m_VarFuncs;
}; };
/// <summary> /// <summary>

View File

@ -517,8 +517,8 @@ public:
virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override
{ {
T x = LRint(helper.In.x); T x = VarFuncs<T>::LRint(helper.In.x);
T y = LRint(helper.In.y); T y = VarFuncs<T>::LRint(helper.In.y);
T c = outPoint.m_ColorX; T c = outPoint.m_ColorX;
if (y <= 0) if (y <= 0)

View File

@ -602,9 +602,9 @@ void FractoriumEmberController<T>::FillAffineWithXform(Xform<T>* xform, bool pre
spinners[0]->SetValueStealth(RAD_2_DEG * atan2(affine.D(), affine.A())); spinners[0]->SetValueStealth(RAD_2_DEG * atan2(affine.D(), affine.A()));
spinners[1]->SetValueStealth(RAD_2_DEG * atan2(affine.E(), affine.B())); spinners[1]->SetValueStealth(RAD_2_DEG * atan2(affine.E(), affine.B()));
spinners[2]->SetValueStealth(RAD_2_DEG * atan2(affine.F(), affine.C())); spinners[2]->SetValueStealth(RAD_2_DEG * atan2(affine.F(), affine.C()));
spinners[3]->SetValueStealth(Hypot(affine.D(), affine.A())); spinners[3]->SetValueStealth(VarFuncs<T>::Hypot(affine.D(), affine.A()));
spinners[4]->SetValueStealth(Hypot(affine.E(), affine.B())); spinners[4]->SetValueStealth(VarFuncs<T>::Hypot(affine.E(), affine.B()));
spinners[5]->SetValueStealth(Hypot(affine.F(), affine.C())); spinners[5]->SetValueStealth(VarFuncs<T>::Hypot(affine.F(), affine.C()));
} }
else else
{ {