diff --git a/Builds/MSVC/VS2013/Ember.vcxproj b/Builds/MSVC/VS2013/Ember.vcxproj index 3160a48..0688dec 100644 --- a/Builds/MSVC/VS2013/Ember.vcxproj +++ b/Builds/MSVC/VS2013/Ember.vcxproj @@ -299,6 +299,7 @@ + diff --git a/Builds/MSVC/VS2013/Ember.vcxproj.filters b/Builds/MSVC/VS2013/Ember.vcxproj.filters index fb9f959..c5bda1e 100644 --- a/Builds/MSVC/VS2013/Ember.vcxproj.filters +++ b/Builds/MSVC/VS2013/Ember.vcxproj.filters @@ -122,6 +122,9 @@ Header Files + + Header Files\Variations + diff --git a/Builds/QtCreator/Ember/Ember.pro b/Builds/QtCreator/Ember/Ember.pro index bf31d8f..9f0ea05 100644 --- a/Builds/QtCreator/Ember/Ember.pro +++ b/Builds/QtCreator/Ember/Ember.pro @@ -59,6 +59,7 @@ HEADERS += \ $$PRJ_DIR/Variations04.h \ $$PRJ_DIR/Variations05.h \ $$PRJ_DIR/Variations06.h \ + $$PRJ_DIR/Variations07.h \ $$PRJ_DIR/VariationsDC.h \ $$PRJ_DIR/VarFuncs.h \ $$PRJ_DIR/Xform.h \ diff --git a/Builds/QtCreator/defaults.pri b/Builds/QtCreator/defaults.pri index 917a1e7..e458994 100644 --- a/Builds/QtCreator/defaults.pri +++ b/Builds/QtCreator/defaults.pri @@ -14,16 +14,21 @@ unix|macx { #This cannot be this... #EMBER_ROOT = $$(PWD)/../../.. #It must be this... -EMBER_ROOT = ./../../../ +win32:{ +EMBER_ROOT = ./../../ +} +unix|macx{ +EMBER_ROOT = ./../../.. +} # When compiling from project root autobuild { - EMBER_ROOT = $$(PWD)/../.. +# EMBER_ROOT = $$(PWD)/../.. } win32:{ - EMBER_ROOT = $$(PWD)../../.. - EXTERNAL_DIR = $$(PWD)../../../../External - EXTERNAL_LIB = $$(PWD)../../../External/libs + #EMBER_ROOT = $$(PWD)../../.. + EXTERNAL_DIR = $$(EMBER_ROOT)/../ + EXTERNAL_LIB = $$(EMBER_ROOT)/../ # EXTERNAL_DIR which contains Third Party Codes is in the parent folder of "fractorium" # EXTERNAL_LIB is in EXTERNAL_DIR actually, but it is strange that EXTERNAL_DIR must go # one more step upper than EXTERNAL_LIB to get it work @@ -32,8 +37,8 @@ win32:{ SHARE_INSTALL_DIR = $$(PWD)../../../Install/share/fractorium # INSTALL_DIRs Don't work? message(EMBER_ROOT: $$absolute_path($$EMBER_ROOT)) - message(EXTERNAL: $$absolute_path($$EXTERNAL_DIR)) - message(EXTERNAL_LIB:$$absolute_path($$EXTERNAL_LIB) ) + message(EXTERNAL_DIR: $$absolute_path($$EXTERNAL_DIR)) + message(EXTERNAL_LIB: $$absolute_path($$EXTERNAL_LIB) ) } message(EMBER_ROOT: $$EMBER_ROOT) diff --git a/Data/Variations.xlsx b/Data/Variations.xlsx index 040dd5c..4563f8e 100644 Binary files a/Data/Variations.xlsx and b/Data/Variations.xlsx differ diff --git a/Data/dark.qss b/Data/dark.qss index 069ddec..b215a6b 100644 --- a/Data/dark.qss +++ b/Data/dark.qss @@ -537,6 +537,7 @@ QTableWidget#ColorTableHeader QHeaderView::section::horizontal, QTableWidget#GeometryTableHeader QHeaderView::section::horizontal, QTableWidget#FilterTableHeader QHeaderView::section::horizontal, QTableWidget#IterationTableHeader QHeaderView::section::horizontal, +QTableWidget#AnimationTableHeader QHeaderView::section::horizontal, QTreeWidget#LibraryTree QHeaderView::section::horizontal { border-right: none; @@ -546,6 +547,7 @@ QTableWidget#ColorTable, QTableWidget#GeometryTable, QTableWidget#FilterTable, QTableWidget#IterationTable, +QTableWidget#AnimationTable, QTableWidget#XformWeightNameTable { border-left: 1px solid gray; @@ -617,4 +619,3 @@ QTableView#FinalRenderParamsTable QPushButton margin-bottom: 2px; padding: 0px; } - \ No newline at end of file diff --git a/Source/Ember/Ember.cpp b/Source/Ember/Ember.cpp index 5b7ab1f..7161b8e 100644 --- a/Source/Ember/Ember.cpp +++ b/Source/Ember/Ember.cpp @@ -23,6 +23,7 @@ template<> CriticalSection QTIsaac::m_CS = CriticalSectio #include "Variations04.h" #include "Variations05.h" #include "Variations06.h" +#include "Variations07.h" #include "VariationsDC.h" #include "VariationList.h" #include "Affine2D.h" @@ -379,6 +380,21 @@ uint Timing::m_ProcessorCount; EXPORTPREPOSTREGVAR(BubbleT3D, T) \ EXPORTPREPOSTREGVAR(Synth, T) \ EXPORTPREPOSTREGVAR(Crackle, T) \ + EXPORTPREPOSTREGVAR(Erf, T) \ + EXPORTPREPOSTREGVAR(Xerf, T) \ + EXPORTPREPOSTREGVAR(W, T) \ + EXPORTPREPOSTREGVAR(X, T) \ + EXPORTPREPOSTREGVAR(Y, T) \ + EXPORTPREPOSTREGVAR(Z, T) \ + EXPORTPREPOSTREGVAR(Splits3D, T) \ + EXPORTPREPOSTREGVAR(Waves2B, T) \ + EXPORTPREPOSTREGVAR(JacCn, T) \ + EXPORTPREPOSTREGVAR(JacDn, T) \ + EXPORTPREPOSTREGVAR(JacSn, T) \ + EXPORTPREPOSTREGVAR(PressureWave, T) \ + EXPORTPREPOSTREGVAR(Gamma, T) \ + EXPORTPREPOSTREGVAR(PRose3D, T) \ + EXPORTPREPOSTREGVAR(LogDB, T) \ template EMBER_API class PostSmartcropVariation; /*Only implemented as post.*/ \ EXPORTPREPOSTREGVAR(DCBubble, T) \ EXPORTPREPOSTREGVAR(DCCarpet, T) \ diff --git a/Source/Ember/Ember.h b/Source/Ember/Ember.h index 732c63a..0608c34 100644 --- a/Source/Ember/Ember.h +++ b/Source/Ember/Ember.h @@ -1794,7 +1794,7 @@ private: for (size_t k = 0; k < size; k++) t += coefs[k] * embers[k].*m; - this->*m = size_t(Rint(t)); + this->*m = size_t(std::rint(t)); } /// diff --git a/Source/Ember/EmberDefines.h b/Source/Ember/EmberDefines.h index 77558f9..1b4d3f9 100644 --- a/Source/Ember/EmberDefines.h +++ b/Source/Ember/EmberDefines.h @@ -64,7 +64,6 @@ namespace EmberNs #define CX(c) (reinterpret_cast(c)) #define CCX(c) (reinterpret_cast(c)) #define BadVal(x) (((x) != (x)) || ((x) > 1e10) || ((x) < -1e10)) -#define Rint(A) floor((A) + (((A) < 0) ? T(-0.5) : T(0.5))) #define Vlen(x) (sizeof(x) / sizeof(*x)) #define SQR(x) ((x) * (x)) #define CUBE(x) ((x) * (x) * (x)) diff --git a/Source/Ember/EmberToXml.h b/Source/Ember/EmberToXml.h index 858f2cc..2dcc99e 100644 --- a/Source/Ember/EmberToXml.h +++ b/Source/Ember/EmberToXml.h @@ -270,9 +270,9 @@ public: for (j = 0; j < 8; j++) { size_t idx = 8 * i + j; - os << hex << setw(2) << setfill('0') << int(Rint(ember.m_Palette[idx][0] * 255)); - os << hex << setw(2) << setfill('0') << int(Rint(ember.m_Palette[idx][1] * 255)); - os << hex << setw(2) << setfill('0') << int(Rint(ember.m_Palette[idx][2] * 255)); + os << hex << setw(2) << setfill('0') << int(std::rint(ember.m_Palette[idx][0] * 255)); + os << hex << setw(2) << setfill('0') << int(std::rint(ember.m_Palette[idx][1] * 255)); + os << hex << setw(2) << setfill('0') << int(std::rint(ember.m_Palette[idx][2] * 255)); } os << endl; @@ -294,14 +294,14 @@ public: if (IsClose(a, 255.0)) { if (intPalette) - os << ""; + os << ""; else os << ""; } else { if (intPalette) - os << " "; + os << " "; else os << " "; } diff --git a/Source/Ember/Utils.h b/Source/Ember/Utils.h index 6f10e9c..02d8b0e 100644 --- a/Source/Ember/Utils.h +++ b/Source/Ember/Utils.h @@ -658,6 +658,22 @@ double SafeTan(double x) return std::tan(x); } +/// +/// If r < EPS, return 1 / r. +/// Else, return q / r. +/// +/// The numerator +/// The denominator +/// The quotient +template +static inline T SafeDivInv(T q, T r) +{ + if (r < EPS) + return 1 / r; + + return q / r; +} + /// /// Return the cube of the passed in value. /// This is useful when the value is a result of a computation diff --git a/Source/Ember/VarFuncs.h b/Source/Ember/VarFuncs.h index c621e6b..a607bb4 100644 --- a/Source/Ember/VarFuncs.h +++ b/Source/Ember/VarFuncs.h @@ -255,7 +255,7 @@ public: if (pmq.x == 0 && pmq.y == 0) return 1; - return 2 * ((u.x - q.x) * pmq.x + (u.y - q.y) * pmq.y) / (SQR(pmq.x) + SQR(pmq.y)); + return 2 * ((u.x - q.x) * pmq.x + (u.y - q.y) * pmq.y) / Zeps(SQR(pmq.x) + SQR(pmq.y)); } /// @@ -279,6 +279,99 @@ public: return ratiomax; } + /// + /// Used in the jac_* variations. + /// + static void JacobiElliptic(T uu, T emmc, T& sn, T& cn, T& dn) + { + //Code is taken from IROIRO++ library, + //released under CC share-alike license. + //Less accurate for faster rendering (still very precise). + T const CA = T(0.0003);//The accuracy is the square of CA. + T a, b, c, d, em[13], en[13]; + int bo; + int l; + int ii; + int i; + T emc = emmc; + T u = uu; + + if (emc != 0) + { + bo = 0; + + if (emc < 0) + bo = 1; + + if (bo != 0) + { + d = 1 - emc; + emc = -emc / d; + d = std::sqrt(d); + u = d * u; + } + + a = 1; + dn = 1; + + for (i = 0; i < 8; i++) + { + l = i; + em[i] = a; + emc = std::sqrt(emc); + en[i] = emc; + c = T(0.5) * (a + emc); + + if (std::abs(a - emc) <= CA * a) + break; + + emc = a * emc; + a = c; + } + + u = c * u; + sincos(u, &sn, &cn); + + if (sn != 0) + { + a = cn / sn; + c = a * c; + + for (ii = l; ii >= 0; --ii) + { + b = em[ii]; + a = c * a; + c = dn * c; + dn = (en[ii] + a) / (b + a); + a = c / b; + } + + a = 1 / std::sqrt(c * c + 1); + + if (sn < 0) + sn = -a; + else + sn = a; + + cn = c * sn; + } + + if (bo != 0) + { + a = dn; + dn = cn; + cn = a; + sn = sn / d; + } + } + else + { + cn = 1 / std::cosh(u); + dn = cn; + sn = std::tanh(u); + } + } + SINGLETON_DERIVED_IMPL(VarFuncs); private: diff --git a/Source/Ember/Variation.h b/Source/Ember/Variation.h index f08c358..7cbb5a7 100644 --- a/Source/Ember/Variation.h +++ b/Source/Ember/Variation.h @@ -136,6 +136,7 @@ enum class eVariationId : et VAR_ENNEPERS , VAR_EPISPIRAL , VAR_EPUSH , + VAR_ERF , VAR_EROTATE , VAR_ESCALE , VAR_ESCHER , @@ -166,6 +167,7 @@ enum class eVariationId : et VAR_FOCI3D , VAR_FOURTH , VAR_FUNNEL , + VAR_GAMMA , VAR_GAUSSIAN_BLUR , VAR_GDOFFS , VAR_GLYNNIA , @@ -193,6 +195,9 @@ enum class eVariationId : et VAR_HYPERTILE3D2 , VAR_IDISC , VAR_INTERFERENCE2 , + VAR_JAC_CN , + VAR_JAC_DN , + VAR_JAC_SN , VAR_JULIA , VAR_JULIA3D , VAR_JULIA3DQ , @@ -216,6 +221,7 @@ enum class eVariationId : et VAR_LINEAR3D , VAR_LISSAJOUS , VAR_LOG , + VAR_LOG_DB , VAR_LOQ , VAR_LOONIE , VAR_LOONIE2 , @@ -260,6 +266,8 @@ enum class eVariationId : et VAR_POPCORN23D , VAR_POW_BLOCK , VAR_POWER , + VAR_PRESSURE_WAVE , + VAR_PROSE3D , VAR_PSPHERE , VAR_Q_ODE , VAR_RADIAL_BLUR , @@ -308,6 +316,7 @@ enum class eVariationId : et VAR_SPLIT , VAR_SPLIT_BRDR , VAR_SPLITS , + VAR_SPLITS3D , VAR_SQUARE , VAR_SQUARE3D , VAR_SQUARIZE , @@ -336,18 +345,24 @@ enum class eVariationId : et VAR_TWO_FACE , VAR_UNPOLAR , VAR_VORON , + VAR_W , VAR_WAFFLE , VAR_WAVES , VAR_WAVES2 , VAR_WAVES23D , + VAR_WAVES2B , VAR_WAVESN , VAR_WDISC , VAR_WEDGE , VAR_WEDGE_JULIA , VAR_WEDGE_SPH , VAR_WHORL , + VAR_X , + VAR_XERF , VAR_XHEART , VAR_XTRB , + VAR_Y , + VAR_Z , VAR_ZBLUR , VAR_ZCONE , VAR_ZSCALE , @@ -445,6 +460,7 @@ enum class eVariationId : et VAR_PRE_ENNEPERS, VAR_PRE_EPISPIRAL, VAR_PRE_EPUSH, + VAR_PRE_ERF, VAR_PRE_EROTATE, VAR_PRE_ESCALE, VAR_PRE_ESCHER, @@ -475,6 +491,7 @@ enum class eVariationId : et VAR_PRE_FOCI3D, VAR_PRE_FOURTH, VAR_PRE_FUNNEL, + VAR_PRE_GAMMA, VAR_PRE_GAUSSIAN_BLUR, VAR_PRE_GDOFFS, VAR_PRE_GLYNNIA, @@ -502,6 +519,9 @@ enum class eVariationId : et VAR_PRE_HYPERTILE3D2, VAR_PRE_IDISC, VAR_PRE_INTERFERENCE2, + VAR_PRE_JAC_CN, + VAR_PRE_JAC_DN, + VAR_PRE_JAC_SN, VAR_PRE_JULIA, VAR_PRE_JULIA3D, VAR_PRE_JULIA3DQ, @@ -525,6 +545,7 @@ enum class eVariationId : et VAR_PRE_LINEAR3D, VAR_PRE_LISSAJOUS, VAR_PRE_LOG, + VAR_PRE_LOG_DB, VAR_PRE_LOQ, VAR_PRE_LOONIE, VAR_PRE_LOONIE2, @@ -569,6 +590,8 @@ enum class eVariationId : et VAR_PRE_POPCORN23D, VAR_PRE_POW_BLOCK, VAR_PRE_POWER, + VAR_PRE_PRESSURE_WAVE, + VAR_PRE_PROSE3D, VAR_PRE_PSPHERE, VAR_PRE_Q_ODE, VAR_PRE_RADIAL_BLUR, @@ -617,6 +640,7 @@ enum class eVariationId : et VAR_PRE_SPLIT, VAR_PRE_SPLIT_BRDR, VAR_PRE_SPLITS, + VAR_PRE_SPLITS3D, VAR_PRE_SQUARE, VAR_PRE_SQUARE3D, VAR_PRE_SQUARIZE, @@ -645,18 +669,24 @@ enum class eVariationId : et VAR_PRE_TWO_FACE, VAR_PRE_UNPOLAR, VAR_PRE_VORON, + VAR_PRE_W, VAR_PRE_WAFFLE, VAR_PRE_WAVES, VAR_PRE_WAVES2, VAR_PRE_WAVES23D, + VAR_PRE_WAVES2B, VAR_PRE_WAVESN, VAR_PRE_WDISC, VAR_PRE_WEDGE, VAR_PRE_WEDGE_JULIA, VAR_PRE_WEDGE_SPH, VAR_PRE_WHORL, + VAR_PRE_X, + VAR_PRE_XERF, VAR_PRE_XHEART, VAR_PRE_XTRB, + VAR_PRE_Y, + VAR_PRE_Z, VAR_PRE_ZBLUR, VAR_PRE_ZCONE, VAR_PRE_ZSCALE, @@ -754,6 +784,7 @@ enum class eVariationId : et VAR_POST_ENNEPERS, VAR_POST_EPISPIRAL, VAR_POST_EPUSH, + VAR_POST_ERF, VAR_POST_EROTATE, VAR_POST_ESCALE, VAR_POST_ESCHER, @@ -784,6 +815,7 @@ enum class eVariationId : et VAR_POST_FOCI3D, VAR_POST_FOURTH, VAR_POST_FUNNEL, + VAR_POST_GAMMA, VAR_POST_GAUSSIAN_BLUR, VAR_POST_GDOFFS, VAR_POST_GLYNNIA, @@ -811,6 +843,9 @@ enum class eVariationId : et VAR_POST_HYPERTILE3D2, VAR_POST_IDISC, VAR_POST_INTERFERENCE2, + VAR_POST_JAC_CN, + VAR_POST_JAC_DN, + VAR_POST_JAC_SN, VAR_POST_JULIA, VAR_POST_JULIA3D, VAR_POST_JULIA3DQ, @@ -834,6 +869,7 @@ enum class eVariationId : et VAR_POST_LINEAR3D, VAR_POST_LISSAJOUS, VAR_POST_LOG, + VAR_POST_LOG_DB, VAR_POST_LOQ, VAR_POST_LOONIE, VAR_POST_LOONIE2, @@ -878,6 +914,8 @@ enum class eVariationId : et VAR_POST_POPCORN23D, VAR_POST_POW_BLOCK, VAR_POST_POWER, + VAR_POST_PRESSURE_WAVE, + VAR_POST_PROSE3D, VAR_POST_PSPHERE, VAR_POST_Q_ODE, VAR_POST_RADIAL_BLUR, @@ -926,6 +964,7 @@ enum class eVariationId : et VAR_POST_SPLIT, VAR_POST_SPLIT_BRDR, VAR_POST_SPLITS, + VAR_POST_SPLITS3D, VAR_POST_SQUARE, VAR_POST_SQUARE3D, VAR_POST_SQUARIZE, @@ -954,18 +993,24 @@ enum class eVariationId : et VAR_POST_TWO_FACE, VAR_POST_UNPOLAR, VAR_POST_VORON, + VAR_POST_W, VAR_POST_WAFFLE, VAR_POST_WAVES, VAR_POST_WAVES2, VAR_POST_WAVES23D, + VAR_POST_WAVES2B, VAR_POST_WAVESN, VAR_POST_WDISC, VAR_POST_WEDGE, VAR_POST_WEDGE_JULIA, VAR_POST_WEDGE_SPH, VAR_POST_WHORL, + VAR_POST_X, + VAR_POST_XERF, VAR_POST_XHEART, VAR_POST_XTRB, + VAR_POST_Y, + VAR_POST_Z, VAR_POST_ZBLUR, VAR_POST_ZCONE, VAR_POST_ZSCALE, @@ -1077,7 +1122,7 @@ public: m_NeedPrecalcSqrtSumSquares = true; } - m_AssignType = eVariationAssignType::ASSIGNTYPE_SET; + m_PrePostAssignType = eVariationAssignType::ASSIGNTYPE_SET; SetType(); } @@ -1131,7 +1176,7 @@ public: { m_Name = variation.Name(); m_VarType = variation.VarType(); - m_AssignType = variation.AssignType(); + m_PrePostAssignType = variation.AssignType(); m_VariationId = variation.VariationId(); m_Weight = T(variation.m_Weight); m_Xform = typeid(T) == typeid(U) ? const_cast*>(reinterpret_cast*>(variation.ParentXform())) : nullptr; @@ -1147,115 +1192,60 @@ public: /// Per-variation precalc used for pre and post variations. /// /// The helper to read values from in the case of pre, and store precalc values to in both cases. - /// The point to read values from in the case of post, ignored for pre. - void PrecalcHelper(IteratorHelper& iteratorHelper, Point* point) + void PrePostPrecalcHelper(IteratorHelper& iteratorHelper) { - if (m_VarType == eVariationType::VARTYPE_PRE) + if (m_NeedPrecalcSumSquares) { - if (m_NeedPrecalcSumSquares) + iteratorHelper.m_PrecalcSumSquares = SQR(iteratorHelper.In.x) + SQR(iteratorHelper.In.y); + + if (m_NeedPrecalcSqrtSumSquares) { - iteratorHelper.m_PrecalcSumSquares = SQR(iteratorHelper.m_TransX) + SQR(iteratorHelper.m_TransY); + iteratorHelper.m_PrecalcSqrtSumSquares = std::sqrt(iteratorHelper.m_PrecalcSumSquares); - if (m_NeedPrecalcSqrtSumSquares) + if (m_NeedPrecalcAngles) { - iteratorHelper.m_PrecalcSqrtSumSquares = std::sqrt(iteratorHelper.m_PrecalcSumSquares); - - if (m_NeedPrecalcAngles) - { - iteratorHelper.m_PrecalcSina = iteratorHelper.m_TransX / iteratorHelper.m_PrecalcSqrtSumSquares; - iteratorHelper.m_PrecalcCosa = iteratorHelper.m_TransY / iteratorHelper.m_PrecalcSqrtSumSquares; - } + iteratorHelper.m_PrecalcSina = iteratorHelper.In.x / iteratorHelper.m_PrecalcSqrtSumSquares; + iteratorHelper.m_PrecalcCosa = iteratorHelper.In.y / iteratorHelper.m_PrecalcSqrtSumSquares; } } - - if (m_NeedPrecalcAtanXY) - iteratorHelper.m_PrecalcAtanxy = atan2(iteratorHelper.m_TransX, iteratorHelper.m_TransY); - - if (m_NeedPrecalcAtanYX) - iteratorHelper.m_PrecalcAtanyx = atan2(iteratorHelper.m_TransY, iteratorHelper.m_TransX); } - else if (m_VarType == eVariationType::VARTYPE_POST) - { - if (m_NeedPrecalcSumSquares) - { - iteratorHelper.m_PrecalcSumSquares = SQR(point->m_X) + SQR(point->m_Y); - if (m_NeedPrecalcSqrtSumSquares) - { - iteratorHelper.m_PrecalcSqrtSumSquares = std::sqrt(iteratorHelper.m_PrecalcSumSquares); + if (m_NeedPrecalcAtanXY) + iteratorHelper.m_PrecalcAtanxy = atan2(iteratorHelper.In.x, iteratorHelper.In.y); - if (m_NeedPrecalcAngles) - { - iteratorHelper.m_PrecalcSina = point->m_X / iteratorHelper.m_PrecalcSqrtSumSquares; - iteratorHelper.m_PrecalcCosa = point->m_Y / iteratorHelper.m_PrecalcSqrtSumSquares; - } - } - } - - if (m_NeedPrecalcAtanXY) - iteratorHelper.m_PrecalcAtanxy = atan2(point->m_X, point->m_Y); - - if (m_NeedPrecalcAtanYX) - iteratorHelper.m_PrecalcAtanyx = atan2(point->m_Y, point->m_X); - } + if (m_NeedPrecalcAtanYX) + iteratorHelper.m_PrecalcAtanyx = atan2(iteratorHelper.In.y, iteratorHelper.In.x); } /// /// Per-variation precalc OpenCL string used for pre and post variations. /// /// The per-variation OpenCL precalc string - string PrecalcOpenCLString() const + string PrePostPrecalcOpenCLString() const { ostringstream ss; - if (m_VarType == eVariationType::VARTYPE_PRE) + if (m_NeedPrecalcSumSquares) { - if (m_NeedPrecalcSumSquares) + ss << "\tprecalcSumSquares = SQR(vIn.x) + SQR(vIn.y);\n"; + + if (m_NeedPrecalcSqrtSumSquares) { - ss << "\tprecalcSumSquares = SQR(transX) + SQR(transY);\n"; + ss << "\tprecalcSqrtSumSquares = sqrt(precalcSumSquares);\n"; - if (m_NeedPrecalcSqrtSumSquares) + if (m_NeedPrecalcAngles) { - ss << "\tprecalcSqrtSumSquares = sqrt(precalcSumSquares);\n"; - - if (m_NeedPrecalcAngles) - { - ss << "\tprecalcSina = transX / precalcSqrtSumSquares;\n"; - ss << "\tprecalcCosa = transY / precalcSqrtSumSquares;\n"; - } + ss << "\tprecalcSina = vIn.x / precalcSqrtSumSquares;\n"; + ss << "\tprecalcCosa = vIn.y / precalcSqrtSumSquares;\n"; } } - - if (m_NeedPrecalcAtanXY) - ss << "\tprecalcAtanxy = atan2(transX, transY);\n"; - - if (m_NeedPrecalcAtanYX) - ss << "\tprecalcAtanyx = atan2(transY, transX);\n"; } - else if (m_VarType == eVariationType::VARTYPE_POST) - { - if (m_NeedPrecalcSumSquares) - { - ss << "\tprecalcSumSquares = SQR(outPoint->m_X) + SQR(outPoint->m_Y);\n"; - if (m_NeedPrecalcSqrtSumSquares) - { - ss << "\tprecalcSqrtSumSquares = sqrt(precalcSumSquares);\n"; + if (m_NeedPrecalcAtanXY) + ss << "\tprecalcAtanxy = atan2(vIn.x, vIn.y);\n"; - if (m_NeedPrecalcAngles) - { - ss << "\tprecalcSina = outPoint->m_X / precalcSqrtSumSquares;\n"; - ss << "\tprecalcCosa = outPoint->m_Y / precalcSqrtSumSquares;\n"; - } - } - } - - if (m_NeedPrecalcAtanXY) - ss << "\tprecalcAtanxy = atan2(outPoint->m_X, outPoint->m_Y);\n"; - - if (m_NeedPrecalcAtanYX) - ss << "\tprecalcAtanyx = atan2(outPoint->m_Y, outPoint->m_X);\n"; - } + if (m_NeedPrecalcAtanYX) + ss << "\tprecalcAtanyx = atan2(vIn.y, vIn.x);\n"; if (NeedAnyPrecalc()) ss << "\n"; @@ -1393,6 +1383,10 @@ public: return ""; } + /// + /// Returns the base name of the variation without the "pre_" or "post_" prefix. + /// + /// The base name of the variation string BaseName() const { string prefix = Prefix(); @@ -1415,7 +1409,7 @@ public: eVariationId VariationId() const { return m_VariationId; } string Name() const { return m_Name; } eVariationType VarType() const { return m_VarType; } - eVariationAssignType AssignType() const { return m_AssignType; } + eVariationAssignType AssignType() const { return m_PrePostAssignType; } const Xform* ParentXform() const { return m_Xform; } void ParentXform(Xform* xform) { m_Xform = xform; } intmax_t IndexInXform() const { return m_Xform ? m_Xform->GetVariationIndex(const_cast*>(this)) : -1; } @@ -1424,6 +1418,10 @@ public: T m_Weight;//The weight of the variation. protected: + /// + /// Sets the type of the variation depending on whether the name starts with "pre_", + /// "post_" or neither. + /// void SetType() { if (m_Name.find("pre_") == 0) @@ -1434,11 +1432,30 @@ protected: m_VarType = eVariationType::VARTYPE_REG; } + /// + /// Return the default Z coordinate assignment value depending on the type of variation and its assign type. + /// + /// The helper used to retrieve the input Z coordinate. + /// The appropriate Z value. + T DefaultZ(const IteratorHelper& helper) const + { + return m_VarType == eVariationType::VARTYPE_REG ? 0 : (m_PrePostAssignType == eVariationAssignType::ASSIGNTYPE_SET ? helper.In.z : 0); + } + + /// + /// OpenCL equivalent of DefaultZ(). + /// + /// The OpenCL string needed to make the proper Z coordinate assignment + string DefaultZCl() const + { + return m_VarType == eVariationType::VARTYPE_REG ? "0;\n" : (m_PrePostAssignType == eVariationAssignType::ASSIGNTYPE_SET ? "vIn.z;\n" : "0;\n"); + } + Xform* m_Xform;//The parent Xform that this variation is a child of. eVariationId m_VariationId;//The unique ID of this variation. string m_Name;//The unique name of this variation. eVariationType m_VarType;//The type of variation: regular, pre or post. - eVariationAssignType m_AssignType;//Whether to assign the results for pre/post, or sum them. + eVariationAssignType m_PrePostAssignType;//Whether to assign the results for pre/post, or sum them. private: bool m_NeedPrecalcSumSquares;//Whether this variation uses the precalc sum squares value in its calculations. @@ -1750,13 +1767,15 @@ private: using Variation::m_VariationId; \ using Variation::m_Name; \ using Variation::m_VarType; \ - using Variation::m_AssignType; \ + using Variation::m_PrePostAssignType; \ using Variation::SetType; \ using Variation::IndexInXform; \ using Variation::XformIndexInEmber; \ using Variation::Prefix; \ using Variation::Precalc; \ - using Variation::StateOpenCLString; + using Variation::StateOpenCLString; \ + using Variation::DefaultZ; \ + using Variation::DefaultZCl; /// /// Parametric variations use parameters in addition to weight. @@ -2147,7 +2166,7 @@ protected: { \ m_VariationId = eVariationId::VAR_PRE_##enumName; \ m_Name = "pre_"#stringName; \ - m_AssignType = assignType; \ + m_PrePostAssignType = assignType; \ SetType(); \ } \ \ @@ -2163,7 +2182,7 @@ protected: { \ m_VariationId = eVariationId::VAR_POST_##enumName; \ m_Name = "post_"#stringName; \ - m_AssignType = assignType; \ + m_PrePostAssignType = assignType; \ SetType(); \ } \ \ @@ -2268,7 +2287,7 @@ protected: { \ m_VariationId = eVariationId::VAR_PRE_##enumName; \ m_Name = "pre_"#stringName; \ - m_AssignType = assignType; \ + m_PrePostAssignType = assignType; \ SetType(); \ Init(); \ } \ @@ -2287,7 +2306,7 @@ protected: { \ m_VariationId = eVariationId::VAR_POST_##enumName; \ m_Name = "post_"#stringName; \ - m_AssignType = assignType; \ + m_PrePostAssignType = assignType; \ SetType(); \ Init(); \ } \ diff --git a/Source/Ember/VariationList.h b/Source/Ember/VariationList.h index 8d17269..c993c94 100644 --- a/Source/Ember/VariationList.h +++ b/Source/Ember/VariationList.h @@ -6,6 +6,7 @@ #include "Variations04.h" #include "Variations05.h" #include "Variations06.h" +#include "Variations07.h" #include "VariationsDC.h" /// @@ -343,6 +344,21 @@ public: ADDPREPOSTREGVAR(Synth) ADDPREPOSTREGVAR(Crackle) m_Variations.push_back(new PostSmartcropVariation());//Post only + ADDPREPOSTREGVAR(Xerf) + ADDPREPOSTREGVAR(Erf) + ADDPREPOSTREGVAR(W) + ADDPREPOSTREGVAR(X) + ADDPREPOSTREGVAR(Y) + ADDPREPOSTREGVAR(Z) + ADDPREPOSTREGVAR(Splits3D) + ADDPREPOSTREGVAR(Waves2B) + ADDPREPOSTREGVAR(JacCn) + ADDPREPOSTREGVAR(JacDn) + ADDPREPOSTREGVAR(JacSn) + ADDPREPOSTREGVAR(PressureWave) + ADDPREPOSTREGVAR(Gamma) + ADDPREPOSTREGVAR(PRose3D) + ADDPREPOSTREGVAR(LogDB) //ADDPREPOSTREGVAR(LinearXZ) //ADDPREPOSTREGVAR(LinearYZ) //DC are special. diff --git a/Source/Ember/Variations01.h b/Source/Ember/Variations01.h index f4c3053..0d8cf58 100644 --- a/Source/Ember/Variations01.h +++ b/Source/Ember/Variations01.h @@ -261,7 +261,7 @@ public: { helper.Out.x = m_Weight * helper.m_PrecalcSqrtSumSquares * std::sin(helper.m_PrecalcAtanxy + helper.m_PrecalcSqrtSumSquares); helper.Out.y = m_Weight * helper.m_PrecalcSqrtSumSquares * std::cos(helper.m_PrecalcAtanxy - helper.m_PrecalcSqrtSumSquares); - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -271,7 +271,7 @@ public: ss << "\t{\n" << "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * precalcSqrtSumSquares * sin(precalcAtanxy + precalcSqrtSumSquares);\n" << "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * precalcSqrtSumSquares * cos(precalcAtanxy - precalcSqrtSumSquares);\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -299,7 +299,7 @@ public: T r = m_Weight * helper.m_PrecalcSqrtSumSquares; helper.Out.x = r * std::sin(a); helper.Out.y = (-r) * std::cos(a); - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -312,7 +312,7 @@ public: << "\n" << "\t\tvOut.x = r * sin(a);\n" << "\t\tvOut.y = (-r) * cos(a);\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -489,7 +489,7 @@ public: { helper.Out.x = m_Weight * helper.m_PrecalcSina * std::cos(helper.m_PrecalcSqrtSumSquares); helper.Out.y = m_Weight * helper.m_PrecalcCosa * std::sin(helper.m_PrecalcSqrtSumSquares); - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -499,7 +499,7 @@ public: ss << "\t{\n" << "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * precalcSina * cos(precalcSqrtSumSquares);\n" << "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * precalcCosa * sin(precalcSqrtSumSquares);\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -534,7 +534,7 @@ public: T m1 = n1 * n1 * n1 * r; helper.Out.x = m_Weight * (m0 + m1); helper.Out.y = m_Weight * (m0 - m1); - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -551,7 +551,7 @@ public: << "\n" << "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * (m0 + m1);\n" << "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * (m0 - m1);\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -585,7 +585,7 @@ public: helper.Out.x = r * std::cos(a); helper.Out.y = r * std::sin(a); - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -601,7 +601,7 @@ public: << "\n" << "\t\tvOut.x = r * cos(a);\n" << "\t\tvOut.y = r * sin(a);\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -630,7 +630,7 @@ public: T ny = helper.In.y < T(0.0) ? helper.In.y / 2 : helper.In.y; helper.Out.x = m_Weight * nx; helper.Out.y = m_Weight * ny; - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -643,7 +643,7 @@ public: << "\n" << "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * nx;\n" << "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * ny;\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -678,7 +678,7 @@ public: T ny = helper.In.y + c11 * std::sin(helper.In.x * m_Dy2); helper.Out.x = m_Weight * nx; helper.Out.y = m_Weight * ny; - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -697,7 +697,7 @@ public: << "\n" << "\t\tvOut.x = (xform->m_VariationWeights[" << varIndex << "] * nx);\n" << "\t\tvOut.y = (xform->m_VariationWeights[" << varIndex << "] * ny);\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -750,7 +750,7 @@ public: T r = 2 * m_Weight / (helper.m_PrecalcSqrtSumSquares + 1); helper.Out.x = r * helper.In.y; helper.Out.y = r * helper.In.x; - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -762,7 +762,7 @@ public: << "\n" << "\t\tvOut.x = r * vIn.y;\n" << "\t\tvOut.y = r * vIn.x;\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -793,7 +793,7 @@ public: T ny = helper.In.y + m_Xform->m_Affine.F() * std::sin(dy); helper.Out.x = m_Weight * nx; helper.Out.y = m_Weight * ny; - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -808,7 +808,7 @@ public: << "\n" << "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * nx;\n" << "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * ny;\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -837,7 +837,7 @@ public: T dy = T(M_PI) * helper.In.y; helper.Out.x = dx * std::cos(dy); helper.Out.y = dx * std::sin(dy); - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -850,7 +850,7 @@ public: << "\n" << "\t\tvOut.x = dx * cos(dy);\n" << "\t\tvOut.y = dx * sin(dy);\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -880,7 +880,7 @@ public: T r = m_Weight * std::pow(helper.m_PrecalcSqrtSumSquares, helper.m_PrecalcSina); helper.Out.x = r * helper.m_PrecalcCosa; helper.Out.y = r * helper.m_PrecalcSina; - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -892,7 +892,7 @@ public: << "\n" << "\t\tvOut.x = r * precalcCosa;\n" << "\t\tvOut.y = r * precalcSina;\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -920,7 +920,7 @@ public: T ny = -std::sin(a) * std::sinh(helper.In.y); helper.Out.x = m_Weight * nx; helper.Out.y = m_Weight * ny; - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -934,7 +934,7 @@ public: << "\n" << "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * nx;\n" << "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * ny;\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -967,7 +967,7 @@ public: r = m_Weight * (fmod(r + dx, 2 * dx) - dx + r * (1 - dx)); helper.Out.x = r * helper.m_PrecalcCosa; helper.Out.y = r * helper.m_PrecalcSina; - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -981,7 +981,7 @@ public: << "\t\tr = xform->m_VariationWeights[" << varIndex << "] * (fmod(r + dx, 2 * dx) - dx + r * (1 - dx));\n" << "\t\tvOut.x = r * precalcCosa;\n" << "\t\tvOut.y = r * precalcSina;\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -1024,7 +1024,7 @@ public: a += (fmod(a + dy, dx) > dx2) ? -dx2 : dx2; helper.Out.x = r * std::cos(a); helper.Out.y = r * std::sin(a); - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -1040,7 +1040,7 @@ public: << "\n" << "\t\tvOut.x = r * cos(a);\n" << "\t\tvOut.y = r * sin(a);\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -1078,7 +1078,7 @@ public: T r = helper.m_PrecalcSqrtSumSquares * (m_BlobLow + m_BlobDiff * (T(0.5) + T(0.5) * std::sin(m_BlobWaves * helper.m_PrecalcAtanxy))); helper.Out.x = m_Weight * helper.m_PrecalcSina * r; helper.Out.y = m_Weight * helper.m_PrecalcCosa * r; - helper.Out.z = (m_VarType == eVariationType::VARTYPE_REG) ? 0 : helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -1096,7 +1096,7 @@ public: << "\n" << "\t\tvOut.x = (xform->m_VariationWeights[" << varIndex << "] * precalcSina * r);\n" << "\t\tvOut.y = (xform->m_VariationWeights[" << varIndex << "] * precalcCosa * r);\n" - << "\t\tvOut.z = " << ((m_VarType == eVariationType::VARTYPE_REG) ? "0" : "vIn.z") << ";\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -1445,7 +1445,7 @@ public: T r = m_Weight / denom; helper.Out.x = r * helper.In.x; helper.Out.y = r * helper.In.y; - helper.Out.z = m_Weight * (2 / denom - 1); + helper.Out.z = m_Weight * (2 / Zeps(denom - 1)); } virtual string OpenCLString() const override @@ -1458,10 +1458,15 @@ public: << "\n" << "\t\tvOut.x = r * vIn.x;\n" << "\t\tvOut.y = r * vIn.y;\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * (2 / denom - 1);\n" + << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * (2 / Zeps(denom - 1));\n" << "\t}\n"; return ss.str(); } + + virtual vector OpenCLGlobalFuncNames() const override + { + return vector { "Zeps" }; + } }; /// @@ -1515,7 +1520,7 @@ public: T t = 1 / d; helper.Out.x = m_Weight * m_Dist * helper.In.x * t; helper.Out.y = m_Weight * m_VfCos * helper.In.y * t; - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -1534,7 +1539,7 @@ public: << "\n" << "\t\tvOut.x = (xform->m_VariationWeights[" << varIndex << "] * " << dist << " * vIn.x * t);\n" << "\t\tvOut.y = (xform->m_VariationWeights[" << varIndex << "] * " << vfCos << " * vIn.y * t);\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -1786,7 +1791,7 @@ protected: string prefix = Prefix(); m_Params.clear(); m_Params.push_back(ParamWithName(&m_Dist, prefix + "juliascope_dist", 1));//Params. - m_Params.push_back(ParamWithName(&m_Power, prefix + "juliascope_power", 1)); + m_Params.push_back(ParamWithName(&m_Power, prefix + "juliascope_power", 1, eParamType::REAL_NONZERO)); m_Params.push_back(ParamWithName(true, &m_Rn, prefix + "juliascope_rn"));//Precalc. m_Params.push_back(ParamWithName(true, &m_Cn, prefix + "juliascope_cn")); } @@ -1970,6 +1975,7 @@ public: T r = m_Weight * rand.Frand01(); helper.Out.x = r * std::cos(a); helper.Out.y = r * std::sin(a); + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -1988,7 +1994,7 @@ public: << "\n" << "\t\tvOut.x = r * cos(a);\n" << "\t\tvOut.y = r * sin(a);\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -2148,7 +2154,7 @@ public: T r = m_Weight / Zeps(SQR(re) + SQR(im)); helper.Out.x = (helper.In.x * re + helper.In.y * im) * r; helper.Out.y = (helper.In.y * re - helper.In.x * im) * r; - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -2167,7 +2173,7 @@ public: << "\n" << "\t\tvOut.x = (vIn.x * re + vIn.y * im) * r;\n" << "\t\tvOut.y = (vIn.y * re - vIn.x * im) * r;\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -2295,7 +2301,7 @@ public: sincos(angle, &sinr, &cosr); helper.Out.x = m_Weight * sinr; helper.Out.y = m_Weight * (sinr * sinr) / cosr; - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -2309,7 +2315,7 @@ public: << "\n" << "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * sinr;\n" << "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * (sinr * sinr) / cosr;\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -2330,7 +2336,7 @@ public: { helper.Out.x = m_Weight * std::sin(helper.In.x) / std::cos(helper.In.y); helper.Out.y = m_Weight * SafeTan(helper.In.y); - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -2340,7 +2346,7 @@ public: ss << "\t{\n" << "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * sin(vIn.x) / cos(vIn.y);\n" << "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * tan(vIn.y);\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -2395,7 +2401,7 @@ public: T tanr = m_Weight * SafeTan(ang) * r; helper.Out.x = tanr * std::cos(helper.In.x); helper.Out.y = tanr * std::sin(helper.In.y); - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -2409,7 +2415,7 @@ public: << "\n" << "\t\tvOut.x = tanr * cos(vIn.x);\n" << "\t\tvOut.y = tanr * sin(vIn.y);\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -2438,7 +2444,7 @@ public: sincos(r, &sinr, &cosr); helper.Out.x = m_Weight * helper.In.x * (cosr + sinr); helper.Out.y = m_Weight * helper.In.x * (cosr - sinr); - helper.Out.z = (m_VarType == eVariationType::VARTYPE_REG) ? 0 : helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -2452,7 +2458,7 @@ public: << "\n" << "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * vIn.x * (cosr + sinr);\n" << "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * vIn.x * (cosr - sinr);\n" - << "\t\tvOut.z = " << ((m_VarType == eVariationType::VARTYPE_REG) ? "0" : "vIn.z") << ";\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -2481,7 +2487,7 @@ public: else helper.Out.y = m_Weight * (icr - 1); - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -2500,7 +2506,7 @@ public: << "\t\telse\n" << "\t\t vOut.y = xform->m_VariationWeights[" << varIndex << "] * (icr - (real_t)(1.0));\n" << "\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -2529,7 +2535,7 @@ public: helper.Out.x = m_Weight * helper.In.x * diff; helper.Out.y = m_Weight * helper.In.x * (diff - sinr * T(M_PI)); - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -2547,7 +2553,7 @@ public: << "\n" << "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * vIn.x * diff;\n" << "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * vIn.x * (diff - sinr * M_PI);\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -2614,7 +2620,7 @@ public: r = m_Weight * helper.m_PrecalcAtanxy / T(M_PI); helper.Out.x = (sinr + m_CosAdd) * r; helper.Out.y = (cosr + m_SinAdd) * r; - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -2636,7 +2642,7 @@ public: << "\n" << "\t\tvOut.x = (sinr + " << cosAdd << ") * r;\n" << "\t\tvOut.y = (cosr + " << sinAdd << ") * r;\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -2714,7 +2720,7 @@ public: * std::pow(t1 + t2, m_PNeg1N1) / helper.m_PrecalcSqrtSumSquares; helper.Out.x = r * helper.In.x; helper.Out.y = r * helper.In.y; - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -2741,7 +2747,7 @@ public: << "\n" << "\t\tvOut.x = r * vIn.x;\n" << "\t\tvOut.y = r * vIn.y;\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -2808,7 +2814,7 @@ public: T r = m_Weight * (rand.Frand01() - m_Holes) * std::cos(m_Petals * theta) / helper.m_PrecalcSqrtSumSquares; helper.Out.x = r * helper.In.x; helper.Out.y = r * helper.In.y; - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -2825,7 +2831,7 @@ public: << "\n" << "\t\tvOut.x = r * vIn.x;\n" << "\t\tvOut.y = r * vIn.y;\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -2871,7 +2877,7 @@ public: m_Eccentricity / (1 + m_Eccentricity * ct) / helper.m_PrecalcSqrtSumSquares; helper.Out.x = r * helper.In.x; helper.Out.y = r * helper.In.y; - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -2888,7 +2894,7 @@ public: << "\n" << "\t\tvOut.x = r * vIn.x;\n" << "\t\tvOut.y = r * vIn.y;\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -2933,7 +2939,7 @@ public: sincos(helper.m_PrecalcSqrtSumSquares, &sr, &cr); helper.Out.x = m_Height * m_Weight * sr * sr * rand.Frand01(); helper.Out.y = m_Width * m_Weight * cr * rand.Frand01(); - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -2950,7 +2956,7 @@ public: << "\n" << "\t\tvOut.x = " << height << " * (xform->m_VariationWeights[" << varIndex << "] * sr * sr * MwcNext01(mwc));\n" << "\t\tvOut.y = " << width << " * (xform->m_VariationWeights[" << varIndex << "] * cr * MwcNext01(mwc));\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -3001,7 +3007,7 @@ public: else helper.Out.y = m_Vy * helper.In.y; - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -3025,7 +3031,7 @@ public: << "\t\telse\n" << "\t\tvOut.y = " << vy << " * vIn.y;\n" << "\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -3223,12 +3229,12 @@ public: virtual void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand) override { - T roundX = Rint(helper.In.x); - T roundY = Rint(helper.In.y); + T roundX = std::rint(helper.In.x); + T roundY = std::rint(helper.In.y); T offsetX = helper.In.x - roundX; T offsetY = helper.In.y - roundY; - if (rand.Frand01() >= 0.75) + if (rand.Frand01() >= T(0.75)) { helper.Out.x = m_Weight * (offsetX * T(0.5) + roundX); helper.Out.y = m_Weight * (offsetY * T(0.5) + roundY); @@ -3237,7 +3243,7 @@ public: { if (std::abs(offsetX) >= std::abs(offsetY)) { - if (offsetX >= 0.0) + if (offsetX >= 0) { helper.Out.x = m_Weight * (offsetX * T(0.5) + roundX + T(0.25)); helper.Out.y = m_Weight * (offsetY * T(0.5) + roundY + T(0.25) * offsetY / offsetX); @@ -3250,7 +3256,7 @@ public: } else { - if (offsetY >= 0.0) + if (offsetY >= 0) { helper.Out.y = m_Weight * (offsetY * T(0.5) + roundY + T(0.25)); helper.Out.x = m_Weight * (offsetX * T(0.5) + roundX + offsetX / offsetY * T(0.25)); @@ -3263,7 +3269,7 @@ public: } } - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -3271,8 +3277,8 @@ public: ostringstream ss; intmax_t varIndex = IndexInXform(); ss << "\t{\n" - << "\t\treal_t roundX = Rint(vIn.x);\n" - << "\t\treal_t roundY = Rint(vIn.y);\n" + << "\t\treal_t roundX = rint(vIn.x);\n" + << "\t\treal_t roundY = rint(vIn.y);\n" << "\t\treal_t offsetX = vIn.x - roundX;\n" << "\t\treal_t offsetY = vIn.y - roundY;\n" << "\n" @@ -3311,7 +3317,7 @@ public: << "\t\t }\n" << "\t\t}\n" << "\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -3335,7 +3341,7 @@ public: T r = wx * std::sqrt(std::abs(helper.In.y * helper.In.x) / Zeps(SQR(helper.In.x) + SQR(y2))); helper.Out.x = r * helper.In.x; helper.Out.y = r * y2; - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -3349,7 +3355,7 @@ public: << "\n" << "\t\tvOut.x = r * vIn.x;\n" << "\t\tvOut.y = r * y2;\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -3412,7 +3418,7 @@ public: helper.Out.x = m_Weight * (dx + x * m_Size); helper.Out.y = -(m_Weight * (dy + y * m_Size)); - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } /// @@ -3469,7 +3475,7 @@ public: << "\n" << "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * (dx + x * " << size << ");\n" << "\t\tvOut.y = -(xform->m_VariationWeights[" << varIndex << "] * (dy + y * " << size << "));\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -3513,7 +3519,7 @@ public: T m = m_Weight * std::exp(m_C * lnr - m_D * a); helper.Out.x = m * std::cos(angle); helper.Out.y = m * std::sin(angle); - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -3536,7 +3542,7 @@ public: << "\n" << "\t\tvOut.x = m * cos(angle);\n" << "\t\tvOut.y = m * sin(angle);\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -3595,7 +3601,7 @@ public: { helper.Out.x = m_Weight * helper.In.x + m_XAmpV * std::exp(-helper.In.y * helper.In.y * m_XLengthV); helper.Out.y = m_Weight * helper.In.y + m_YAmpV * std::exp(-helper.In.x * helper.In.x * m_YLengthV); - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -3615,7 +3621,7 @@ public: ss << "\t{\n" << "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * vIn.x + " << xAmpV << " * exp(-vIn.y * vIn.y * " << xLengthV << ");\n" << "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * vIn.y + " << yAmpV << " * exp(-vIn.x * vIn.x * " << yLengthV << ");\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -3693,7 +3699,7 @@ public: helper.Out.x = w * cshu * csv; helper.Out.y = w * snhu * snv; - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -3717,7 +3723,7 @@ public: << "\t\t snv = -snv;\n" << "\t\tvOut.x = w * cshu * csv;\n" << "\t\tvOut.y = w * snhu * snv;\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -3764,7 +3770,7 @@ public: else helper.Out.y = -(w * std::log(xmax + ssx)); - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -3800,7 +3806,7 @@ public: << "\t\telse\n" << "\t\t vOut.y = -(w * log(xmax + ssx));\n" << "\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -4179,7 +4185,7 @@ public: else helper.Out.y = m_Weight * helper.In.y; - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -4207,7 +4213,7 @@ public: << "\t\telse\n" << "\t\t vOut.y = xform->m_VariationWeights[" << varIndex << "] * vIn.y;\n" << "\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -4276,7 +4282,7 @@ public: helper.Out.y = m_Weight * helper.In.y; } - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -4309,7 +4315,7 @@ public: << "\t\t vOut.y = xform->m_VariationWeights[" << varIndex << "] * vIn.y;\n" << "\t\t}\n" << "\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -4422,7 +4428,7 @@ public: { helper.Out.x = m_Weight * (helper.In.x + m_X * std::sin(SafeTan(helper.In.y * m_C))); helper.Out.y = m_Weight * (helper.In.y + m_Y * std::sin(SafeTan(helper.In.x * m_C))); - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -4437,7 +4443,7 @@ public: ss << "\t{\n" << "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * (vIn.x + " << x << " * sin(tan(vIn.y * " << c << ")));\n" << "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * (vIn.y + " << y << " * sin(tan(vIn.x * " << c << ")));\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -4488,7 +4494,7 @@ public: T r = 1 / Zeps(helper.m_PrecalcSqrtSumSquares * (t + m_InvWeight)); helper.Out.x = helper.In.x * r; helper.Out.y = helper.In.y * r; - helper.Out.z = (m_VarType == eVariationType::VARTYPE_REG) ? 0 : helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -4504,7 +4510,7 @@ public: << "\n" << "\t\tvOut.x = vIn.x * r;\n" << "\t\tvOut.y = vIn.y * r;\n" - << "\t\tvOut.z = " << ((m_VarType == eVariationType::VARTYPE_REG) ? "0" : "vIn.z") << ";\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -4650,7 +4656,7 @@ public: else helper.Out.y = -(m_Weight * helper.In.y); - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -4674,7 +4680,7 @@ public: << "\t\telse\n" << "\t\t vOut.y = -(xform->m_VariationWeights[" << varIndex << "] * vIn.y);\n" << "\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -4735,7 +4741,7 @@ public: else helper.Out.y = m_Weight * (helper.In.y - m_Y); - helper.Out.z = m_Weight * helper.In.z;//Original does *not* have this. search through all for this and sync.//TODO! + helper.Out.z = m_Weight * helper.In.z;//Original from flam3 does not have this, but the apo implementation does, so use Apo since it's more recent. } virtual string OpenCLString() const override @@ -4802,7 +4808,7 @@ public: T offsetx = helper.In.x - roundx; helper.Out.x = m_Weight * (offsetx * (1 - m_Space) + roundx); helper.Out.y = m_Weight * (helper.In.y + offsetx * offsetx * m_Warp); - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -4819,7 +4825,7 @@ public: << "\n" << "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * (offsetx * ((real_t)(1.0) - " << space << ") + roundx);\n" << "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * (vIn.y + offsetx * offsetx * " << warp << ");\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -4951,7 +4957,7 @@ public: a = a * m_Cf + c * m_Angle; helper.Out.x = r * std::cos(a); helper.Out.y = r * std::sin(a); - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -4976,7 +4982,7 @@ public: << "\t\ta = a * " << cf << " + c * " << angle << ";\n" << "\t\tvOut.x = r * cos(a);\n" << "\t\tvOut.y = r * sin(a);\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -5038,13 +5044,12 @@ public: { T r = 1 / Zeps(helper.m_PrecalcSqrtSumSquares); T a = helper.m_PrecalcAtanyx + m_Swirl * r; - T c = T(Floor((m_Count * a + T(M_PI)) * T(M_1_PI) * T(0.5))); - T compFac = 1 - m_Angle * m_Count * T(M_1_PI) * T(0.5); - a = a * compFac + c * m_Angle; - r = m_Weight * (r + m_Hole); - helper.Out.x = r * std::cos(a); - helper.Out.y = r * std::sin(a); - helper.Out.z = m_Weight * helper.In.z; + auto c = Floor((m_Count * a + T(M_PI)) * m_C12Pi); + a = a * m_CompFac + c * m_Angle; + T temp = m_Weight * (r + m_Hole); + helper.Out.x = temp * std::cos(a); + helper.Out.y = temp * std::sin(a); + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -5053,21 +5058,22 @@ public: intmax_t i = 0, varIndex = IndexInXform(); ss2 << "_" << XformIndexInEmber() << "]"; string index = ss2.str(); - string angle = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string count = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string hole = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string swirl = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string angle = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string count = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string hole = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string swirl = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string c12pi = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string compfac = "parVars[" + ToUpper(m_Params[i++].Name()) + index; ss << "\t{\n" << "\t\treal_t r = (real_t)(1.0) / Zeps(precalcSqrtSumSquares);\n" << "\t\treal_t a = precalcAtanyx + " << swirl << " * r;\n" - << "\t\treal_t c = floor((" << count << " * a + M_PI) * M_1_PI * (real_t)(0.5));\n" - << "\t\treal_t compFac = 1 - " << angle << " * " << count << " * M_1_PI * (real_t)(0.5);\n" + << "\t\treal_t c = floor((" << count << " * a + M_PI) * " << c12pi << "); \n" << "\n" - << "\t\ta = a * compFac + c * " << angle << ";\n" - << "\t\tr = xform->m_VariationWeights[" << varIndex << "] * (r + " << hole << ");\n" - << "\t\tvOut.x = r * cos(a);\n" - << "\t\tvOut.y = r * sin(a);\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\ta = a * " << compfac << " + c * " << angle << ";\n" + << "\t\treal_t temp = xform->m_VariationWeights[" << varIndex << "] * (r + " << hole << ");\n" + << "\t\tvOut.x = temp * cos(a);\n" + << "\t\tvOut.y = temp * sin(a);\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -5085,15 +5091,23 @@ public: m_Swirl = rand.Frand01(); } + virtual void Precalc() override + { + m_C12Pi = T(M_1_PI) / 2; + m_CompFac = 1 - m_Angle * m_Count * m_C12Pi; + } + protected: void Init() { string prefix = Prefix(); m_Params.clear(); - m_Params.push_back(ParamWithName(&m_Angle, prefix + "wedge_sph_angle")); - m_Params.push_back(ParamWithName(&m_Count, prefix + "wedge_sph_hole", 1)); - m_Params.push_back(ParamWithName(&m_Hole, prefix + "wedge_sph_count")); + m_Params.push_back(ParamWithName(&m_Angle, prefix + "wedge_sph_angle", T(M_PI_2))); + m_Params.push_back(ParamWithName(&m_Count, prefix + "wedge_sph_count", 2, eParamType::INTEGER, 1)); + m_Params.push_back(ParamWithName(&m_Hole, prefix + "wedge_sph_hole")); m_Params.push_back(ParamWithName(&m_Swirl, prefix + "wedge_sph_swirl")); + m_Params.push_back(ParamWithName(true, &m_C12Pi, prefix + "wedge_sph_c1_2pi")); + m_Params.push_back(ParamWithName(true, &m_CompFac, prefix + "wedge_sph_comp_fac")); } private: @@ -5101,6 +5115,8 @@ private: T m_Count; T m_Hole; T m_Swirl; + T m_C12Pi;//Precalc. + T m_CompFac; }; /// @@ -5128,7 +5144,7 @@ public: helper.Out.x = m_Weight * r * std::cos(a); helper.Out.y = m_Weight * r * std::sin(a); - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -5150,7 +5166,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 = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -5264,7 +5280,7 @@ public: T expe = m_Weight * std::exp(helper.In.x); helper.Out.x = expe * std::cos(helper.In.y); helper.Out.y = expe * std::sin(helper.In.y); - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -5276,7 +5292,7 @@ public: << "\n" << "\t\tvOut.x = expe * cos(vIn.y);\n" << "\t\tvOut.y = expe * sin(vIn.y);\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -5353,7 +5369,7 @@ public: { helper.Out.x = m_Weight * std::sin(helper.In.x) * cosh(helper.In.y); helper.Out.y = m_Weight * std::cos(helper.In.x) * sinh(helper.In.y); - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -5363,7 +5379,7 @@ public: ss << "\t{\n" << "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * sin(vIn.x) * cosh(vIn.y);\n" << "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * cos(vIn.x) * sinh(vIn.y);\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -5385,7 +5401,7 @@ public: //clamp fabs x and y to 7.104760e+002 for cosh, and |x| 7.104760e+002 for sinh helper.Out.x = m_Weight * std::cos(helper.In.x) * cosh(helper.In.y); helper.Out.y = -(m_Weight * std::sin(helper.In.x) * sinh(helper.In.y)); - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -5395,7 +5411,7 @@ public: ss << "\t{\n" << "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * cos(vIn.x) * cosh(vIn.y);\n" << "\t\tvOut.y = -(xform->m_VariationWeights[" << varIndex << "] * sin(vIn.x) * sinh(vIn.y));\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -5421,7 +5437,7 @@ public: tanden = 1 / (tancos + tancosh); helper.Out.x = m_Weight * tanden * tansin; helper.Out.y = m_Weight * tanden * tansinh; - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -5437,7 +5453,7 @@ public: << "\n" << "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * tanden * tansin;\n" << "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * tanden * tansinh;\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -5463,7 +5479,7 @@ public: secden = 2 / (cos(2 * helper.In.x) + cosh(2 * helper.In.y)); helper.Out.x = m_Weight * secden * seccos * seccosh; helper.Out.y = m_Weight * secden * secsin * secsinh; - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -5479,7 +5495,7 @@ public: << "\n" << "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * secden * seccos * seccosh;\n" << "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * secden * secsin * secsinh;\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -5505,7 +5521,7 @@ public: cscden = 2 / (std::cosh(2 * helper.In.y) - std::cos(2 * helper.In.x)); helper.Out.x = m_Weight * cscden * cscsin * csccosh; helper.Out.y = -(m_Weight * cscden * csccos * cscsinh); - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -5521,7 +5537,7 @@ public: << "\n" << "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * cscden * cscsin * csccosh;\n" << "\t\tvOut.y = -(xform->m_VariationWeights[" << varIndex << "] * cscden * csccos * cscsinh);\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -5547,7 +5563,7 @@ public: cotden = 1 / (cotcosh - cotcos); helper.Out.x = m_Weight * cotden * cotsin; helper.Out.y = m_Weight * cotden * -1 * cotsinh; - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -5563,7 +5579,7 @@ public: << "\n" << "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * cotden * cotsin;\n" << "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * cotden * -1 * cotsinh;\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -5588,7 +5604,7 @@ public: sinhcosh = cosh(helper.In.x); helper.Out.x = m_Weight * sinhsinh * sinhcos; helper.Out.y = m_Weight * sinhcosh * sinhsin; - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -5603,7 +5619,7 @@ public: << "\n" << "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * sinhsinh * sinhcos;\n" << "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * sinhcosh * sinhsin;\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -5628,7 +5644,7 @@ public: coshcosh = cosh(helper.In.x); helper.Out.x = m_Weight * coshcosh * coshcos; helper.Out.y = m_Weight * coshsinh * coshsin; - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -5643,7 +5659,7 @@ public: << "\n" << "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * coshcosh * coshcos;\n" << "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * coshsinh * coshsin;\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -5669,7 +5685,7 @@ public: tanhden = 1 / (tanhcos + tanhcosh); helper.Out.x = m_Weight * tanhden * tanhsinh; helper.Out.y = m_Weight * tanhden * tanhsin; - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -5685,7 +5701,7 @@ public: << "\n" << "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * tanhden * tanhsinh;\n" << "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * tanhden * tanhsin;\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -5711,7 +5727,7 @@ public: sechden = 2 / (cos(2 * helper.In.y) + cosh(2 * helper.In.x)); helper.Out.x = m_Weight * sechden * sechcos * sechcosh; helper.Out.y = -(m_Weight * sechden * sechsin * sechsinh); - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -5727,7 +5743,7 @@ public: << "\n" << "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * sechden * sechcos * sechcosh;\n" << "\t\tvOut.y = -(xform->m_VariationWeights[" << varIndex << "] * sechden * sechsin * sechsinh);\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -5753,7 +5769,7 @@ public: cschden = 2 / (std::cosh(2 * helper.In.x) - std::cos(2 * helper.In.y)); helper.Out.x = m_Weight * cschden * cschsinh * cschcos; helper.Out.y = -(m_Weight * cschden * cschcosh * cschsin); - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -5769,7 +5785,7 @@ public: << "\n" << "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * cschden * cschsinh * cschcos;\n" << "\t\tvOut.y = -(xform->m_VariationWeights[" << varIndex << "] * cschden * cschcosh * cschsin);\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -5795,7 +5811,7 @@ public: cothden = 1 / (cothcosh - cothcos); helper.Out.x = m_Weight * cothden * cothsinh; helper.Out.y = m_Weight * cothden * cothsin; - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -5811,7 +5827,7 @@ public: << "\n" << "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * cothden * cothsinh;\n" << "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * cothden * cothsin;\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -5919,7 +5935,7 @@ public: T avga = (atan2(helper.In.y, xmw) - atan2(helper.In.y, xpw)) * T(0.5); helper.Out.x = avgr * std::cos(avga); helper.Out.y = avgr * std::sin(avga); - helper.Out.z = helper.In.z; + helper.Out.z = helper.In.z;//Apo does not use weight, sums only z. Sum here for reg, else assign. } virtual string OpenCLString() const override @@ -5944,7 +5960,7 @@ public: << "\n" << "\t\tvOut.x = avgr * cos(avga);\n" << "\t\tvOut.y = avgr * sin(avga);\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = vIn.z;\n" << "\t}\n"; return ss.str(); } diff --git a/Source/Ember/Variations02.h b/Source/Ember/Variations02.h index e193e26..cf33d3f 100644 --- a/Source/Ember/Variations02.h +++ b/Source/Ember/Variations02.h @@ -61,14 +61,14 @@ public: { helper.Out.x = m_Weight * t * std::cos(theta); helper.Out.y = m_Weight * t * std::sin(theta); - helper.Out.z = 0; } else { helper.Out.x = 0; helper.Out.y = 0; - helper.Out.z = 0; } + + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -96,6 +96,7 @@ public: << "\t\t\tvOut.y = 0;\n" << "\t\t\tvOut.z = 0;\n" << "\t\t}\n" + << "\t\tvOut.Z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -697,7 +698,7 @@ public: } } - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -736,7 +737,7 @@ public: << "\t\t }\n" << "\t\t}\n" << "\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -781,7 +782,7 @@ public: T r = m_BlurLinearLength * rand.Frand01(); helper.Out.x = m_Weight * (helper.In.x + r * m_C); helper.Out.y = m_Weight * (helper.In.y + r * m_S); - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -799,7 +800,7 @@ public: << "\n" << "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * (vIn.x + r * " << c << ");\n" << "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * (vIn.y + r * " << s << ");\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -845,7 +846,7 @@ public: { helper.Out.x = m_V * (rand.Frand01() - T(0.5)); helper.Out.y = m_V * (rand.Frand01() - T(0.5)); - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -858,7 +859,7 @@ public: ss << "\t{\n" << "\t\tvOut.x = " << v << " * (MwcNext01(mwc) - (real_t)(0.5));\n" << "\t\tvOut.y = " << v << " * (MwcNext01(mwc) - (real_t)(0.5));\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -1361,7 +1362,7 @@ public: } } - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -1417,7 +1418,7 @@ public: << "\t\t }\n" << "\t\t}\n" << "\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -1473,7 +1474,7 @@ public: T r = m_Weight * std::sqrt(helper.m_PrecalcSumSquares + std::sin(helper.m_PrecalcAtanyx * m_A) + 1); helper.Out.x = r * helper.m_PrecalcCosa; helper.Out.y = r * helper.m_PrecalcSina; - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -1488,7 +1489,7 @@ public: << "\n" << "\t\tvOut.x = r * precalcCosa;\n" << "\t\tvOut.y = r * precalcSina;\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -1669,7 +1670,7 @@ public: val = T(M_PI_4) * perimeter / side - T(M_PI_4); helper.Out.x = r * std::cos(val); helper.Out.y = r * std::sin(val); - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -1710,7 +1711,7 @@ public: << "\n" << "\t\tvOut.x = r * cos(val);\n" << "\t\tvOut.y = r * sin(val);\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -1778,7 +1779,7 @@ public: T val = T(M_PI_4) * perimeter / side - T(M_PI_4); helper.Out.x = r * std::cos(val); helper.Out.y = r * std::sin(val); - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -1818,7 +1819,7 @@ public: << "\n" << "\t\tvOut.x = r * cos(val);\n" << "\t\tvOut.y = r * sin(val);\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -1859,7 +1860,7 @@ public: T oscnapy = Foscn(m_AmountY, m_Py); helper.Out.x = -1 + m_Vv2 * Lerp(Lerp(x, Fosc(x, T(4), m_Px), oscnapx), Fosc(bx, T(4), m_Px), oscnapx);//Original did a direct assignment to outPoint, which is incompatible with Ember's design. helper.Out.y = -1 + m_Vv2 * Lerp(Lerp(y, Fosc(y, T(4), m_Py), oscnapy), Fosc(by, T(4), m_Py), oscnapy); - helper.Out.z = (m_VarType == eVariationType::VARTYPE_REG) ? 0 : helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -1889,7 +1890,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 == eVariationType::VARTYPE_REG) ? "0" : "vIn.z") << ";\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -1963,7 +1964,7 @@ public: sincos(avga, &s, &c); helper.Out.x = avgr * c; helper.Out.y = avgr * s; - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -1978,7 +1979,7 @@ public: << "\n" << "\t\tvOut.x = avgr * c;\n" << "\t\tvOut.y = avgr * s;\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -2006,7 +2007,7 @@ public: T csv = std::cos(temp); helper.Out.x = m_Weight * expor * csv; helper.Out.y = m_Weight * expor * snv; - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -2027,7 +2028,7 @@ public: << "\n" << "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * expor * csv;\n" << "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * expor * snv;\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -2159,7 +2160,7 @@ public: sincos(a, &s, &c); helper.Out.x = m_Weight * r * c; helper.Out.y = m_Weight * r * s; - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -2174,7 +2175,7 @@ public: << "\n" << "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * r * c;\n" << "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * r * s;\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -2205,7 +2206,7 @@ public: T eradius2 = std::exp((helper.In.x * m_NatLog - helper.In.y * T(M_PI)) * -1); helper.Out.x = m_Weight * (eradius1 * cnum1 - eradius2 * cnum2) * m_Five; helper.Out.y = m_Weight * (eradius1 * snum1 - eradius2 * snum2) * m_Five; - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -2228,7 +2229,7 @@ public: << "\n" << "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * (eradius1 * cnum1 - eradius2 * cnum2) * " << five << ";\n" << "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * (eradius1 * snum1 - eradius2 * snum2) * " << five << ";\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -2278,7 +2279,7 @@ public: T eradius2 = m_Sc * std::exp(m_Sc2 * ((helper.In.x * m_NatLog - helper.In.y * T(M_PI)) * -1)); helper.Out.x = m_Weight * (eradius1 * cnum1 - eradius2 * cnum2) * m_Five; helper.Out.y = m_Weight * (eradius1 * snum1 - eradius2 * snum2) * m_Five; - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -2303,7 +2304,7 @@ public: << "\n" << "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * (eradius1 * cnum1 - eradius2 * cnum2) * " << five << ";\n" << "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * (eradius1 * snum1 - eradius2 * snum2) * " << five << ";\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -2383,7 +2384,7 @@ public: } } - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -2429,7 +2430,7 @@ public: << "\t\t }\n" << "\t\t}\n" << "\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -2526,7 +2527,7 @@ public: } } - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -2596,7 +2597,7 @@ public: << "\t\t }\n" << "\t\t}\n" << "\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -2632,7 +2633,7 @@ public: helper.Out.x = r * helper.m_PrecalcCosa; helper.Out.y = r * helper.m_PrecalcSina; - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -2653,7 +2654,7 @@ public: << "\n" << "\t\tvOut.x = r * precalcCosa;\n" << "\t\tvOut.y = r * precalcSina;\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -2695,7 +2696,7 @@ public: T vr = m_Weight / (SQR(c) + SQR(d)); helper.Out.x = vr * (a * c + b * d); helper.Out.y = vr * (b * c - a * d); - helper.Out.z = (m_VarType == eVariationType::VARTYPE_REG) ? 0 : helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -2718,7 +2719,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 == eVariationType::VARTYPE_REG) ? "0" : "vIn.z") << ";\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -2787,7 +2788,7 @@ public: T vr = m_Weight / (SQR(c) + SQR(d)); helper.Out.x = vr * (a * c + b * d); helper.Out.y = vr * (b * c - a * d); - helper.Out.z = (m_VarType == eVariationType::VARTYPE_REG) ? 0 : helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -2814,7 +2815,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 == eVariationType::VARTYPE_REG) ? "0" : "vIn.z") << ";\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -2878,7 +2879,7 @@ public: T cosa = std::cos(temp); helper.Out.x = vr * (x * cosa + y * sina); helper.Out.y = vr * (y * cosa - x * sina); - helper.Out.z = (m_VarType == eVariationType::VARTYPE_REG) ? 0 : helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -2905,7 +2906,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 == eVariationType::VARTYPE_REG) ? "0" : "vIn.z") << ";\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -3286,7 +3287,7 @@ public: T r = helper.m_PrecalcAtanyx * m_V; helper.Out.x = r * c; helper.Out.y = r * s; - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -3304,7 +3305,7 @@ public: << "\n" << "\t\tvOut.x = r * c;\n" << "\t\tvOut.y = r * s;\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -3350,7 +3351,7 @@ public: T r = m_Weight * std::pow(SQR(x) + SQR(y), m_Cn); helper.Out.x = r * cosa; helper.Out.y = r * sina; - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -3379,7 +3380,7 @@ public: << "\n" << "\t\tvOut.x = r * cosa;\n" << "\t\tvOut.y = r * sina;\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -3445,7 +3446,7 @@ public: T r = m_Weight * std::pow(helper.m_PrecalcSumSquares, m_HalfInvPower); helper.Out.x = r * cosa; helper.Out.y = r * sina; - helper.Out.z = (m_VarType == eVariationType::VARTYPE_REG) ? 0 : helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -3467,7 +3468,7 @@ public: << "\n" << "\t\tvOut.x = r * cosa;\n" << "\t\tvOut.y = r * sina;\n" - << "\t\tvOut.z = " << ((m_VarType == eVariationType::VARTYPE_REG) ? "0" : "vIn.z") << ";\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -3524,7 +3525,7 @@ public: T r1 = m_Vp / (SQR(re) + SQR(im)); helper.Out.x = r1 * (helper.In.x * re + helper.In.y * im); helper.Out.y = r1 * (helper.In.y * re - helper.In.x * im); - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -3549,7 +3550,7 @@ public: << "\n" << "\t\tvOut.x = r1 * (vIn.x * re + vIn.y * im);\n" << "\t\tvOut.y = r1 * (vIn.y * re - vIn.x * im);\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -3616,7 +3617,7 @@ public: T r1 = m_Vp / SQR(r); helper.Out.x = r1 * (helper.In.x * re + helper.In.y * im); helper.Out.y = r1 * (helper.In.y * re - helper.In.x * im); - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -3650,7 +3651,7 @@ public: << "\n" << "\t\tvOut.x = r1 * (vIn.x * re + vIn.y * im);\n" << "\t\tvOut.y = r1 * (vIn.y * re - vIn.x * im);\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -3715,7 +3716,7 @@ public: y = (m_IsOdd != 0) ? sina : (m_Vvar * std::atan2(cosa, sina)); helper.Out.x = x; helper.Out.y = y; - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -3744,7 +3745,7 @@ public: << "\t\ty = (" << isOdd << " != 0) ? sina : (" << vvar << " * atan2(cosa, sina));\n" << "\t\tvOut.x = x;\n" << "\t\tvOut.y = y;\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -3872,7 +3873,7 @@ public: } } - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -3968,7 +3969,7 @@ public: << "\t\t }\n" << "\t\t}\n" << "\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -4007,7 +4008,7 @@ public: T y = m_C1y + (SQR(m_C1r) * (helper.In.y - m_C1y)) / (SQR(helper.In.x - m_C1x) + SQR(helper.In.y - m_C1y)); helper.Out.x = m_C2x + (SQR(m_C2r) * (x - m_C2x)) / (SQR(x - m_C2x) + SQR(y - m_C2y)); helper.Out.y = m_C2y + (SQR(m_C2r) * (y - m_C2y)) / (SQR(x - m_C2x) + SQR(y - m_C2y)); - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -4032,7 +4033,7 @@ public: << "\n" << "\t\tvOut.x = " << c2x << " + (SQR(" << c2r << ") * (x - " << c2x << ")) / (SQR(x - " << c2x << ") + SQR(y - " << c2y << "));\n" << "\t\tvOut.y = " << c2y << " + (SQR(" << c2r << ") * (y - " << c2y << ")) / (SQR(x - " << c2x << ") + SQR(y - " << c2y << "));\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -4363,7 +4364,7 @@ public: T r3den = 1 / (br * br + bi * bi); helper.Out.x = m_Weight * (tr * br + ti * bi) * r3den; helper.Out.y = m_Weight * (ti * br - tr * bi) * r3den; - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -4396,7 +4397,7 @@ public: << "\n" << "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * (tr * br + ti * bi) * r3den;\n" << "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * (ti * br - tr * bi) * r3den;\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -4466,7 +4467,7 @@ public: //invert the multiplication with scale from before. helper.Out.x = m_Weight * Lerp(u1, u2, m_P) * m_Is;//Original did a direct assignment to outPoint, which is incompatible with Ember's design. helper.Out.y = m_Weight * Lerp(v1, v2, m_P) * m_Is; - helper.Out.z = (m_VarType == eVariationType::VARTYPE_REG) ? 0 : helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -4511,7 +4512,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 == eVariationType::VARTYPE_REG) ? "0" : "vIn.z") << ";\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -4596,7 +4597,7 @@ public: T y = (2 * (c1 - T(0.5))); helper.Out.x = m_Vv * x; helper.Out.y = m_Vv * y; - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -4620,7 +4621,7 @@ public: << "\n" << "\t\tvOut.x = " << vv << " * x;\n" << "\t\tvOut.y = " << vv << " * y;\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -4713,7 +4714,7 @@ public: T ty = Lerp(helper.In.y, sy, m_Ay); helper.Out.x = m_Weight * tx; helper.Out.y = m_Weight * ty; - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -4741,7 +4742,7 @@ public: << "\n" << "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * tx;\n" << "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * ty;\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * tz;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -4818,7 +4819,7 @@ public: result /= divident; helper.Out.x = m_Weight * helper.In.x + result; helper.Out.y = m_Weight * helper.In.y + result; - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -4846,7 +4847,7 @@ public: << "\n" << "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * vIn.x + result;\n" << "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * vIn.y + result;\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -4883,7 +4884,7 @@ public: helper.Out.x = r * helper.In.x; helper.Out.y = r * helper.In.y; - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -4898,7 +4899,7 @@ public: << "\n" << "\t\tvOut.x = r * vIn.x;\n" << "\t\tvOut.y = r * vIn.y;\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -4925,7 +4926,7 @@ public: T c = std::cos(helper.In.x); helper.Out.x = m_Vvar2 * r * s; helper.Out.y = m_Vvar2 * r * c; - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -4942,7 +4943,7 @@ public: << "\n" << "\t\tvOut.x = " << vvar2 << " * r * s;\n" << "\t\tvOut.y = " << vvar2 << " * r * c;\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -4992,7 +4993,7 @@ public: T dy = yn + T(0.5) * (m_ScaleY * sinx + std::abs(yn) * m_IncY * sinx); helper.Out.x = m_Weight * dx; helper.Out.y = m_Weight * dy; - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -5024,7 +5025,7 @@ public: << "\n" << "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * dx;\n" << "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * dy;\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -5103,7 +5104,7 @@ public: helper.Out.y = -m_Weight * y; } - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -5139,7 +5140,7 @@ public: << "\t\t vOut.y = -xform->m_VariationWeights[" << varIndex << "] * y;\n" << "\t\t}\n" << "\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -5277,7 +5278,7 @@ public: { helper.Out.x = m_Weight01 / SafeTan(helper.In.x) * std::cos(helper.In.y); helper.Out.y = m_Weight01 / std::sin(helper.In.x) * (-helper.In.y); - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -5290,7 +5291,7 @@ public: ss << "\t{\n" << "\t\tvOut.x = " << weight01 << " / tan(vIn.x) * cos(vIn.y);\n" << "\t\tvOut.y = " << weight01 << " / sin(vIn.x) * (-vIn.y);\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -5331,7 +5332,7 @@ public: T coshy1 = std::cosh(helper.In.y) + 1; helper.Out.x = m_Weight * sinx * coshy1 * sinx2; helper.Out.y = m_Weight * cosx * coshy1 * sinx2; - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -5346,7 +5347,7 @@ public: << "\n" << "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * sinx * coshy1 * sinx2;\n" << "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * cosx * coshy1 * sinx2;\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -5377,7 +5378,7 @@ public: T coshy1 = std::cosh(helper.In.y) + 1; helper.Out.x = d * sinx * coshy1 * sinx2; helper.Out.y = d * cosx * coshy1 * sinx2; - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -5393,7 +5394,7 @@ public: << "\n" << "\t\tvOut.x = d * sinx * coshy1 * sinx2;\n" << "\t\tvOut.y = d * cosx * coshy1 * sinx2;\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -5436,7 +5437,7 @@ public: T temp = m_C * a + m_HalfD * lnr2 + m_Ang * rand.Rand(); helper.Out.x = r * std::cos(temp); helper.Out.y = r * std::sin(temp); - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -5474,7 +5475,7 @@ public: << "\n" << "\t\tvOut.x = r * cos(temp);\n" << "\t\tvOut.y = r * sin(temp);\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -5535,7 +5536,7 @@ MAKEPREPOSTPARVARASSIGN(BlurSquare, blur_square, BLUR_SQUARE, eVariationAssignTy MAKEPREPOSTVAR(Flatten, flatten, FLATTEN) MAKEPREPOSTVARASSIGN(Zblur, zblur, ZBLUR, eVariationAssignType::ASSIGNTYPE_SUM) MAKEPREPOSTVARASSIGN(Blur3D, blur3D, BLUR3D, eVariationAssignType::ASSIGNTYPE_SUM) -MAKEPREPOSTVARASSIGN(ZScale, zscale, ZSCALE, eVariationAssignType::ASSIGNTYPE_SUM) +MAKEPREPOSTVAR(ZScale, zscale, ZSCALE) MAKEPREPOSTVARASSIGN(ZTranslate, ztranslate, ZTRANSLATE, eVariationAssignType::ASSIGNTYPE_SUM) MAKEPREPOSTVAR(ZCone, zcone, ZCONE) MAKEPREPOSTVAR(Spherical3D, Spherical3D, SPHERICAL3D) diff --git a/Source/Ember/Variations03.h b/Source/Ember/Variations03.h index 12aa946..c2619fe 100644 --- a/Source/Ember/Variations03.h +++ b/Source/Ember/Variations03.h @@ -23,7 +23,7 @@ public: T temp = 1 / Zeps(cos(helper.In.y)) + m_Effect * T(M_PI); helper.Out.x = m_Weight * (tanh(helper.In.x) * temp); helper.Out.y = m_Weight * (tanh(helper.In.y) * temp); - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -38,7 +38,7 @@ public: << "\n" << "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * (tanh(vIn.x) * temp);\n" << "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * (tanh(vIn.y) * temp);\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -111,7 +111,7 @@ public: T ran = (helper.m_PrecalcAtanyx / Zeps(m_Denominator) + (m_Root * M_2PI * Floor(rand.Frand01() * m_Denominator) / Zeps(m_Denominator))) * m_Numerator; helper.Out.x = r2 * std::cos(ran); helper.Out.y = r2 * std::sin(ran); - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -132,7 +132,7 @@ public: << "\n" << "\t\tvOut.x = r2 * cos(ran);\n" << "\t\tvOut.y = r2 * sin(ran);\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -188,7 +188,7 @@ public: T u = std::sqrt(ClampGte0(Zeps(m_A) * SQR(helper.In.x) + Zeps(m_B) * SQR(helper.In.y)));//Original did not clamp. helper.Out.x = std::cos(u) * SafeTan(helper.In.x) * m_Weight; helper.Out.y = std::sin(u) * SafeTan(helper.In.y) * m_Weight; - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -204,7 +204,7 @@ public: << "\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" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -243,7 +243,7 @@ public: { helper.Out.x = m_Weight * (helper.In.x - ((SQR(helper.In.x) * helper.In.x) / 3)) + helper.In.x * SQR(helper.In.y); helper.Out.y = m_Weight * (helper.In.y - ((SQR(helper.In.y) * helper.In.y) / 3)) + helper.In.y * SQR(helper.In.x); - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -253,7 +253,7 @@ public: ss << "\t{\n" << "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * (vIn.x - ((SQR(vIn.x) * vIn.x) / 3)) + vIn.x * SQR(vIn.y);\n" << "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * (vIn.y - ((SQR(vIn.y) * vIn.y) / 3)) + vIn.y * SQR(vIn.x);\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -282,7 +282,7 @@ public: T cosa = std::cos(alpha); helper.Out.x = m_Weight * cosa / r; helper.Out.y = m_Weight * sina / r; - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -302,7 +302,7 @@ public: << "\n" << "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * cosa / r;\n" << "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * sina / r;\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -352,7 +352,7 @@ public: else helper.Out.y = (m_Rotate * helper.In.y) * cos45 + helper.In.x * sin45 - m_Pull - m_LineUp; - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -377,7 +377,7 @@ public: << "\t\telse\n" << "\t\t vOut.y = (" << rotate << " * vIn.y) * cos45 + vIn.x * sin45 - " << pull << " - " << lineUp << ";\n" << "\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -456,7 +456,7 @@ public: } } - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -512,7 +512,7 @@ public: << "\t\t }\n" << "\t\t}\n" << "\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -624,7 +624,7 @@ public: } } - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -668,7 +668,7 @@ public: << "\t\t }\n" << "\t\t}\n" << "\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -783,7 +783,7 @@ public: } } - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -825,7 +825,7 @@ public: << "\t\t }\n" << "\t\t}\n" << "\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -936,7 +936,7 @@ public: T temp = angle - T(M_PI_2); helper.Out.x = m_Weight * z * std::cos(temp); helper.Out.y = m_Weight * z * std::sin(temp); - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -969,7 +969,7 @@ public: << "\n" << "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * z * cos(temp);\n" << "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * z * sin(temp);\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -1021,7 +1021,7 @@ public: T r = m_Weight * (m_Power == 1 ? std::acos(rand.Frand01() * 2 - 1) / T(M_PI) : std::acos(std::exp(std::log(rand.Frand01()) * m_Power) * 2 - 1) / T(M_PI)); helper.Out.x = r * c; helper.Out.y = r * s; - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -1039,7 +1039,7 @@ public: << "\n" << "\t\tvOut.x = r * c;\n" << "\t\tvOut.y = r * s;\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -1073,7 +1073,7 @@ public: T temp = rand.Frand01() * M_2PI; helper.Out.x = m_Weight * std::cos(temp) * rad; helper.Out.y = m_Weight * std::sin(temp) * rad; - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -1086,7 +1086,7 @@ public: << "\n" << "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * cos(temp) * rad;\n" << "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * sin(temp) * rad;\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -1190,7 +1190,7 @@ public: helper.Out.y = m_Weight * helper.In.y; } - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -1233,7 +1233,7 @@ public: << "\t\t vOut.y = xform->m_VariationWeights[" << varIndex << "] * vIn.y;\n" << "\t\t}\n" << "\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -1611,7 +1611,7 @@ public: { helper.Out.x = SignNz(helper.In.x) * std::pow(std::abs(helper.In.x), m_PowX) * m_Weight; helper.Out.y = SignNz(helper.In.y) * std::pow(std::abs(helper.In.y), m_PowY) * m_Weight; - helper.Out.z = (m_VarType == eVariationType::VARTYPE_REG) ? 0 : helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -1625,7 +1625,7 @@ public: ss << "\t{\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 == eVariationType::VARTYPE_REG) ? "0" : "vIn.z") << ";\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -1722,7 +1722,7 @@ public: 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 == eVariationType::VARTYPE_REG) ? 0 : helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -1738,7 +1738,7 @@ public: << "\n" << "\t\tvOut.x = vIn.x * r * " << x << ";\n" << "\t\tvOut.y = vIn.y * r * " << y << ";\n" - << "\t\tvOut.z = " << ((m_VarType == eVariationType::VARTYPE_REG) ? "0" : "vIn.z") << ";\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -1846,7 +1846,7 @@ public: T y1 = (m_A + m_B) * std::sin(t) - m_C2 * std::sin((m_A + m_B) / m_B * t); helper.Out.x = m_Weight * (x1 + m_D * std::cos(t) + y); helper.Out.y = m_Weight * (y1 + m_D * std::sin(t) + y); - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -1872,7 +1872,7 @@ public: << "\n" << "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * (x1 + " << d << " * cos(t) + y);\n" << "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * (y1 + " << d << " * sin(t) + y);\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -1925,7 +1925,7 @@ public: T by = Cube(sinX * cosY); helper.Out.x = m_Weight * cosX * bx; helper.Out.y = m_Weight * cosX * by; - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -1942,7 +1942,7 @@ public: << "\n" << "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * cosX * bx;\n" << "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * cosX * by;\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -1969,7 +1969,7 @@ public: T e = 1 / helper.m_PrecalcSumSquares + SQR(T(M_2_PI)); helper.Out.x = m_Weight * (m_Weight / helper.m_PrecalcSumSquares * helper.In.x / e); helper.Out.y = m_Weight * (m_Weight / helper.m_PrecalcSumSquares * helper.In.y / e); - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -1981,7 +1981,7 @@ public: << "\n" << "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * (xform->m_VariationWeights[" << varIndex << "] / precalcSumSquares * vIn.x / e);\n" << "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * (xform->m_VariationWeights[" << varIndex << "] / precalcSumSquares * vIn.y / e);\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -2124,7 +2124,7 @@ public: T c2 = Zeps(SQR(helper.In.y)); helper.Out.x = m_Weight * ((1 / d) * std::cos(c1) * std::sin(c2)); helper.Out.y = m_Weight * ((1 / d) * std::sin(c1) * std::sin(c2)); - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -2138,7 +2138,7 @@ public: << "\n" << "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * (((real_t)(1.0) / d) * cos(c1) * sin(c2));\n" << "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * (((real_t)(1.0) / d) * sin(c1) * sin(c2));\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -2195,7 +2195,7 @@ public: helper.Out.y = -(m_Weight * (8 * helper.m_PrecalcSqrtSumSquares - p)); } - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -2236,7 +2236,7 @@ public: << "\t\t vOut.y = -(xform->m_VariationWeights[" << varIndex << "] * (8 * precalcSqrtSumSquares - p));\n" << "\t\t}\n" << "\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -2274,7 +2274,7 @@ public: helper.Out.x = m_Weight * (std::sin(helper.In.x) * r + dx); helper.Out.y = m_Weight * (std::sin(helper.In.y) * r + dy); - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -2305,7 +2305,7 @@ public: << "\n" << "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * (sin(vIn.x) * r + dx);\n" << "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * (sin(vIn.y) * r + dy);\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -2362,7 +2362,7 @@ public: T r = m_Weight * std::pow(helper.m_PrecalcSumSquares, m_Cn); helper.Out.x = r * std::cos(temp); helper.Out.y = r * std::sin(temp); - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -2386,7 +2386,7 @@ public: << "\n" << "\t\tvOut.x = r * cos(temp);\n" << "\t\tvOut.y = r * sin(temp);\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -2542,7 +2542,7 @@ public: alpha = (std::atan2(y, x) + n * M_2PI) / Floor(m_Power); helper.Out.x = m_Weight * r * std::cos(alpha); helper.Out.y = m_Weight * r * std::sin(alpha); - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -2585,7 +2585,7 @@ public: << "\n" << "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * r * cos(alpha);\n" << "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * r * sin(alpha);\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -2689,7 +2689,7 @@ public: //Add final values in to variations totals. helper.Out.x = m_Weight * mx; helper.Out.y = m_Weight * my; - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -2752,7 +2752,7 @@ public: << "\n" << "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * mx;\n" << "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * my;\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -2817,7 +2817,7 @@ public: T y1 = sin(m_B * t); helper.Out.x = m_Weight * (x1 + m_C * t + m_E * y); helper.Out.y = m_Weight * (y1 + m_C * t + m_E * y); - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -2841,7 +2841,7 @@ public: << "\n" << "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * (x1 + " << c << " * t + " << e << " * y);\n" << "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * (y1 + " << c << " * t + " << e << " * y);\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -2960,7 +2960,7 @@ public: helper.Out.x = helper.m_PrecalcSqrtSumSquares * std::cos(a); helper.Out.y = helper.m_PrecalcSqrtSumSquares * std::sin(a); - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -2989,7 +2989,7 @@ public: << "\n" << "\t\tvOut.x = precalcSqrtSumSquares * cos(a);\n" << "\t\tvOut.y = precalcSqrtSumSquares * sin(a);\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -3142,7 +3142,7 @@ public: helper.Out.x = r * std::cos(a); helper.Out.y = r * std::sin(a); - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -3183,7 +3183,7 @@ public: << "\n" << "\t\tvOut.x = r * cos(a);\n" << "\t\tvOut.y = r * sin(a);\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -3244,7 +3244,7 @@ public: T temp = std::cosh(tau) - std::cos(sigma); helper.Out.x = m_Weight * std::sinh(tau) / temp; helper.Out.y = m_Weight * std::sin(sigma) / temp; - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -3266,7 +3266,7 @@ public: << "\n" << "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * sinh(tau) / temp;\n" << "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * sin(sigma) / temp;\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -3312,7 +3312,7 @@ public: T temp = std::cosh(tau) - std::cos(sigma); helper.Out.x = m_Weight * std::sinh(tau) / temp; helper.Out.y = m_Weight * std::sin(sigma) / temp; - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -3333,7 +3333,7 @@ public: << "\n" << "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * sinh(tau) / temp;\n" << "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * sin(sigma) / temp;\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -3385,7 +3385,7 @@ public: T temp = std::cosh(tau) - std::cos(sigma); helper.Out.x = m_Weight * std::sinh(tau) / temp; helper.Out.y = m_Weight * std::sin(sigma) / temp; - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -3413,7 +3413,7 @@ public: << "\n" << "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * sinh(tau) / temp;\n" << "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * sin(sigma) / temp;\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -3469,7 +3469,7 @@ public: T temp = std::cosh(tau) - std::cos(sigma); helper.Out.x = m_Weight * sinh(tau) / temp; helper.Out.y = m_Weight * sin(sigma) / temp; - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -3498,7 +3498,7 @@ public: << "\n" << "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * sinh(tau) / temp;\n" << "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * sin(sigma) / temp;\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -3582,7 +3582,7 @@ public: helper.Out.y = m_Weight * helper.In.y; } - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -3621,7 +3621,7 @@ public: << "\t\t vOut.y = xform->m_VariationWeights[" << varIndex << "] * vIn.y;\n" << "\t\t}\n" << "\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -3661,7 +3661,7 @@ public: else helper.Out.y = -(m_Weight * helper.In.y); - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -3679,7 +3679,7 @@ public: << "\t\telse\n" << "\t\t vOut.y = -(xform->m_VariationWeights[" << varIndex << "] * vIn.y);\n" << "\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -3721,7 +3721,7 @@ public: else helper.Out.y = m_Weight * helper.In.y; - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -3736,7 +3736,7 @@ public: << "\t\telse\n" << "\t\t vOut.y = xform->m_VariationWeights[" << varIndex << "] * vIn.y;\n" << "\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -3791,7 +3791,7 @@ public: helper.Out.x = m_Weight * xmax * std::cos(nu); helper.Out.y = m_Weight * std::sqrt(xmax - 1) * std::sqrt(xmax + 1) * sin(nu); - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -3840,7 +3840,7 @@ public: << "\n" << "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * xmax * cos(nu);\n" << "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * sqrt(xmax - 1) * sqrt(xmax + 1) * sin(nu);\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -3922,7 +3922,7 @@ public: mu /= m_Power; helper.Out.x = m_Weight * std::cosh(mu) * std::cos(nu); helper.Out.y = m_Weight * std::sinh(mu) * std::sin(nu); - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -3964,7 +3964,7 @@ public: << "\n" << "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * cosh(mu) * cos(nu);\n" << "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * sinh(mu) * sin(nu);\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -4032,7 +4032,7 @@ public: helper.Out.x = m_Weight * std::cosh(mu) * std::cos(nu); helper.Out.y = m_Weight * std::sinh(mu) * std::sin(nu); - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -4067,7 +4067,7 @@ public: << "\n" << "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * cosh(mu) * cos(nu);\n" << "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * sinh(mu) * sin(nu);\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -4131,7 +4131,7 @@ public: nu += m_Rotate; helper.Out.x = m_Weight * std::cosh(mu) * std::cos(nu); helper.Out.y = m_Weight * std::sinh(mu) * std::sin(nu); - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -4171,7 +4171,7 @@ public: << "\n" << "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * cosh(mu) * cos(nu);\n" << "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * sinh(mu) * sin(nu);\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -4226,7 +4226,7 @@ public: mu += m_Push; helper.Out.x = m_Weight * std::cosh(mu) * std::cos(nu); helper.Out.y = m_Weight * std::sinh(mu) * std::sin(nu); - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -4258,7 +4258,7 @@ public: << "\n" << "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * cosh(mu) * cos(nu);\n" << "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * sinh(mu) * sin(nu);\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -4315,7 +4315,7 @@ public: nu = fmod(nu + m_Rotate + T(M_PI), M_2PI) - T(M_PI); helper.Out.x = m_Weight * xmax * std::cos(nu); helper.Out.y = m_Weight * std::sqrt(xmax - 1) * std::sqrt(xmax + 1) * std::sin(nu); - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -4333,7 +4333,7 @@ public: << "\t\tif (xmax < 1)\n" << "\t\t xmax = 1;\n" << "\n" - << "\t\treal_t nu = acos(clamp(vIn.x / xmax, -(real_t)(1.0), (real_t)(1.0)));\n" + << "\t\treal_t nu = acos(clamp(vIn.x / xmax, (real_t)(-1.0), (real_t)(1.0)));\n" << "\n" << "\t\tif (vIn.y < 0)\n" << "\t\t nu *= -1;\n" @@ -4342,7 +4342,7 @@ public: << "\n" << "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * xmax * cos(nu);\n" << "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * sqrt(xmax - 1) * sqrt(xmax + 1) * sin(nu);\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -4401,7 +4401,7 @@ public: helper.Out.x = m_Weight * std::cosh(mu) * std::cos(nu); helper.Out.y = m_Weight * std::sinh(mu) * std::sin(nu); - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -4437,7 +4437,7 @@ public: << "\n" << "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * cosh(mu) * cos(nu);\n" << "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * sinh(mu) * sin(nu);\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } diff --git a/Source/Ember/Variations04.h b/Source/Ember/Variations04.h index b78bca4..6fc82c2 100644 --- a/Source/Ember/Variations04.h +++ b/Source/Ember/Variations04.h @@ -33,7 +33,7 @@ public: nu = nu + mu * m_Out + m_In / mu; helper.Out.x = m_Weight * std::cosh(mu) * std::cos(nu); helper.Out.y = m_Weight * std::sinh(mu) * std::sin(nu); - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -62,7 +62,7 @@ public: << "\n" << "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * cosh(mu) * cos(nu);\n" << "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * sinh(mu) * sin(nu);\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -204,7 +204,7 @@ public: } } - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -321,7 +321,7 @@ public: << "\t\t }\n" << "\t\t}\n" << "\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -420,7 +420,7 @@ public: helper.Out.y = (m_Weight * (8 * s - p)); } - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -484,7 +484,7 @@ public: << "\t\t vOut.y = -(xform->m_VariationWeights[" << varIndex << "] * (8 * s - p));\n" << "\t\t}\n" << "\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -533,7 +533,7 @@ public: helper.Out.x = m_Weight * r * helper.m_PrecalcCosa; helper.Out.y = m_Weight * r * helper.m_PrecalcSina; - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -554,7 +554,7 @@ public: << "\n" << "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * r * precalcCosa;\n" << "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * r * precalcSina;\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -594,7 +594,7 @@ public: 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)); - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -606,7 +606,7 @@ public: << "\n" << "\t\tvOut.x = (xform->m_VariationWeights[" << varIndex << "] / d) * (tanh(d) * ((real_t)(2.0) * vIn.x));\n" << "\t\tvOut.y = (xform->m_VariationWeights[" << varIndex << "] / d) * (cos(d) * ((real_t)(2.0) * vIn.y));\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -633,7 +633,7 @@ public: 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)); - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -645,7 +645,7 @@ public: << "\n" << "\t\tvOut.x = (xform->m_VariationWeights[" << varIndex << "] / (real_t)(2.0)) * (tanh(d) * ((real_t)(2.0) * vIn.x));\n" << "\t\tvOut.y = (xform->m_VariationWeights[" << varIndex << "] / (real_t)(2.0)) * (cos(d) * ((real_t)(2.0) * vIn.y));\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -1134,7 +1134,7 @@ public: r *= m_S2; helper.Out.x = m_Weight * (helper.In.x + (rand.Frand01() - T(0.5)) * r); helper.Out.y = m_Weight * (helper.In.y + (rand.Frand01() - T(0.5)) * r); - helper.Out.z = (m_VarType == eVariationType::VARTYPE_REG) ? 0 : helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -1158,7 +1158,7 @@ public: << "\n" << "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * (vIn.x + (MwcNext01(mwc) - (real_t)(0.5)) * r);\n" << "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * (vIn.y + (MwcNext01(mwc) - (real_t)(0.5)) * r);\n" - << "\t\tvOut.z = " << ((m_VarType == eVariationType::VARTYPE_REG) ? "0" : "vIn.z") << ";\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -1209,7 +1209,10 @@ public: T r = m_Weight * std::pow(helper.m_PrecalcSumSquares, m_Cn * m_A); helper.Out.x = r * std::cos(a) + m_B; helper.Out.y = r * std::sin(a) + m_B; - helper.Out.z = m_Weight * helper.In.z;//Original did not multiply by weight. Do it here to be consistent with others. + helper.Out.z = helper.In.z; + + if (m_VarType == eVariationType::VARTYPE_REG) + outPoint.m_Z = 0; } virtual string OpenCLString() const override @@ -1232,8 +1235,13 @@ public: << "\n" << "\t\tvOut.x = r * cos(a) + " << b << ";\n" << "\t\tvOut.y = r * sin(a) + " << b << ";\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" - << "\t}\n"; + << "\t\tvOut.z = vIn.z;\n"; + + if (m_VarType == eVariationType::VARTYPE_REG) + ss << "\t\toutPoint->m_Z = 0;\n"; + + ss + << "\t}\n"; return ss.str(); } @@ -1292,7 +1300,7 @@ public: T v = (sqX + sqY) * m_W;//Do not use precalcSumSquares here because its components are needed below. helper.Out.x = m_Weight * std::sin(helper.In.x) * (sqX + m_W - v); helper.Out.y = m_Weight * std::sin(helper.In.y) * (sqY + m_W - v); - helper.Out.z = (m_VarType == eVariationType::VARTYPE_REG) ? 0 : helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -1309,7 +1317,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 == eVariationType::VARTYPE_REG) ? "0" : "vIn.z") << ";\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -1378,7 +1386,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 == eVariationType::VARTYPE_REG) ? 0 : helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -1429,7 +1437,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 == eVariationType::VARTYPE_REG) ? "0" : "vIn.z") << ";\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -1527,7 +1535,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 == eVariationType::VARTYPE_REG) ? 0 : helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -1571,7 +1579,7 @@ public: << "\n" << "\t\tvOut.x = " << cosr << " * a + " << sinr << " * r;\n" << "\t\tvOut.y = -" << sinr << " * a + " << cosr << " * r;\n" - << "\t\tvOut.z = " << ((m_VarType == eVariationType::VARTYPE_REG) ? "0" : "vIn.z") << ";\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -2240,7 +2248,7 @@ public: helper.Out.y = m_Weight * helper.In.y; } - helper.Out.z = (m_VarType == eVariationType::VARTYPE_REG) ? 0 : helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -2307,7 +2315,7 @@ public: << "\t\t vOut.y = xform->m_VariationWeights[" << varIndex << "] * vIn.y;\n" << "\t\t}\n" << "\n" - << "\t\tvOut.z = " << ((m_VarType == eVariationType::VARTYPE_REG) ? "0" : "vIn.z") << ";\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -2963,7 +2971,7 @@ public: helper.Out.x = m_Weight * (fp1x + fp2x); helper.Out.y = m_Weight * (fp1y + fp2y); - helper.Out.z = (m_VarType == eVariationType::VARTYPE_REG) ? 0 : helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -3030,7 +3038,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 == eVariationType::VARTYPE_REG) ? "0" : "vIn.z") << ";\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -3852,7 +3860,7 @@ public: { helper.Out.x = m_Weight / Zeps(helper.m_PrecalcSqrtSumSquares); helper.Out.y = helper.m_PrecalcAtanyx; - helper.Out.z = (m_VarType == eVariationType::VARTYPE_REG) ? 0 : helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -3862,7 +3870,7 @@ public: ss << "\t{\n" << "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] / Zeps(precalcSqrtSumSquares);\n" << "\t\tvOut.y = precalcAtanyx;\n" - << "\t\tvOut.z = " << ((m_VarType == eVariationType::VARTYPE_REG) ? "0" : "vIn.z") << ";\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -3896,7 +3904,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 == eVariationType::VARTYPE_REG) ? 0 : helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -3926,7 +3934,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 == eVariationType::VARTYPE_REG) ? "0" : "vIn.z") << ";\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -4002,7 +4010,7 @@ public: helper.Out.x = xx * m_Weight; helper.Out.y = yy * m_Weight; - helper.Out.z = (m_VarType == eVariationType::VARTYPE_REG) ? 0 : helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -4035,7 +4043,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 == eVariationType::VARTYPE_REG) ? "0" : "vIn.z") << ";\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -4192,7 +4200,7 @@ public: helper.Out.y += m_Size * (y + Floor(helper.In.y)); } - helper.Out.z = (m_VarType == eVariationType::VARTYPE_REG) ? 0 : helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -4329,7 +4337,7 @@ public: << "\t\t vOut.y += " << size << " * (y + floor(vIn.y));\n" << "\t\t}\n" << "\n" - << "\t\tvOut.z = " << ((m_VarType == eVariationType::VARTYPE_REG) ? "0" : "vIn.z") << ";\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -4732,7 +4740,7 @@ public: } } - helper.Out.z = (m_VarType == eVariationType::VARTYPE_REG) ? 0 : helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -4789,7 +4797,7 @@ public: << "\t\t }\n" << "\t\t}\n" << "\n" - << "\t\tvOut.z = " << ((m_VarType == eVariationType::VARTYPE_REG) ? "0" : "vIn.z") << ";\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -4844,7 +4852,7 @@ public: T mod2 = std::exp(lnmod * m_ReInv - arg * m_Im100); helper.Out.x = m_Weight * mod2 * std::cos(temp); helper.Out.y = m_Weight * mod2 * std::sin(temp); - helper.Out.z = (m_VarType == eVariationType::VARTYPE_REG) ? 0 : helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -4866,7 +4874,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 == eVariationType::VARTYPE_REG) ? "0" : "vIn.z") << ";\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -5036,7 +5044,7 @@ public: 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 == eVariationType::VARTYPE_REG) ? 0 : helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -5068,7 +5076,7 @@ public: << "\t\tb = SafeSqrt(1 - SQR(a));\n" << "\n" << "\t\tvOut.y = " << vy << " * atan2(a, b) * r;\n" - << "\t\tvOut.z = " << ((m_VarType == eVariationType::VARTYPE_REG) ? "0" : "vIn.z") << ";\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } diff --git a/Source/Ember/Variations05.h b/Source/Ember/Variations05.h index 7ab5142..5041573 100644 --- a/Source/Ember/Variations05.h +++ b/Source/Ember/Variations05.h @@ -133,7 +133,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 == eVariationType::VARTYPE_REG) ? 0 : helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -195,7 +195,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 == eVariationType::VARTYPE_REG) ? "0" : "vIn.z") << ";\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -292,7 +292,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 == eVariationType::VARTYPE_REG) ? 0 : helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -327,7 +327,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 == eVariationType::VARTYPE_REG) ? "0" : "vIn.z") << ";\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -418,7 +418,7 @@ public: helper.Out.x = m_Weight * ux; helper.Out.y = m_Weight * uy; - helper.Out.z = (m_VarType == eVariationType::VARTYPE_REG) ? 0 : helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -456,7 +456,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 == eVariationType::VARTYPE_REG) ? "0" : "vIn.z") << ";\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -1086,7 +1086,7 @@ public: T sucv = su * cv; T x = std::pow(std::abs(cucv), m_XPow) + (cucv * m_XPow) + (T(0.25) * atOmegaX);//Must fabs first argument to pow, because negative values will return NaN. T y = std::pow(std::abs(sucv), m_YPow) + (sucv * m_YPow) + (T(0.25) * atOmegaY);//Original did not do this and would frequently return bad values. - T z = std::pow(std::abs(sv), m_ZPow) + sv * m_ZPow; + T z = std::pow(std::abs(sv), m_ZPow) + sv * m_ZPow; helper.Out.x = m_Weight * x; helper.Out.y = m_Weight * y; helper.Out.z = m_Weight * z; @@ -1356,7 +1356,7 @@ public: helper.Out.y = m_Weight * helper.In.y; } - helper.Out.z = (m_VarType == eVariationType::VARTYPE_REG) ? 0 : helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -1417,7 +1417,7 @@ public: << "\t\t vOut.y = xform->m_VariationWeights[" << varIndex << "] * vIn.y;\n" << "\t\t}\n" << "\n" - << "\t\tvOut.z = " << ((m_VarType == eVariationType::VARTYPE_REG) ? "0" : "vIn.z") << ";\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -1498,7 +1498,7 @@ public: helper.Out.y = m_Weight * helper.In.y; } - helper.Out.z = (m_VarType == eVariationType::VARTYPE_REG) ? 0 : helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -1529,7 +1529,7 @@ public: << "\t\t vOut.y = xform->m_VariationWeights[" << varIndex << "] * vIn.y;\n" << "\t\t}\n" << "\n" - << "\t\tvOut.z = " << ((m_VarType == eVariationType::VARTYPE_REG) ? "0" : "vIn.z") << ";\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -1655,7 +1655,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 == eVariationType::VARTYPE_REG) ? 0 : helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -1676,7 +1676,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 == eVariationType::VARTYPE_REG) ? "0" : "vIn.z") << ";\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -1702,8 +1702,8 @@ private: /// /// waves2_3D. /// Original used a precalc for the input points, but it doesn't -/// work with Ember's design, so it gets calculated on every iter -/// which is slightly slower. +/// work with Ember's design (and is also likely wrong), so it gets calculated on every iter +/// which is slightly slower, but more correct. /// template class EMBER_API Waves23DVariation : public ParametricVariation @@ -2130,8 +2130,8 @@ public: virtual void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand) override { T b = m_Weight / (helper.m_PrecalcSumSquares * T(0.25) + 1); - T roundX = Rint(helper.In.x); - T roundY = Rint(helper.In.y); + T roundX = std::rint(helper.In.x); + T roundY = std::rint(helper.In.y); T offsetX = helper.In.x - roundX; T offsetY = helper.In.y - roundY; helper.Out.x = helper.In.x * b; @@ -2174,7 +2174,7 @@ public: helper.Out.x += helper.In.x * m_Px; helper.Out.y += helper.In.y * m_Py; - helper.Out.z = (m_VarType == eVariationType::VARTYPE_REG) ? 0 : helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -2234,7 +2234,7 @@ public: << "\n" << "\t\tvOut.x += vIn.x * " << px << ";\n" << "\t\tvOut.y += vIn.y * " << py << ";\n" - << "\t\tvOut.z = " << ((m_VarType == eVariationType::VARTYPE_REG) ? "0" : "vIn.z") << ";\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -2278,7 +2278,7 @@ public: helper.Out.x = m_Weight * r * std::cos(a); helper.Out.y = m_Weight * r * std::sin(a); - helper.Out.z = (m_VarType == eVariationType::VARTYPE_REG) ? 0 : helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -2294,7 +2294,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 == eVariationType::VARTYPE_REG) ? "0" : "vIn.z") << ";\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -2941,7 +2941,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 == eVariationType::VARTYPE_REG) ? 0 : helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -3062,7 +3062,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 == eVariationType::VARTYPE_REG) ? "0" : "vIn.z") << ";\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } diff --git a/Source/Ember/Variations06.h b/Source/Ember/Variations06.h index fb50af5..1fec36c 100644 --- a/Source/Ember/Variations06.h +++ b/Source/Ember/Variations06.h @@ -46,7 +46,12 @@ public: //Infinite number of small cells? No effect . . . if (s == 0) + { + helper.Out.x = 0; + helper.Out.y = 0; + helper.Out.z = DefaultZ(helper); return; + } //Get co-ordinates, and convert to hex co-ordinates. u.x = helper.In.x; @@ -96,7 +101,7 @@ public: DYo = u.y - P[0].y; //Apply "interesting bit" to cell's DXo and DYo co-ordinates. //trgL is the defined value of l, independent of any rotation. - trgL = std::pow(Zeps(L1), m_Power) * m_Scale;//Original added 1e-100, use Zeps to be more precise. + trgL = std::pow(std::abs(L1), m_Power) * m_Scale;//Original added 1e-100, use Zeps to be more precise. //Rotate. v.x = DXo * m_RotCos + DYo * m_RotSin; v.y = -DXo * m_RotSin + DYo * m_RotCos; @@ -110,7 +115,7 @@ public: //L is maximum of L1 or L2 . . . //When L = 0.8 or higher . . . match trgL/L2 exactly. //When L = T(0.5) or less . . . match trgL/L1 exactly. - L = (L1 > L2) ? L1 : L2; + L = std::max(L1, L2); if (L < T(0.5)) { @@ -130,7 +135,7 @@ public: //Finally add values in. helper.Out.x = m_Weight * v.x; helper.Out.y = m_Weight * v.y; - helper.Out.z = (m_VarType == eVariationType::VARTYPE_REG) ? 0 : helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -155,7 +160,12 @@ public: << "\t\ts = " << cellsize << ";\n" << "\n" << "\t\tif (s == 0)\n" - << "\t\t return;\n" + << "\t\t{\n" + << "\t\t vOut.x = 0;\n" + << "\t\t vOut.y = 0;\n" + << "\t\t vOut.z = " << DefaultZCl() + << "\t\t return;\n" + << "\t\t}\n" << "\n" << "\t\tU.x = vIn.x;\n" << "\t\tU.y = vIn.y;\n" @@ -201,7 +211,7 @@ public: << "\t\tDXo = U.x - P[0].x;\n" << "\t\tDYo = U.y - P[0].y;\n" << "\n" - << "\t\ttrgL = pow(Zeps(L1), " << power << ") * " << scale << ";\n" + << "\t\ttrgL = pow(fabs(L1), " << power << ") * " << scale << ";\n" << "\n" << "\t\tVx = DXo * " << rotcos << " + DYo * " << rotsin << ";\n" << "\t\tVy = -DXo * " << rotsin << " + DYo * " << rotcos << ";\n" @@ -209,8 +219,7 @@ public: << "\t\tU.x = Vx + P[0].x;\n" << "\t\tU.y = Vy + P[0].y;\n" << "\t\tL2 = Voronoi(&P[0], 7, 0, &U);\n" - << "\n" - << "\t\tL = (L1 > L2) ? L1 : L2;\n" + << "\t\tL = max(L1, L2);\n" << "\n" << "\t\tif (L < 0.5)\n" << "\t\t{\n" @@ -232,7 +241,7 @@ public: << "\n" << "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * Vx;\n" << "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * Vy;\n" - << "\t\tvOut.z = " << ((m_VarType == eVariationType::VARTYPE_REG) ? "0" : "vIn.z") << ";\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -366,7 +375,7 @@ public: params.Y = m_Sina * xTmp + m_Cosa * yTmp; helper.Out.x = m_AdjustedWeight * params.X; helper.Out.y = m_AdjustedWeight * params.Y; - helper.Out.z = (m_VarType == eVariationType::VARTYPE_REG) ? 0 : helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -441,7 +450,7 @@ public: << "\n" << "\t\tvOut.x = " << adjustedWeight << " * params.X;\n" << "\t\tvOut.y = " << adjustedWeight << " * params.Y;\n" - << "\t\tvOut.z = " << ((m_VarType == eVariationType::VARTYPE_REG) ? "0" : "vIn.z") << ";\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -1544,7 +1553,7 @@ public: helper.Out.x = xTmp; helper.Out.y = yTmp; - helper.Out.z = (m_VarType == eVariationType::VARTYPE_REG) ? 0 : helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -1646,7 +1655,7 @@ public: << "\n" << "\t\tvOut.x = xTmp;\n" << "\t\tvOut.y = yTmp;\n" - << "\t\tvOut.z = " << ((m_VarType == eVariationType::VARTYPE_REG) ? "0" : "vIn.z") << ";\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -2737,7 +2746,7 @@ public: break; } - helper.Out.z = (m_VarType == eVariationType::VARTYPE_REG) ? 0 : helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual string OpenCLString() const override @@ -3092,7 +3101,7 @@ public: << "\t\t break;\n" << "\t\t}\n" << "\n" - << "\t\tvOut.z = " << ((m_VarType == eVariationType::VARTYPE_REG) ? "0" : "vIn.z") << ";\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -3749,7 +3758,7 @@ public: dO += p[4]; helper.Out.x = m_Weight * dO.x; helper.Out.y = m_Weight * dO.y; - helper.Out.z = (m_VarType == eVariationType::VARTYPE_REG) ? 0 : helper.In.z; + helper.Out.z = DefaultZ(helper); } virtual vector OpenCLGlobalFuncNames() const override @@ -3847,7 +3856,7 @@ public: << "\t\tdO += p[4];\n" << "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * dO.x;\n" << "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * dO.y;\n" - << "\t\tvOut.z = " << ((m_VarType == eVariationType::VARTYPE_REG) ? "0" : "vIn.z") << ";\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t}\n"; return ss.str(); } @@ -3920,7 +3929,7 @@ class EMBER_API PostSmartcropVariation : public ParametricVariation public: PostSmartcropVariation(T weight = 1.0) : ParametricVariation("post_smartcrop", eVariationId::VAR_POST_SMARTCROP, weight) { - m_AssignType = eVariationAssignType::ASSIGNTYPE_SET; + m_PrePostAssignType = eVariationAssignType::ASSIGNTYPE_SET; m_VarType = eVariationType::VARTYPE_POST;//Very special usage, post only. Init(); } @@ -4417,6 +4426,984 @@ private: T m_C; }; +/// +/// erf. +/// +template +class EMBER_API ErfVariation : public Variation +{ +public: + ErfVariation(T weight = 1.0) : Variation("erf", eVariationId::VAR_ERF, weight) { } + + VARCOPY(ErfVariation) + + virtual void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand) override + { + helper.Out.x = m_Weight * std::erf(helper.In.x); + helper.Out.y = m_Weight * std::erf(helper.In.y); + helper.Out.z = DefaultZ(helper); + } + + virtual string OpenCLString() const override + { + ostringstream ss; + intmax_t varIndex = IndexInXform(); + ss << "\t{\n" + << "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * erf(vIn.x);\n" + << "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * erf(vIn.y);\n" + << "\t\tvOut.z = " << DefaultZCl() + << "\t}\n"; + return ss.str(); + } +}; + +/// +/// xerf. +/// +template +class EMBER_API XerfVariation : public Variation +{ +public: + XerfVariation(T weight = 1.0) : Variation("xerf", eVariationId::VAR_XERF, weight, true) { } + + VARCOPY(XerfVariation) + + virtual void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand) override + { + T r2 = Sqr(std::sqrt(helper.m_PrecalcSumSquares + SQR(helper.In.z))); + helper.Out.x = m_Weight * (std::abs(helper.In.x) >= 2 ? helper.In.x / r2 : std::erf(helper.In.x)); + helper.Out.y = m_Weight * (std::abs(helper.In.y) >= 2 ? helper.In.y / r2 : std::erf(helper.In.y)); + helper.Out.z = m_Weight * (std::abs(helper.In.z) >= 2 ? helper.In.z / r2 : std::erf(helper.In.z)); + } + + virtual string OpenCLString() const override + { + ostringstream ss; + intmax_t varIndex = IndexInXform(); + ss << "\t{\n" + << "\t\treal_t r2 = Sqr(sqrt(precalcSumSquares + SQR(vIn.z)));\n" + << "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * (fabs(vIn.x) >= 2 ? vIn.x / r2 : erf(vIn.x));\n" + << "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * (fabs(vIn.y) >= 2 ? vIn.y / r2 : erf(vIn.y));\n" + << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * (fabs(vIn.z) >= 2 ? vIn.z / r2 : erf(vIn.z));\n" + << "\t}\n"; + return ss.str(); + } + + virtual vector OpenCLGlobalFuncNames() const override + { + return vector { "Sqr" }; + } +}; + +template +class EMBER_API WVariation : public ParametricVariation +{ +public: + WVariation(T weight = 1.0) : ParametricVariation("w", eVariationId::VAR_W, weight, true, true, false, false, true) + { + Init(); + } + + PARVARCOPY(WVariation) + + virtual void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand) override + { + T a = helper.m_PrecalcAtanyx; + T r = helper.m_PrecalcSqrtSumSquares; + T a2 = a + m_Angle; + + if (a2 < -T(M_PI)) + a2 += M_2PI; + + if (a2 > T(M_PI)) + a2 -= M_2PI; + + T s, c; + T total = 0; + T total2 = 0; + T temp1, temp2, temp3, temp4; + + if (m_Hypergon != 0) + { + temp1 = fmod(std::abs(a), M_2PI / m_HypergonN) - T(M_PI) / m_HypergonN; + temp2 = Sqr(std::tan(temp1)) + 1; + + if (temp2 >= Sqr(m_HypergonD)) + { + total += m_Hypergon; + } + else + { + temp3 = m_HypergonD; + total += m_Hypergon * (m_HypergonD - std::sqrt(Sqr(m_HypergonD) - temp2)) / std::sqrt(temp2); + } + } + + if (m_Star != 0) + { + temp1 = std::tan(std::abs(fmod(std::abs(a), M_2PI / m_StarN) - T(M_PI) / m_StarN)); + total += m_Star * std::sqrt(Sqr(m_TanStarSlope) * (1 + Sqr(temp1)) / Sqr(temp1 + m_TanStarSlope)); + } + + if (m_Lituus != 0) + { + total += m_Lituus * std::pow(std::abs(a / T(M_PI) + 1), m_InvLituusA); + } + + if (m_Super != 0) + { + temp4 = a * m_SuperM4th; + sincos(temp4, &s, &c); + total += m_Super * std::pow(std::pow(std::abs(c), m_SuperN2) + std::pow(std::abs(s), m_SuperN3), m_OneOverSuperN1); + } + + if (r <= total) + { + if (m_Hypergon != 0.0) + { + temp1 = fmod(std::abs(a2), M_2PI / m_HypergonN) - T(M_PI) / m_HypergonN; + temp2 = Sqr(std::tan(temp1)) + 1; + + if (temp2 >= Sqr(m_HypergonD)) + { + total2 += m_Hypergon; + } + else + { + temp3 = m_HypergonD; + total2 += m_Hypergon * (m_HypergonD - std::sqrt(Sqr(m_HypergonD) - temp2)) / std::sqrt(temp2); + } + } + + if (m_Star != 0) + { + temp1 = std::tan(std::abs(fmod(std::abs(a2), M_2PI / m_StarN) - T(M_PI) / m_StarN)); + total2 += m_Star * std::sqrt(Sqr(m_TanStarSlope) * (1 + Sqr(temp1)) / Sqr(temp1 + m_TanStarSlope)); + } + + if (m_Lituus != 0) + { + total2 += m_Lituus * std::pow(std::abs(a2 / T(M_PI) + 1), m_InvLituusA); + } + + if (m_Super != 0) + { + temp4 = a2 * m_SuperM4th; + sincos(temp4, &s, &c); + total2 += m_Super * std::pow(std::pow(std::abs(c), m_SuperN2) + std::pow(std::abs(s), m_SuperN3), m_OneOverSuperN1); + } + + r = m_Weight * total2 * r / total; + sincos(a2, &s, &c); + helper.Out.x = r * c; + helper.Out.y = r * s; + } + else + { + helper.Out.x = m_Weight * helper.In.x; + helper.Out.y = m_Weight * helper.In.y; + } + + helper.Out.z = DefaultZ(helper); + } + + virtual string OpenCLString() const override + { + ostringstream ss, ss2; + intmax_t i = 0, varIndex = IndexInXform(); + ss2 << "_" << XformIndexInEmber() << "]"; + string index = ss2.str(); + string angle = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string hypergon = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string hypergonN = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string hypergonR = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string star = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string starN = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string starSlope = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string lituus = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string lituusA = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string super = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string superM = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string superN1 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string superN2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string superN3 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string invLituusA = "parVars[" + ToUpper(m_Params[i++].Name()) + index;//Precalc + string tanStarSlope = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string hypergonD = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string superM4th = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string oneOverSuperN1 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + ss << "\t{\n" + << "\t\treal_t a = precalcAtanyx;\n" + << "\t\treal_t r = precalcSqrtSumSquares;\n" + << "\t\treal_t a2 = a + " << angle << ";\n" + << "\n" + << "\t\tif (a2 < -M_PI)\n" + << "\t\t a2 += M_2PI;\n" + << "\n" + << "\t\tif (a2 > M_PI)\n" + << "\t\t a2 -= M_2PI;\n" + << "\n" + << "\t\treal_t s, c;\n" + << "\t\treal_t total = 0;\n" + << "\t\treal_t total2 = 0;\n" + << "\t\treal_t temp1, temp2, temp3, temp4;\n" + << "\n" + << "\t\tif (" << hypergon << " != 0)\n" + << "\t\t{\n" + << "\t\t temp1 = fmod(fabs(a), M_2PI / " << hypergonN << ") - M_PI / " << hypergonN << ";\n" + << "\t\t temp2 = Sqr(tan(temp1)) + 1;\n" + << "\n" + << "\t\t if (temp2 >= Sqr(" << hypergonD << "))\n" + << "\t\t {\n" + << "\t\t total += " << hypergon << ";\n" + << "\t\t }\n" + << "\t\t else\n" + << "\t\t {\n" + << "\t\t temp3 = " << hypergonD << ";\n" + << "\t\t total += " << hypergon << " * (" << hypergonD << " - sqrt(Sqr(" << hypergonD << ") - temp2)) / sqrt(temp2);\n" + << "\t\t }\n" + << "\t\t}\n" + << "\n" + << "\t\tif (" << star << "!= 0)\n" + << "\t\t{\n" + << "\t\t temp1 = tan(fabs(fmod(fabs(a), M_2PI / " << starN << ") - M_PI / " << starN << "));\n" + << "\t\t total += " << star << " * sqrt(Sqr(" << tanStarSlope << ") * (1 + Sqr(temp1)) / Sqr(temp1 + " << tanStarSlope << "));\n" + << "\t\t}\n" + << "\n" + << "\t\tif (" << lituus << " != 0)\n" + << "\t\t{\n" + << "\t\t total += " << lituus << " * pow(fabs(a / M_PI + 1), " << invLituusA << ");\n" + << "\t\t}\n" + << "\n" + << "\t\tif (" << super << " != 0)\n" + << "\t\t{\n" + << "\t\t temp4 = a * " << superM4th << ";\n" + << "\t\t s = sincos(temp4, &c);\n" + << "\t\t total += " << super << " * pow(pow(fabs(c), " << superN2 << ") + pow(fabs(s), " << superN3 << "), " << oneOverSuperN1 << ");\n" + << "\t\t}\n" + << "\n" + << "\t\tif (r <= total)\n" + << "\t\t{\n" + << "\t\t if (" << hypergon << " != 0.0)\n" + << "\t\t {\n" + << "\t\t temp1 = fmod(fabs(a2), M_2PI / " << hypergonN << ") - M_PI / " << hypergonN << ";\n" + << "\t\t temp2 = Sqr(tan(temp1)) + 1;\n" + << "\n" + << "\t\t if (temp2 >= Sqr(" << hypergonD << "))\n" + << "\t\t {\n" + << "\t\t total2 += " << hypergon << ";\n" + << "\t\t }\n" + << "\t\t else\n" + << "\t\t {\n" + << "\t\t temp3 = " << hypergonD << ";\n" + << "\t\t total2 += " << hypergon << " * (" << hypergonD << " - sqrt(Sqr(" << hypergonD << ") - temp2)) / sqrt(temp2);\n" + << "\t\t }\n" + << "\t\t }\n" + << "\n" + << "\t\t if (" << star << " != 0)\n" + << "\t\t {\n" + << "\t\t temp1 = tan(fabs(fmod(fabs(a2), M_2PI / " << starN << ") - M_PI / " << starN << "));\n" + << "\t\t total2 += " << star << " * sqrt(Sqr(" << tanStarSlope << ") * (1 + Sqr(temp1)) / Sqr(temp1 + " << tanStarSlope << "));\n" + << "\t\t }\n" + << "\n" + << "\t\t if (" << lituus << " != 0)\n" + << "\t\t {\n" + << "\t\t total2 += " << lituus << " * pow(fabs(a2 / M_PI + 1), " << invLituusA << ");\n" + << "\t\t }\n" + << "\n" + << "\t\t if (" << super << " != 0)\n" + << "\t\t {\n" + << "\t\t temp4 = a2 * " << superM4th << ";\n" + << "\t\t s = sincos(temp4, &c);\n" + << "\t\t total2 += " << super << " * pow(pow(fabs(c), " << superN2 << ") + pow(fabs(s), " << superN3 << "), " << oneOverSuperN1 << ");\n" + << "\t\t }\n" + << "\n" + << "\t\t r = xform->m_VariationWeights[" << varIndex << "] * total2 * r / total;\n" + << "\t\t s = sincos(a2, &c);\n" + << "\t\t vOut.x = r * c;\n" + << "\t\t vOut.y = r * s;\n" + << "\t\t}\n" + << "\t\telse\n" + << "\t\t{\n" + << "\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 = " << DefaultZCl() + << "\t}\n"; + return ss.str(); + } + + virtual vector OpenCLGlobalFuncNames() const override + { + return vector { "Sqr" }; + } + + virtual void Precalc() override + { + m_HypergonD = std::sqrt(1 + SQR(m_HypergonR)); + m_InvLituusA = -m_LituusA; + + if (IsClose(m_StarSlope, T(M_PI_2))) + m_TanStarSlope = std::tan(m_StarSlope - T(0.05));//Original did not do this, but it makes no sense to take tan(pi/2) because it's undefined. + else + m_TanStarSlope = std::tan(m_StarSlope); + + m_SuperM4th = m_SuperM / 4; + m_OneOverSuperN1 = -1 / Zeps(m_SuperN1); + } + +protected: + void Init() + { + string prefix = Prefix(); + m_Params.clear(); + m_Params.push_back(ParamWithName(&m_Angle, prefix + "w_angle", 0, eParamType::REAL_CYCLIC, T(-M_PI), T(M_PI))); + m_Params.push_back(ParamWithName(&m_Hypergon, prefix + "w_hypergon")); + m_Params.push_back(ParamWithName(&m_HypergonN, prefix + "w_hypergon_n", 4, eParamType::INTEGER, 3)); + m_Params.push_back(ParamWithName(&m_HypergonR, prefix + "w_hypergon_r", 1)); + m_Params.push_back(ParamWithName(&m_Star, prefix + "w_star")); + m_Params.push_back(ParamWithName(&m_StarN, prefix + "w_star_n", 5, eParamType::INTEGER, 3)); + m_Params.push_back(ParamWithName(&m_StarSlope, prefix + "w_star_slope", 2, eParamType::REAL, EPS, T(M_PI_2))); + m_Params.push_back(ParamWithName(&m_Lituus, prefix + "w_lituus")); + m_Params.push_back(ParamWithName(&m_LituusA, prefix + "w_lituus_a", 1)); + m_Params.push_back(ParamWithName(&m_Super, prefix + "w_super")); + m_Params.push_back(ParamWithName(&m_SuperM, prefix + "w_super_m", 1)); + m_Params.push_back(ParamWithName(&m_SuperN1, prefix + "w_super_n1", 1)); + m_Params.push_back(ParamWithName(&m_SuperN2, prefix + "w_super_n2", 1)); + m_Params.push_back(ParamWithName(&m_SuperN3, prefix + "w_super_n3", 1)); + m_Params.push_back(ParamWithName(true, &m_InvLituusA, prefix + "w_inv_lituus_a"));//Precalc + m_Params.push_back(ParamWithName(true, &m_TanStarSlope, prefix + "w_tan_star_slope")); + m_Params.push_back(ParamWithName(true, &m_HypergonD, prefix + "w_hypergon_d")); + m_Params.push_back(ParamWithName(true, &m_SuperM4th, prefix + "w_super_m_4th")); + m_Params.push_back(ParamWithName(true, &m_OneOverSuperN1, prefix + "w_one_over_super_n1")); + } + +private: + T m_Angle; + T m_Hypergon; + T m_HypergonN; + T m_HypergonR; + T m_Star; + T m_StarN; + T m_StarSlope; + T m_Lituus; + T m_LituusA; + T m_Super; + T m_SuperM; + T m_SuperN1; + T m_SuperN2; + T m_SuperN3; + T m_InvLituusA;//Precalc + T m_TanStarSlope; + T m_HypergonD; + T m_SuperM4th; + T m_OneOverSuperN1; +}; + +template +class EMBER_API XVariation : public ParametricVariation +{ +public: + XVariation(T weight = 1.0) : ParametricVariation("x", eVariationId::VAR_X, weight, true, false, false, false, true) + { + Init(); + } + + PARVARCOPY(XVariation) + + virtual void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand) override + { + T a = helper.m_PrecalcAtanyx; + T a90 = atan2(helper.In.x, -helper.In.y); + T r; + T s, c; + T total = 0; + T temp1, temp2, temp3, temp4; + + if (m_Hypergon != 0) + { + temp1 = fmod(std::abs(a), M_2PI / m_HypergonN) - T(M_PI) / m_HypergonN; + temp2 = Sqr(std::tan(temp1)) + 1; + + if (temp2 >= Sqr(m_HypergonD)) + { + total += m_Hypergon; + } + else + { + temp3 = m_HypergonD; + total += m_Hypergon * (m_HypergonD - std::sqrt(Sqr(m_HypergonD) - temp2)) / std::sqrt(temp2); + } + } + + if (m_Star != 0) + { + temp1 = std::tan(std::abs(fmod(std::abs(a), M_2PI / m_StarN) - T(M_PI) / m_StarN)); + total += m_Star * std::sqrt(Sqr(m_TanStarSlope) * (1 + Sqr(temp1)) / Sqr(temp1 + m_TanStarSlope)); + } + + if (m_Lituus != 0) + { + total += m_Lituus * std::pow(std::fabs(a / T(M_PI) + 1), m_InvLituusA); + } + + if (m_Super != 0) + { + temp4 = a * m_SuperM4th; + sincos(temp4, &s, &c); + total += m_Super * std::pow(std::pow(std::abs(c), m_SuperN2) + std::pow(std::abs(s), m_SuperN3), m_OneOverSuperN1); + } + + r = m_Weight * std::sqrt(helper.m_PrecalcSumSquares + Sqr(total)); + sincos(a, &s, &c); + helper.Out.x = r * c; + helper.Out.y = r * s; + helper.Out.z = DefaultZ(helper); + } + + virtual string OpenCLString() const override + { + ostringstream ss, ss2; + intmax_t i = 0, varIndex = IndexInXform(); + ss2 << "_" << XformIndexInEmber() << "]"; + string index = ss2.str(); + string hypergon = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string hypergonN = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string hypergonR = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string star = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string starN = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string starSlope = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string lituus = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string lituusA = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string super = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string superM = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string superN1 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string superN2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string superN3 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string invLituusA = "parVars[" + ToUpper(m_Params[i++].Name()) + index;//Precalc + string tanStarSlope = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string hypergonD = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string superM4th = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string oneOverSuperN1 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + ss << "\t{\n" + << "\t\treal_t a = precalcAtanyx;\n" + << "\t\treal_t a90 = atan2(vIn.x, -vIn.y);\n" + << "\t\treal_t r;\n" + << "\t\treal_t s, c;\n" + << "\t\treal_t total = 0;\n" + << "\t\treal_t temp1, temp2, temp3, temp4;\n" + << "\n" + << "\t\tif (" << hypergon << " != 0)\n" + << "\t\t{\n" + << "\t\t temp1 = fmod(fabs(a), M_2PI / " << hypergonN << ") - M_PI / " << hypergonN << ";\n" + << "\t\t temp2 = Sqr(tan(temp1)) + 1;\n" + << "\n" + << "\t\t if (temp2 >= Sqr(" << hypergonD << "))\n" + << "\t\t {\n" + << "\t\t total += " << hypergon << ";\n" + << "\t\t }\n" + << "\t\t else\n" + << "\t\t {\n" + << "\t\t temp3 = " << hypergonD << ";\n" + << "\t\t total += " << hypergon << " * (" << hypergonD << " - sqrt(Sqr(" << hypergonD << ") - temp2)) / sqrt(temp2);\n" + << "\t\t }\n" + << "\t\t}\n" + << "\n" + << "\t\tif (" << star << " != 0)\n" + << "\t\t{\n" + << "\t\t temp1 = tan(fabs(fmod(fabs(a), M_2PI / " << starN << ") - M_PI / " << starN << "));\n" + << "\t\t total += " << star << " * sqrt(Sqr(" << tanStarSlope << ") * (1 + Sqr(temp1)) / Sqr(temp1 + " << tanStarSlope << "));\n" + << "\t\t}\n" + << "\n" + << "\t\tif (" << lituus << " != 0)\n" + << "\t\t{\n" + << "\t\t total += " << lituus << " * pow(fabs(a / M_PI + 1), " << invLituusA << ");\n" + << "\t\t}\n" + << "\n" + << "\t\tif (" << super << " != 0)\n" + << "\t\t{\n" + << "\t\t temp4 = a * " << superM4th << ";\n" + << "\t\t s = sincos(temp4, &c);\n" + << "\t\t total += " << super << " * pow(pow(fabs(c), " << superN2 << ") + pow(fabs(s), " << superN3 << "), " << oneOverSuperN1 << ");\n" + << "\t\t}\n" + << "\n" + << "\t\tr = xform->m_VariationWeights[" << varIndex << "] * sqrt(precalcSumSquares + Sqr(total));\n" + << "\t\ts = sincos(a, &c);\n" + << "\t\tvOut.x = r * c;\n" + << "\t\tvOut.y = r * s;\n" + << "\t\tvOut.z = " << DefaultZCl() + << "\t}\n"; + return ss.str(); + } + + virtual vector OpenCLGlobalFuncNames() const override + { + return vector { "Sqr" }; + } + + virtual void Precalc() override + { + m_HypergonD = std::sqrt(1 + SQR(m_HypergonR)); + m_InvLituusA = -m_LituusA; + + if (IsClose(m_StarSlope, T(M_PI_2))) + m_TanStarSlope = std::tan(m_StarSlope - T(0.05));//Original did not do this, but it makes no sense to take tan(pi/2) because it's undefined. + else + m_TanStarSlope = std::tan(m_StarSlope); + + m_SuperM4th = m_SuperM / 4; + m_OneOverSuperN1 = -1 / Zeps(m_SuperN1); + } + +protected: + void Init() + { + string prefix = Prefix(); + m_Params.clear(); + m_Params.push_back(ParamWithName(&m_Hypergon, prefix + "x_hypergon")); + m_Params.push_back(ParamWithName(&m_HypergonN, prefix + "x_hypergon_n", 4, eParamType::INTEGER, 3)); + m_Params.push_back(ParamWithName(&m_HypergonR, prefix + "x_hypergon_r", 1)); + m_Params.push_back(ParamWithName(&m_Star, prefix + "x_star")); + m_Params.push_back(ParamWithName(&m_StarN, prefix + "x_star_n", 5, eParamType::INTEGER, 3)); + m_Params.push_back(ParamWithName(&m_StarSlope, prefix + "x_star_slope", 2, eParamType::REAL, EPS, T(M_PI_2))); + m_Params.push_back(ParamWithName(&m_Lituus, prefix + "x_lituus")); + m_Params.push_back(ParamWithName(&m_LituusA, prefix + "x_lituus_a", 1)); + m_Params.push_back(ParamWithName(&m_Super, prefix + "x_super")); + m_Params.push_back(ParamWithName(&m_SuperM, prefix + "x_super_m", 1)); + m_Params.push_back(ParamWithName(&m_SuperN1, prefix + "x_super_n1", 1)); + m_Params.push_back(ParamWithName(&m_SuperN2, prefix + "x_super_n2", 1)); + m_Params.push_back(ParamWithName(&m_SuperN3, prefix + "x_super_n3", 1)); + m_Params.push_back(ParamWithName(true, &m_InvLituusA, prefix + "x_inv_lituus_a"));//Precalc + m_Params.push_back(ParamWithName(true, &m_TanStarSlope, prefix + "x_tan_star_slope")); + m_Params.push_back(ParamWithName(true, &m_HypergonD, prefix + "x_hypergon_d")); + m_Params.push_back(ParamWithName(true, &m_SuperM4th, prefix + "x_super_m_4th")); + m_Params.push_back(ParamWithName(true, &m_OneOverSuperN1, prefix + "x_one_over_super_n1")); + } + +private: + T m_Hypergon; + T m_HypergonN; + T m_HypergonR; + T m_Star; + T m_StarN; + T m_StarSlope; + T m_Lituus; + T m_LituusA; + T m_Super; + T m_SuperM; + T m_SuperN1; + T m_SuperN2; + T m_SuperN3; + T m_InvLituusA;//Precalc + T m_TanStarSlope; + T m_HypergonD; + T m_SuperM4th; + T m_OneOverSuperN1; +}; + +template +class EMBER_API YVariation : public ParametricVariation +{ +public: + YVariation(T weight = 1.0) : ParametricVariation("y", eVariationId::VAR_Y, weight, true, true, false, false, true) + { + Init(); + } + + PARVARCOPY(YVariation) + + virtual void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand) override + { + T a = helper.m_PrecalcAtanyx; + T a90 = atan2(helper.In.x, -helper.In.y); + T r; + T s, c; + T total = 0; + T temp1, temp2, temp3, temp4; + + if (m_Hypergon != 0) + { + temp1 = fmod(std::abs(a), M_2PI / m_HypergonN) - T(M_PI) / m_HypergonN; + temp2 = Sqr(std::tan(temp1)) + 1; + + if (temp2 >= Sqr(m_HypergonD)) + { + total += m_Hypergon; + } + else + { + temp3 = m_HypergonD; + total += m_Hypergon * (m_HypergonD - std::sqrt(Sqr(m_HypergonD) - temp2)) / std::sqrt(temp2); + } + } + + if (m_Star != 0) + { + temp1 = std::tan(std::abs(fmod(std::abs(a), M_2PI / m_StarN) - T(M_PI) / m_StarN)); + total += m_Star * std::sqrt(Sqr(m_TanStarSlope) * (1 + Sqr(temp1)) / Sqr(temp1 + m_TanStarSlope)); + } + + if (m_Lituus != 0) + { + total += m_Lituus * std::pow(std::abs(a / T(M_PI) + 1), m_InvLituusA); + } + + if (m_Super != 0) + { + temp4 = a * m_SuperM4th; + sincos(temp4, &s, &c); + total += m_Super * std::pow(std::pow(std::abs(c), m_SuperN2) + std::pow(std::abs(s), m_SuperN3), m_OneOverSuperN1); + } + + r = m_Weight * Sqr(total) / helper.m_PrecalcSqrtSumSquares; + sincos(a, &s, &c); + helper.Out.x = r * c; + helper.Out.y = r * s; + helper.Out.z = DefaultZ(helper); + } + + virtual string OpenCLString() const override + { + ostringstream ss, ss2; + intmax_t i = 0, varIndex = IndexInXform(); + ss2 << "_" << XformIndexInEmber() << "]"; + string index = ss2.str(); + string hypergon = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string hypergonN = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string hypergonR = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string star = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string starN = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string starSlope = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string lituus = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string lituusA = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string super = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string superM = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string superN1 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string superN2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string superN3 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string invLituusA = "parVars[" + ToUpper(m_Params[i++].Name()) + index;//Precalc + string tanStarSlope = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string hypergonD = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string superM4th = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string oneOverSuperN1 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + ss << "\t{\n" + << "\t\treal_t a = precalcAtanyx;\n" + << "\t\treal_t a90 = atan2(vIn.x, -vIn.y);\n" + << "\t\treal_t r;\n" + << "\t\treal_t s, c;\n" + << "\t\treal_t total = 0;\n" + << "\t\treal_t temp1, temp2, temp3, temp4;\n" + << "\n" + << "\t\tif (" << hypergon << " != 0)\n" + << "\t\t{\n" + << "\t\t temp1 = fmod(fabs(a), M_2PI / " << hypergonN << ") - M_PI / " << hypergonN << ";\n" + << "\t\t temp2 = Sqr(tan(temp1)) + 1;\n" + << "\n" + << "\t\t if (temp2 >= Sqr(" << hypergonD << "))\n" + << "\t\t {\n" + << "\t\t total += " << hypergon << ";\n" + << "\t\t }\n" + << "\t\t else\n" + << "\t\t {\n" + << "\t\t temp3 = " << hypergonD << ";\n" + << "\t\t total += " << hypergon << " * (" << hypergonD << " - sqrt(Sqr(" << hypergonD << ") - temp2)) / sqrt(temp2);\n" + << "\t\t }\n" + << "\t\t}\n" + << "\n" + << "\t\tif (" << star << " != 0)\n" + << "\t\t{\n" + << "\t\t temp1 = tan(fabs(fmod(fabs(a), M_2PI / " << starN << ") - M_PI / " << starN << "));\n" + << "\t\t total += " << star << " * sqrt(Sqr(" << tanStarSlope << ") * (1 + Sqr(temp1)) / Sqr(temp1 + " << tanStarSlope << "));\n" + << "\t\t}\n" + << "\n" + << "\t\tif (" << lituus << " != 0)\n" + << "\t\t{\n" + << "\t\t total += " << lituus << " * pow(fabs(a / M_PI + 1), " << invLituusA << ");\n" + << "\t\t}\n" + << "\n" + << "\t\tif (" << super << " != 0)\n" + << "\t\t{\n" + << "\t\t temp4 = a * " << superM4th << ";\n" + << "\t\t s = sincos(temp4, &c);\n" + << "\t\t total += " << super << " * pow(pow(fabs(c), " << superN2 << ") + pow(fabs(s), " << superN3 << "), " << oneOverSuperN1 << ");\n" + << "\t\t}\n" + << "\n" + << "\t\tr = xform->m_VariationWeights[" << varIndex << "] * Sqr(total) / precalcSqrtSumSquares;\n" + << "\t\ts = sincos(a, &c);\n" + << "\t\tvOut.x = r * c;\n" + << "\t\tvOut.y = r * s;\n" + << "\t\tvOut.z = " << DefaultZCl() + << "\t}\n"; + return ss.str(); + } + + virtual vector OpenCLGlobalFuncNames() const override + { + return vector { "Sqr" }; + } + + virtual void Precalc() override + { + m_HypergonD = std::sqrt(1 + SQR(m_HypergonR)); + m_InvLituusA = -m_LituusA; + + if (IsClose(m_StarSlope, T(M_PI_2))) + m_TanStarSlope = std::tan(m_StarSlope - T(0.05));//Original did not do this, but it makes no sense to take tan(pi/2) because it's undefined. + else + m_TanStarSlope = std::tan(m_StarSlope); + + m_SuperM4th = m_SuperM / 4; + m_OneOverSuperN1 = -1 / Zeps(m_SuperN1); + } + +protected: + void Init() + { + string prefix = Prefix(); + m_Params.clear(); + m_Params.push_back(ParamWithName(&m_Hypergon, prefix + "y_hypergon")); + m_Params.push_back(ParamWithName(&m_HypergonN, prefix + "y_hypergon_n", 4, eParamType::INTEGER, 3)); + m_Params.push_back(ParamWithName(&m_HypergonR, prefix + "y_hypergon_r", 1)); + m_Params.push_back(ParamWithName(&m_Star, prefix + "y_star")); + m_Params.push_back(ParamWithName(&m_StarN, prefix + "y_star_n", 5, eParamType::INTEGER, 3)); + m_Params.push_back(ParamWithName(&m_StarSlope, prefix + "y_star_slope", 2, eParamType::REAL, EPS, T(M_PI_2))); + m_Params.push_back(ParamWithName(&m_Lituus, prefix + "y_lituus")); + m_Params.push_back(ParamWithName(&m_LituusA, prefix + "y_lituus_a", 1)); + m_Params.push_back(ParamWithName(&m_Super, prefix + "y_super")); + m_Params.push_back(ParamWithName(&m_SuperM, prefix + "y_super_m", 1)); + m_Params.push_back(ParamWithName(&m_SuperN1, prefix + "y_super_n1", 1)); + m_Params.push_back(ParamWithName(&m_SuperN2, prefix + "y_super_n2", 1)); + m_Params.push_back(ParamWithName(&m_SuperN3, prefix + "y_super_n3", 1)); + m_Params.push_back(ParamWithName(true, &m_InvLituusA, prefix + "y_inv_lituus_a"));//Precalc + m_Params.push_back(ParamWithName(true, &m_TanStarSlope, prefix + "y_tan_star_slope")); + m_Params.push_back(ParamWithName(true, &m_HypergonD, prefix + "y_hypergon_d")); + m_Params.push_back(ParamWithName(true, &m_SuperM4th, prefix + "y_super_m_4th")); + m_Params.push_back(ParamWithName(true, &m_OneOverSuperN1, prefix + "y_one_over_super_n1")); + } + +private: + T m_Hypergon; + T m_HypergonN; + T m_HypergonR; + T m_Star; + T m_StarN; + T m_StarSlope; + T m_Lituus; + T m_LituusA; + T m_Super; + T m_SuperM; + T m_SuperN1; + T m_SuperN2; + T m_SuperN3; + T m_InvLituusA;//Precalc + T m_TanStarSlope; + T m_HypergonD; + T m_SuperM4th; + T m_OneOverSuperN1; +}; + +template +class EMBER_API ZVariation : public ParametricVariation +{ +public: + ZVariation(T weight = 1.0) : ParametricVariation("z", eVariationId::VAR_Z, weight, true, true, false, false, true) + { + Init(); + } + + PARVARCOPY(ZVariation) + + virtual void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand) override + { + T a = helper.m_PrecalcAtanyx; + T a90 = atan2(helper.In.x, -helper.In.y); + T r; + T s, c; + T total = 0; + T temp1, temp2, temp3, temp4; + + if (m_Hypergon != 0) + { + temp1 = fmod(std::abs(a), M_2PI / m_HypergonN) - T(M_PI) / m_HypergonN; + temp2 = Sqr(std::tan(temp1)) + 1; + + if (temp2 >= Sqr(m_HypergonD)) + { + total += m_Hypergon; + } + else + { + temp3 = m_HypergonD; + total += m_Hypergon * (m_HypergonD - std::sqrt(Sqr(m_HypergonD) - temp2)) / std::sqrt(temp2); + } + } + + if (m_Star != 0) + { + temp1 = std::tan(std::abs(fmod(std::abs(a), M_2PI / m_StarN) - T(M_PI) / m_StarN)); + total += m_Star * std::sqrt(Sqr(m_TanStarSlope) * (1 + Sqr(temp1)) / Sqr(temp1 + m_TanStarSlope)); + } + + if (m_Lituus != 0) + { + total += m_Lituus * std::pow(std::abs(a / T(M_PI) + 1), m_InvLituusA); + } + + if (m_Super != 0) + { + temp4 = a * m_SuperM4th; + sincos(temp4, &s, &c); + total += m_Super * std::pow(std::pow(std::abs(c), m_SuperN2) + std::pow(std::abs(s), m_SuperN3), m_OneOverSuperN1); + } + + r = m_Weight * (helper.m_PrecalcSqrtSumSquares + total); + sincos(a, &s, &c); + helper.Out.x = r * c; + helper.Out.y = r * s; + helper.Out.z = DefaultZ(helper); + } + + virtual string OpenCLString() const override + { + ostringstream ss, ss2; + intmax_t i = 0, varIndex = IndexInXform(); + ss2 << "_" << XformIndexInEmber() << "]"; + string index = ss2.str(); + string hypergon = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string hypergonN = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string hypergonR = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string star = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string starN = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string starSlope = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string lituus = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string lituusA = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string super = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string superM = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string superN1 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string superN2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string superN3 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string invLituusA = "parVars[" + ToUpper(m_Params[i++].Name()) + index;//Precalc + string tanStarSlope = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string hypergonD = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string superM4th = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string oneOverSuperN1 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + ss << "\t{\n" + << "\t\treal_t a = precalcAtanyx;\n" + << "\t\treal_t a90 = atan2(vIn.x, -vIn.y);\n" + << "\t\treal_t r;\n" + << "\t\treal_t s, c;\n" + << "\t\treal_t total = 0;\n" + << "\t\treal_t temp1, temp2, temp3, temp4;\n" + << "\n" + << "\t\tif (" << hypergon << " != 0)\n" + << "\t\t{\n" + << "\t\t temp1 = fmod(fabs(a), M_2PI / " << hypergonN << ") - M_PI / " << hypergonN << ";\n" + << "\t\t temp2 = Sqr(tan(temp1)) + 1;\n" + << "\n" + << "\t\t if (temp2 >= Sqr(" << hypergonD << "))\n" + << "\t\t {\n" + << "\t\t total += " << hypergon << ";\n" + << "\t\t }\n" + << "\t\t else\n" + << "\t\t {\n" + << "\t\t temp3 = " << hypergonD << ";\n" + << "\t\t total += " << hypergon << " * (" << hypergonD << " - sqrt(Sqr(" << hypergonD << ") - temp2)) / sqrt(temp2);\n" + << "\t\t }\n" + << "\t\t}\n" + << "\n" + << "\t\tif (" << star << " != 0)\n" + << "\t\t{\n" + << "\t\t temp1 = tan(fabs(fmod(fabs(a), M_2PI / " << starN << ") - M_PI / " << starN << "));\n" + << "\t\t total += " << star << " * sqrt(Sqr(" << tanStarSlope << ") * (1 + Sqr(temp1)) / Sqr(temp1 + " << tanStarSlope << "));\n" + << "\t\t}\n" + << "\n" + << "\t\tif (" << lituus << " != 0)\n" + << "\t\t{\n" + << "\t\t total += " << lituus << " * pow(fabs(a / M_PI + 1), " << invLituusA << ");\n" + << "\t\t}\n" + << "\n" + << "\t\tif (" << super << " != 0)\n" + << "\t\t{\n" + << "\t\t temp4 = a * " << superM4th << ";\n" + << "\t\t s = sincos(temp4, &c);\n" + << "\t\t total += " << super << " * pow(pow(fabs(c), " << superN2 << ") + pow(fabs(s), " << superN3 << "), " << oneOverSuperN1 << ");\n" + << "\t\t}\n" + << "\n" + << "\t\tr = xform->m_VariationWeights[" << varIndex << "] * (precalcSqrtSumSquares + total);\n" + << "\t\ts = sincos(a, &c);\n" + << "\t\tvOut.x = r * c;\n" + << "\t\tvOut.y = r * s;\n" + << "\t\tvOut.z = " << DefaultZCl() + << "\t}\n"; + return ss.str(); + } + + virtual vector OpenCLGlobalFuncNames() const override + { + return vector { "Sqr" }; + } + + virtual void Precalc() override + { + m_HypergonD = std::sqrt(1 + SQR(m_HypergonR)); + m_InvLituusA = -m_LituusA; + + if (IsClose(m_StarSlope, T(M_PI_2))) + m_TanStarSlope = std::tan(m_StarSlope - T(0.05));//Original did not do this, but it makes no sense to take tan(pi/2) because it's undefined. + else + m_TanStarSlope = std::tan(m_StarSlope); + + m_SuperM4th = m_SuperM / 4; + m_OneOverSuperN1 = -1 / Zeps(m_SuperN1); + } + +protected: + void Init() + { + string prefix = Prefix(); + m_Params.clear(); + m_Params.push_back(ParamWithName(&m_Hypergon, prefix + "z_hypergon")); + m_Params.push_back(ParamWithName(&m_HypergonN, prefix + "z_hypergon_n", 4, eParamType::INTEGER, 3)); + m_Params.push_back(ParamWithName(&m_HypergonR, prefix + "z_hypergon_r", 1)); + m_Params.push_back(ParamWithName(&m_Star, prefix + "z_star")); + m_Params.push_back(ParamWithName(&m_StarN, prefix + "z_star_n", 5, eParamType::INTEGER, 3)); + m_Params.push_back(ParamWithName(&m_StarSlope, prefix + "z_star_slope", 2, eParamType::REAL, EPS, T(M_PI_2))); + m_Params.push_back(ParamWithName(&m_Lituus, prefix + "z_lituus")); + m_Params.push_back(ParamWithName(&m_LituusA, prefix + "z_lituus_a", 1)); + m_Params.push_back(ParamWithName(&m_Super, prefix + "z_super")); + m_Params.push_back(ParamWithName(&m_SuperM, prefix + "z_super_m", 1)); + m_Params.push_back(ParamWithName(&m_SuperN1, prefix + "z_super_n1", 1)); + m_Params.push_back(ParamWithName(&m_SuperN2, prefix + "z_super_n2", 1)); + m_Params.push_back(ParamWithName(&m_SuperN3, prefix + "z_super_n3", 1)); + m_Params.push_back(ParamWithName(true, &m_InvLituusA, prefix + "z_inv_lituus_a"));//Precalc + m_Params.push_back(ParamWithName(true, &m_TanStarSlope, prefix + "z_tan_star_slope")); + m_Params.push_back(ParamWithName(true, &m_HypergonD, prefix + "z_hypergon_d")); + m_Params.push_back(ParamWithName(true, &m_SuperM4th, prefix + "z_super_m_4th")); + m_Params.push_back(ParamWithName(true, &m_OneOverSuperN1, prefix + "z_one_over_super_n1")); + } + +private: + T m_Hypergon; + T m_HypergonN; + T m_HypergonR; + T m_Star; + T m_StarN; + T m_StarSlope; + T m_Lituus; + T m_LituusA; + T m_Super; + T m_SuperM; + T m_SuperN1; + T m_SuperN2; + T m_SuperN3; + T m_InvLituusA;//Precalc + T m_TanStarSlope; + T m_HypergonD; + T m_SuperM4th; + T m_OneOverSuperN1; +}; + MAKEPREPOSTPARVAR(Hexes, hexes, HEXES) MAKEPREPOSTPARVAR(Nblur, nBlur, NBLUR) MAKEPREPOSTPARVAR(Octapol, octapol, OCTAPOL) @@ -4424,4 +5411,10 @@ MAKEPREPOSTPARVAR(Crob, crob, CROB) MAKEPREPOSTPARVAR(BubbleT3D, bubbleT3D, BUBBLET3D) MAKEPREPOSTPARVAR(Synth, synth, SYNTH) MAKEPREPOSTPARVAR(Crackle, crackle, CRACKLE) +MAKEPREPOSTVAR(Erf, erf, ERF) +MAKEPREPOSTVAR(Xerf, xerf, XERF) +MAKEPREPOSTPARVAR(W, w, W) +MAKEPREPOSTPARVAR(X, x, X) +MAKEPREPOSTPARVAR(Y, y, Y) +MAKEPREPOSTPARVAR(Z, z, Z) } diff --git a/Source/Ember/Variations07.h b/Source/Ember/Variations07.h new file mode 100644 index 0000000..f5bcdfa --- /dev/null +++ b/Source/Ember/Variations07.h @@ -0,0 +1,968 @@ +#pragma once + +#include "Variation.h" + +namespace EmberNs +{ +/// +/// splits3D. +/// +template +class EMBER_API Splits3DVariation : public ParametricVariation +{ +public: + Splits3DVariation(T weight = 1.0) : ParametricVariation("splits3D", eVariationId::VAR_SPLITS3D, weight) + { + Init(); + } + + PARVARCOPY(Splits3DVariation) + + virtual void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand) override + { + if (helper.In.x >= 0) + helper.Out.x = m_Weight * (helper.In.x + m_X); + else + helper.Out.x = m_Weight * (helper.In.x - m_X); + + if (helper.In.y >= 0) + helper.Out.y = m_Weight * (helper.In.y + m_Y); + else + helper.Out.y = m_Weight * (helper.In.y - m_Y); + + if (helper.In.z >= 0) + helper.Out.z = m_Weight * (helper.In.z + m_Z); + else + helper.Out.z = m_Weight * (helper.In.z - m_Z); + } + + virtual string OpenCLString() const override + { + ostringstream ss, ss2; + intmax_t 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 z = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + ss << "\t{\n" + << "\t\tif (vIn.x >= 0)\n" + << "\t\t vOut.x = xform->m_VariationWeights[" << varIndex << "] * (vIn.x + " << x << ");\n" + << "\t\telse\n" + << "\t\t vOut.x = xform->m_VariationWeights[" << varIndex << "] * (vIn.x - " << x << ");\n" + << "\n" + << "\t\tif (vIn.y >= 0)\n" + << "\t\t vOut.y = xform->m_VariationWeights[" << varIndex << "] * (vIn.y + " << y << ");\n" + << "\t\telse\n" + << "\t\t vOut.y = xform->m_VariationWeights[" << varIndex << "] * (vIn.y - " << y << ");\n" + << "\n" + << "\t\tif (vIn.z >= 0)\n" + << "\t\t vOut.z = xform->m_VariationWeights[" << varIndex << "] * (vIn.z + " << z << ");\n" + << "\t\telse\n" + << "\t\t vOut.z = xform->m_VariationWeights[" << varIndex << "] * (vIn.z - " << z << ");\n" + << "\t}\n"; + return ss.str(); + } + + virtual void Random(QTIsaac& rand) override + { + m_X = rand.Frand11(); + m_Y = rand.Frand11(); + m_Z = rand.Frand11(); + } + +protected: + void Init() + { + string prefix = Prefix(); + m_Params.clear(); + m_Params.push_back(ParamWithName(&m_X, prefix + "splits3D_x")); + m_Params.push_back(ParamWithName(&m_Y, prefix + "splits3D_y")); + m_Params.push_back(ParamWithName(&m_Z, prefix + "splits3D_z")); + } + +private: + T m_X; + T m_Y; + T m_Z; +}; + +/// +/// waves2b. +/// Note that _j1() is not implemented in OpenCL, so that conditional is skipped +/// when running on the GPU. The results might look different. +/// +template +class EMBER_API Waves2BVariation : public ParametricVariation +{ +public: + Waves2BVariation(T weight = 1.0) : ParametricVariation("waves2b", eVariationId::VAR_WAVES2B, weight) + { + Init(); + } + + PARVARCOPY(Waves2BVariation) + + virtual void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand) override + { + T CsX = 1; + T CsY = 1; + T jcbSn = 0, jcbCn, jcbDn; + CsX = SafeDivInv(m_Unity, (m_Unity + Sqr(helper.In.x))); + CsX = CsX * m_Six + m_Scaleinfx; + CsY = SafeDivInv(m_Unity, (m_Unity + Sqr(helper.In.y))); + CsY = CsY * m_Siy + m_Scaleinfy; + + if (m_Pwx >= 0 && m_Pwx < 1e-4) + { + m_VarFuncs->JacobiElliptic(helper.In.y * m_Freqx, m_Jacok, jcbSn, jcbCn, jcbDn); + helper.Out.x = m_Weight * (helper.In.x + CsX * jcbSn); + } + else if (m_Pwx < 0 && m_Pwx > -1e-4) +#ifdef _WIN32 + helper.Out.x = m_Weight * (helper.In.x + CsX * T(_j1(helper.In.y * m_Freqx)));//This is not implemented in OpenCL. + +#else + helper.Out.x = m_Weight * (helper.In.x + CsX * T(j1(helper.In.y * m_Freqx)));//This is not implemented in OpenCL. +#endif + 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)); + + if (m_Pwy >= 0 && m_Pwy < 1e-4) + { + m_VarFuncs->JacobiElliptic(helper.In.x * m_Freqy, m_Jacok, jcbSn, jcbCn, jcbDn); + helper.Out.y = m_Weight * (helper.In.y + CsY * jcbSn); + } + else if (m_Pwy < 0 && m_Pwy > -1e-4) +#ifdef _WIN32 + helper.Out.y = m_Weight * (helper.In.y + CsY * T(_j1(helper.In.x * m_Freqy))); + +#else + helper.Out.y = m_Weight * (helper.In.y + CsY * T(j1(helper.In.x * m_Freqy))); +#endif + 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.z = DefaultZ(helper); + } + + virtual string OpenCLString() const override + { + ostringstream ss, ss2; + intmax_t i = 0, varIndex = IndexInXform(); + ss2 << "_" << XformIndexInEmber() << "]"; + string index = ss2.str(); + string freqx = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string freqy = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string pwx = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string pwy = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string scalex = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string scaleinfx = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string scaley = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string scaleinfy = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string unity = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string jacok = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string six = "parVars[" + ToUpper(m_Params[i++].Name()) + index;//Precalc. + string siy = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + ss << "\t{\n" + << "\t\treal_t CsX = 1;\n" + << "\t\treal_t CsY = 1;\n" + << "\t\treal_t jcbSn = 0, jcbCn, jcbDn;\n" + << "\t\tCsX = SafeDivInv(" << unity << ", (" << unity << " + Sqr(vIn.x)));\n" + << "\t\tCsX = CsX * " << six << " + " << scaleinfx << ";\n" + << "\t\tCsY = SafeDivInv(" << unity << ", (" << unity << " + Sqr(vIn.y)));\n" + << "\t\tCsY = CsY * " << siy << " + " << scaleinfy << ";\n" + << "\n" + << "\t\tif (" << pwx << " >= 0 && " << pwx << " < 1e-4)\n" + << "\t\t{\n" + << "\t\t JacobiElliptic(vIn.y * " << freqx << ", " << jacok << ", &jcbSn, &jcbCn, &jcbDn);\n" + << "\t\t vOut.x = xform->m_VariationWeights[" << varIndex << "] * (vIn.x + CsX * jcbSn);\n" + << "\t\t}\n" + //<< "\t\telse if (" << pwx << " < 0 && " << pwx << " > -1e-4)\n" + //<< "\t\t vOut.x = xform->m_VariationWeights[" << varIndex << "] * (vIn.x + CsX * _j1(vIn.y * " << freqx << "));\n"//This is not implemented in OpenCL. + << "\t\telse\n" + << "\t\t vOut.x = xform->m_VariationWeights[" << varIndex << "] * (vIn.x + CsX * sin(SignNz(vIn.y) * pow(Zeps(fabs(vIn.y)), " << pwx << ") * " << freqx << "));\n" + << "\n" + << "\t\tif (" << pwy << " >= 0 && " << pwy << " < 1e-4)\n" + << "\t\t{\n" + << "\t\t JacobiElliptic(vIn.x * " << freqy << ", " << jacok << ", &jcbSn, &jcbCn, &jcbDn);\n" + << "\t\t vOut.y = xform->m_VariationWeights[" << varIndex << "] * (vIn.y + CsY * jcbSn);\n" + << "\t\t}\n" + //<< "\t\telse if (" << pwy << " < 0 && " << pwy << " > -1e-4)\n" + //<< "\t\t vOut.y = xform->m_VariationWeights[" << varIndex << "] * (vIn.y + CsY * _j1(vIn.x * " << freqy << "));\n"//This is not implemented in OpenCL. + << "\t\telse\n" + << "\t\t vOut.y = xform->m_VariationWeights[" << varIndex << "] * (vIn.y + CsY * sin(SignNz(vIn.x) * pow(Zeps(fabs(vIn.x)), " << pwy << ") * " << freqy << "));\n" + << "\n" + << "\t\tvOut.z = " << DefaultZCl() + << "\t}\n"; + return ss.str(); + } + + virtual vector OpenCLGlobalFuncNames() const override + { + return vector { "Zeps", "Sqr", "SignNz", "SafeDivInv", "JacobiElliptic" }; + } + + virtual void Precalc() override + { + m_Six = m_Scalex - m_Scaleinfx; + m_Siy = m_Scaley - m_Scaleinfy; + } + +protected: + void Init() + { + string prefix = Prefix(); + m_VarFuncs = VarFuncs::Instance(); + m_Params.clear(); + m_Params.push_back(ParamWithName(&m_Freqx, prefix + "waves2b_freqx", 2)); + m_Params.push_back(ParamWithName(&m_Freqy, prefix + "waves2b_freqy", 2)); + m_Params.push_back(ParamWithName(&m_Pwx, prefix + "waves2b_pwx", 1, eParamType::REAL, -10, 10)); + m_Params.push_back(ParamWithName(&m_Pwy, prefix + "waves2b_pwy", 1, eParamType::REAL, -10, 10)); + m_Params.push_back(ParamWithName(&m_Scalex, prefix + "waves2b_scalex", 1)); + m_Params.push_back(ParamWithName(&m_Scaleinfx, prefix + "waves2b_scaleinfx", 1)); + m_Params.push_back(ParamWithName(&m_Scaley, prefix + "waves2b_scaley", 1)); + m_Params.push_back(ParamWithName(&m_Scaleinfy, prefix + "waves2b_scaleinfy", 1)); + m_Params.push_back(ParamWithName(&m_Unity, prefix + "waves2b_unity", 1)); + m_Params.push_back(ParamWithName(&m_Jacok, prefix + "waves2b_jacok", T(0.25), eParamType::REAL, -1, 1)); + m_Params.push_back(ParamWithName(true, &m_Six, prefix + "waves2b_six"));//Precalc. + m_Params.push_back(ParamWithName(true, &m_Siy, prefix + "waves2b_siy")); + } + +private: + T m_Freqx; + T m_Freqy; + T m_Pwx; + T m_Pwy; + T m_Scalex; + T m_Scaleinfx; + T m_Scaley; + T m_Scaleinfy; + T m_Unity; + T m_Jacok; + T m_Six;//Precalc. + T m_Siy; + shared_ptr> m_VarFuncs; +}; + +/// +/// jac_cn. +/// +template +class EMBER_API JacCnVariation : public ParametricVariation +{ +public: + JacCnVariation(T weight = 1.0) : ParametricVariation("jac_cn", eVariationId::VAR_JAC_CN, weight) + { + Init(); + } + + PARVARCOPY(JacCnVariation) + + virtual void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand) override + { + T snx, cnx, dnx; + T sny, cny, dny; + T numX, numY, denom; + m_VarFuncs->JacobiElliptic(helper.In.x, m_K, snx, cnx, dnx); + m_VarFuncs->JacobiElliptic(helper.In.y, 1 - m_K, sny, cny, dny); + numX = cnx * cny; + numY = -dnx * snx * dny * sny; + denom = SQR(snx) * SQR(sny) * m_K + SQR(cny); + denom = m_Weight / Zeps(denom); + helper.Out.x = denom * numX; + helper.Out.y = denom * numY; + helper.Out.z = DefaultZ(helper); + } + + virtual string OpenCLString() const override + { + ostringstream ss, ss2; + intmax_t i = 0, varIndex = IndexInXform(); + ss2 << "_" << XformIndexInEmber() << "]"; + string index = ss2.str(); + string k = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + ss << "\t{\n" + << "\t\treal_t snx, cnx, dnx;\n" + << "\t\treal_t sny, cny, dny;\n" + << "\t\treal_t numX, numY, denom;\n" + << "\t\tJacobiElliptic(vIn.x, " << k << ", &snx, &cnx, &dnx);\n" + << "\t\tJacobiElliptic(vIn.y, 1 - " << k << ", &sny, &cny, &dny);\n" + << "\t\tnumX = cnx * cny;\n" + << "\t\tnumY = -dnx * snx * dny * sny;\n" + << "\t\tdenom = SQR(snx) * SQR(sny) * " << k << " + SQR(cny);\n" + << "\t\tdenom = xform->m_VariationWeights[" << varIndex << "] / Zeps(denom);\n" + << "\t\tvOut.x = denom * numX;\n" + << "\t\tvOut.y = denom * numY;\n" + << "\t\tvOut.z = " << DefaultZCl() + << "\t}\n"; + return ss.str(); + } + + virtual vector OpenCLGlobalFuncNames() const override + { + return vector { "Zeps", "JacobiElliptic" }; + } + +protected: + void Init() + { + string prefix = Prefix(); + m_VarFuncs = VarFuncs::Instance(); + m_Params.clear(); + m_Params.push_back(ParamWithName(&m_K, prefix + "jac_cn_k", T(0.5), eParamType::REAL, -1, 1)); + } + +private: + T m_K; + shared_ptr> m_VarFuncs; +}; + +/// +/// jac_dn. +/// +template +class EMBER_API JacDnVariation : public ParametricVariation +{ +public: + JacDnVariation(T weight = 1.0) : ParametricVariation("jac_dn", eVariationId::VAR_JAC_DN, weight) + { + Init(); + } + + PARVARCOPY(JacDnVariation) + + virtual void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand) override + { + T snx, cnx, dnx; + T sny, cny, dny; + T numX, numY, denom; + m_VarFuncs->JacobiElliptic(helper.In.x, m_K, snx, cnx, dnx); + m_VarFuncs->JacobiElliptic(helper.In.y, 1 - m_K, sny, cny, dny); + numX = dnx * cny * dny; + numY = -cnx * snx * sny * m_K; + denom = SQR(snx) * SQR(sny) * m_K + SQR(cny); + denom = m_Weight / Zeps(denom); + helper.Out.x = denom * numX; + helper.Out.y = denom * numY; + helper.Out.z = DefaultZ(helper); + } + + virtual string OpenCLString() const override + { + ostringstream ss, ss2; + intmax_t i = 0, varIndex = IndexInXform(); + ss2 << "_" << XformIndexInEmber() << "]"; + string index = ss2.str(); + string k = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + ss << "\t{\n" + << "\t\treal_t snx, cnx, dnx;\n" + << "\t\treal_t sny, cny, dny;\n" + << "\t\treal_t numX, numY, denom;\n" + << "\t\tJacobiElliptic(vIn.x, " << k << ", &snx, &cnx, &dnx);\n" + << "\t\tJacobiElliptic(vIn.y, 1 - " << k << ", &sny, &cny, &dny);\n" + << "\t\tnumX = dnx * cny * dny;\n" + << "\t\tnumY = -cnx * snx * sny * " << k << ";\n" + << "\t\tdenom = SQR(snx) * SQR(sny) * " << k << " + SQR(cny);\n" + << "\t\tdenom = xform->m_VariationWeights[" << varIndex << "] / Zeps(denom);\n" + << "\t\tvOut.x = denom * numX;\n" + << "\t\tvOut.y = denom * numY;\n" + << "\t\tvOut.z = " << DefaultZCl() + << "\t}\n"; + return ss.str(); + } + + virtual vector OpenCLGlobalFuncNames() const override + { + return vector { "Zeps", "JacobiElliptic" }; + } + +protected: + void Init() + { + string prefix = Prefix(); + m_VarFuncs = VarFuncs::Instance(); + m_Params.clear(); + m_Params.push_back(ParamWithName(&m_K, prefix + "jac_dn_k", T(0.5), eParamType::REAL, -1, 1)); + } + +private: + T m_K; + shared_ptr> m_VarFuncs; +}; + +/// +/// jac_sn. +/// +template +class EMBER_API JacSnVariation : public ParametricVariation +{ +public: + JacSnVariation(T weight = 1.0) : ParametricVariation("jac_sn", eVariationId::VAR_JAC_SN, weight) + { + Init(); + } + + PARVARCOPY(JacSnVariation) + + virtual void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand) override + { + T snx, cnx, dnx; + T sny, cny, dny; + T numX, numY, denom; + m_VarFuncs->JacobiElliptic(helper.In.x, m_K, snx, cnx, dnx); + m_VarFuncs->JacobiElliptic(helper.In.y, 1 - m_K, sny, cny, dny); + numX = snx * dny; + numY = cnx * dnx * cny * sny; + denom = SQR(snx) * SQR(sny) * m_K + SQR(cny); + denom = m_Weight / Zeps(denom); + helper.Out.x = denom * numX; + helper.Out.y = denom * numY; + helper.Out.z = DefaultZ(helper); + } + + virtual string OpenCLString() const override + { + ostringstream ss, ss2; + intmax_t i = 0, varIndex = IndexInXform(); + ss2 << "_" << XformIndexInEmber() << "]"; + string index = ss2.str(); + string k = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + ss << "\t{\n" + << "\t\treal_t snx, cnx, dnx;\n" + << "\t\treal_t sny, cny, dny;\n" + << "\t\treal_t numX, numY, denom;\n" + << "\t\tJacobiElliptic(vIn.x, " << k << ", &snx, &cnx, &dnx);\n" + << "\t\tJacobiElliptic(vIn.y, 1 - " << k << ", &sny, &cny, &dny);\n" + << "\t\tnumX = snx * dny;\n" + << "\t\tnumY = cnx * dnx * cny * sny;\n" + << "\t\tdenom = SQR(snx) * SQR(sny) * " << k << " + SQR(cny);\n" + << "\t\tdenom = xform->m_VariationWeights[" << varIndex << "] / Zeps(denom);\n" + << "\t\tvOut.x = denom * numX;\n" + << "\t\tvOut.y = denom * numY;\n" + << "\t\tvOut.z = " << DefaultZCl() + << "\t}\n"; + return ss.str(); + } + + virtual vector OpenCLGlobalFuncNames() const override + { + return vector { "Zeps", "JacobiElliptic" }; + } + +protected: + void Init() + { + string prefix = Prefix(); + m_VarFuncs = VarFuncs::Instance(); + m_Params.clear(); + m_Params.push_back(ParamWithName(&m_K, prefix + "jac_sn_k", T(0.5), eParamType::REAL, -1, 1)); + } + +private: + T m_K; + shared_ptr> m_VarFuncs; +}; + +/// +/// pressure_wave. +/// +template +class EMBER_API PressureWaveVariation : public ParametricVariation +{ +public: + PressureWaveVariation(T weight = 1.0) : ParametricVariation("pressure_wave", eVariationId::VAR_PRESSURE_WAVE, weight) + { + Init(); + } + + PARVARCOPY(PressureWaveVariation) + + virtual void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand) override + { + helper.Out.x = m_Weight * (helper.In.x + (1 / Zeps(m_X * M_2PI)) * std::sin(m_X * M_2PI * helper.In.x)); + helper.Out.y = m_Weight * (helper.In.y + (1 / Zeps(m_Y * M_2PI)) * std::sin(m_Y * M_2PI * helper.In.y)); + helper.Out.z = DefaultZ(helper); + } + + virtual string OpenCLString() const override + { + ostringstream ss, ss2; + intmax_t 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; + ss << "\t{\n" + << "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * (vIn.x + (1 / Zeps(" << x << " * M_2PI)) * sin(" << x << " * M_2PI * vIn.x));\n" + << "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * (vIn.y + (1 / Zeps(" << y << " * M_2PI)) * sin(" << y << " * M_2PI * vIn.y));\n" + << "\t\tvOut.z = " << DefaultZCl() + << "\t}\n"; + return ss.str(); + } + + virtual vector OpenCLGlobalFuncNames() const override + { + return vector { "Zeps" }; + } + +protected: + void Init() + { + string prefix = Prefix(); + m_Params.clear(); + m_Params.push_back(ParamWithName(&m_X, prefix + "pressure_wave_x_freq", 1)); + m_Params.push_back(ParamWithName(&m_Y, prefix + "pressure_wave_y_freq", 1)); + } + +private: + T m_X; + T m_Y; +}; + +/// +/// gamma. +/// +template +class EMBER_API GammaVariation : public Variation +{ +public: + GammaVariation(T weight = 1.0) : Variation("gamma", eVariationId::VAR_GAMMA, weight, true, true, false, false, true) + { + } + + VARCOPY(GammaVariation) + + virtual void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand) override + { + helper.Out.x = m_Weight * std::lgamma(helper.m_PrecalcSqrtSumSquares); + helper.Out.y = m_Weight * helper.m_PrecalcAtanyx; + helper.Out.z = DefaultZ(helper); + } + + virtual string OpenCLString() const override + { + ostringstream ss, ss2; + intmax_t i = 0, varIndex = IndexInXform(); + ss2 << "_" << XformIndexInEmber() << "]"; + string index = ss2.str(); + ss << "\t{\n" + << "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * lgamma(precalcSqrtSumSquares);\n" + << "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * precalcAtanyx;\n" + << "\t\tvOut.z = " << DefaultZCl() + << "\t}\n"; + return ss.str(); + } +}; + +/// +/// prose3D. +/// +template +class EMBER_API PRose3DVariation : public ParametricVariation +{ +public: + PRose3DVariation(T weight = 1.0) : ParametricVariation("pRose3D", eVariationId::VAR_PROSE3D, weight, true, true, false, false, true) + { + Init(); + } + + PARVARCOPY(PRose3DVariation) + + virtual void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand) override + { + int posNeg = 1; + T th = 0; + T sth, cth, pang, wig, wag, wag2, wag3, wag12, waggle; + T rad = helper.m_PrecalcSqrtSumSquares; + T curve1 = rad / m_L; + T curve2 = Sqr(curve1); + T curve3 = (rad - m_L * T(0.5)) / m_L; + T curve4 = Sqr(curve2); + th = helper.m_PrecalcAtanyx; + sincos(th, &sth, &cth); + + if (rand.Frand01() < T(0.5)) + posNeg = -1; + + pang = th / Zeps(m_Cycle); + wig = pang * m_Freq * T(0.5) + m_Offset * m_Cycle; + + if (m_OptDir < 0) + { + wag = std::sin(curve1 * T(M_PI) * m_AbsOptSc) + m_Wagsc * T(0.4) * rad + m_Crvsc * T(0.5) * (std::sin(curve2 * T(M_PI))); + wag3 = std::sin(curve4 * T(M_PI) * m_AbsOptSc) + m_Wagsc * SQR(rad) * T(0.4) + m_Crvsc * T(0.5) * (std::cos(curve3 * T(M_PI))); + } + else + { + wag = std::sin(curve1 * T(M_PI) * m_AbsOptSc) + m_Wagsc * T(0.4) * rad + m_Crvsc * T(0.5) * (std::cos(curve3 * T(M_PI))); + wag3 = std::sin(curve4 * T(M_PI) * m_AbsOptSc) + m_Wagsc * SQR(rad) * T(0.4) + m_Crvsc * T(0.5) * (std::sin(curve2 * T(M_PI))); + } + + wag2 = std::sin(curve2 * T(M_PI) * m_AbsOptSc) + m_Wagsc * T(0.4) * rad + m_Crvsc * T(0.5) * (std::cos(curve3 * T(M_PI))); + + if (m_Smooth12 <= 1) + wag12 = wag; + else if (m_Smooth12 <= 2 && m_Smooth12 > 1) + wag12 = wag2 * (1 - m_AntiOpt1) + wag * m_AntiOpt1; + else if (m_Smooth12 > 2) + wag12 = wag2; + + if (m_Smooth3 == 0) + waggle = wag12; + else if (m_Smooth3 > 0) + waggle = wag12 * (1 - m_Smooth3) + wag3 * m_Smooth3; + + if (rand.Frand01() < m_Ghost) + { + if (posNeg < 0) + { + helper.Out.x = m_Weight * T(0.5) * m_RefSc * (m_L * std::cos(m_NumPetals * th + m_C)) * cth; + helper.Out.y = m_Weight * T(0.5) * m_RefSc * (m_L * std::cos(m_NumPetals * th + m_C)) * sth; + helper.Out.z = m_Weight * T(-0.5) * ((m_Z2 * waggle + Sqr(rad * T(0.5)) * std::sin(wig) * m_WigScale) + m_Dist); + } + else + { + helper.Out.x = m_Weight * T(0.5) * (m_L * std::cos(m_NumPetals * th + m_C)) * cth; + helper.Out.y = m_Weight * T(0.5) * (m_L * std::cos(m_NumPetals * th + m_C)) * sth; + helper.Out.z = m_Weight * T(0.5) * ((m_Z1 * waggle + Sqr(rad * T(0.5)) * std::sin(wig) * m_WigScale) + m_Dist); + } + } + else + { + if (posNeg < 0) + { + helper.Out.x = m_Weight * T(0.5) * (m_L * std::cos(m_NumPetals * th + m_C)) * cth; + helper.Out.y = m_Weight * T(0.5) * (m_L * std::cos(m_NumPetals * th + m_C)) * sth; + helper.Out.z = m_Weight * T(0.5) * ((m_Z1 * waggle + Sqr(rad * T(0.5)) * std::sin(wig) * m_WigScale) + m_Dist); + } + else + { + helper.Out.x = m_Weight * T(0.5) * (m_L * std::cos(m_NumPetals * th + m_C)) * cth; + helper.Out.y = m_Weight * T(0.5) * (m_L * std::cos(m_NumPetals * th + m_C)) * sth; + helper.Out.z = m_Weight * T(0.5) * ((m_Z1 * waggle + Sqr(rad * T(0.5)) * std::sin(wig) * m_WigScale) + m_Dist); + } + } + } + + virtual string OpenCLString() const override + { + ostringstream ss, ss2; + intmax_t i = 0, varIndex = IndexInXform(); + ss2 << "_" << XformIndexInEmber() << "]"; + string index = ss2.str(); + string l = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string k = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string c = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string z1 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string z2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string refSc = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string opt = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string optSc = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string opt3 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string transp = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string dist = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string wagsc = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string crvsc = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string f = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string wigsc = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string offset = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string cycle = "parVars[" + ToUpper(m_Params[i++].Name()) + index;//Precalc. + string optDir = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string petalsSign = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string numPetals = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string absOptSc = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string smooth12 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string smooth3 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string antiOpt1 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string ghost = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string freq = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string wigScale = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + ss << "\t{\n" + << "\t\tint posNeg = 1;\n" + << "\t\treal_t th = 0;\n" + << "\t\treal_t sth, cth, pang, wig, wag, wag2, wag3, wag12, waggle;\n" + << "\t\treal_t rad = precalcSqrtSumSquares;\n" + << "\t\treal_t curve1 = rad / " << l << ";\n" + << "\t\treal_t curveTwo = Sqr(curve1);\n" + << "\t\treal_t curve3 = (rad - " << l << " * 0.5) / " << l << ";\n" + << "\t\treal_t curve4 = Sqr(curveTwo);\n" + << "\t\tth = precalcAtanyx;\n" + << "\t\tsth = sincos(th, &cth);\n" + << "\n" + << "\t\tif (MwcNext01(mwc) < 0.5)\n" + << "\t\t posNeg = -1;\n" + << "\n" + << "\t\tpang = th / Zeps(" << cycle << ");\n" + << "\t\twig = pang * " << freq << " * 0.5 + " << offset << " * " << cycle << ";\n" + << "\n" + << "\t\tif (" << optDir << " < 0)\n" + << "\t\t{\n" + << "\t\t wag = sin(curve1 * M_PI * " << absOptSc << ") + " << wagsc << " * 0.4 * rad + " << crvsc << " * 0.5 * (sin(curveTwo * M_PI));\n" + << "\t\t wag3 = sin(curve4 * M_PI * " << absOptSc << ") + " << wagsc << " * SQR(rad) * 0.4 + " << crvsc << " * 0.5 * (cos(curve3 * M_PI));\n" + << "\t\t}\n" + << "\t\telse\n" + << "\t\t{\n" + << "\t\t wag = sin(curve1 * M_PI * " << absOptSc << ") + " << wagsc << " * 0.4 * rad + " << crvsc << " * 0.5 * (cos(curve3 * M_PI));\n" + << "\t\t wag3 = sin(curve4 * M_PI * " << absOptSc << ") + " << wagsc << " * SQR(rad) * 0.4 + " << crvsc << " * 0.5 * (sin(curveTwo * M_PI));\n" + << "\t\t}\n" + << "\n" + << "\t\twag2 = sin(curveTwo * M_PI * " << absOptSc << ") + " << wagsc << " * 0.4 * rad + " << crvsc << " * 0.5 * (cos(curve3 * M_PI));\n" + << "\n" + << "\t\tif (" << smooth12 << " <= 1)\n" + << "\t\t wag12 = wag;\n" + << "\t\telse if (" << smooth12 << " <= 2 && " << smooth12 << " > 1)\n" + << "\t\t wag12 = wag2 * (1 - " << antiOpt1 << ") + wag * " << antiOpt1 << ";\n" + << "\t\telse if (" << smooth12 << " > 2)\n" + << "\t\t wag12 = wag2;\n" + << "\n" + << "\t\tif (" << smooth3 << " == 0)\n" + << "\t\t waggle = wag12;\n" + << "\t\telse if (" << smooth3 << " > 0)\n" + << "\t\t waggle = wag12 * (1 - " << smooth3 << ") + wag3 * " << smooth3 << ";\n" + << "\n" + << "\t\tif (MwcNext01(mwc) < " << ghost << ")\n" + << "\t\t{\n" + << "\t\t if (posNeg < 0)\n" + << "\t\t {\n" + << "\t\t vOut.x = xform->m_VariationWeights[" << varIndex << "] * 0.5 * " << refSc << " * (" << l << " * cos(" << numPetals << " * th + " << c << ")) * cth;\n" + << "\t\t vOut.y = xform->m_VariationWeights[" << varIndex << "] * 0.5 * " << refSc << " * (" << l << " * cos(" << numPetals << " * th + " << c << ")) * sth;\n" + << "\t\t vOut.z = xform->m_VariationWeights[" << varIndex << "] * -0.5 * ((" << z2 << " * waggle + Sqr(rad * 0.5) * sin(wig) * " << wigScale << ") + " << dist << ");\n" + << "\t\t }\n" + << "\t\t else\n" + << "\t\t {\n" + << "\t\t vOut.x = xform->m_VariationWeights[" << varIndex << "] * 0.5 * (" << l << " * cos(" << numPetals << " * th + " << c << ")) * cth;\n" + << "\t\t vOut.y = xform->m_VariationWeights[" << varIndex << "] * 0.5 * (" << l << " * cos(" << numPetals << " * th + " << c << ")) * sth;\n" + << "\t\t vOut.z = xform->m_VariationWeights[" << varIndex << "] * 0.5 * ((" << z1 << " * waggle + Sqr(rad * 0.5) * sin(wig) * " << wigScale << ") + " << dist << ");\n" + << "\t\t }\n" + << "\t\t}\n" + << "\t\telse\n" + << "\t\t{\n" + << "\t\t if (posNeg < 0)\n" + << "\t\t {\n" + << "\t\t vOut.x = xform->m_VariationWeights[" << varIndex << "] * 0.5 * (" << l << " * cos(" << numPetals << " * th + " << c << ")) * cth;\n" + << "\t\t vOut.y = xform->m_VariationWeights[" << varIndex << "] * 0.5 * (" << l << " * cos(" << numPetals << " * th + " << c << ")) * sth;\n" + << "\t\t vOut.z = xform->m_VariationWeights[" << varIndex << "] * 0.5 * ((" << z1 << " * waggle + Sqr(rad * 0.5) * sin(wig) * " << wigScale << ") + " << dist << ");\n" + << "\t\t }\n" + << "\t\t else\n" + << "\t\t {\n" + << "\t\t vOut.x = xform->m_VariationWeights[" << varIndex << "] * 0.5 * (" << l << " * cos(" << numPetals << " * th + " << c << ")) * cth;\n" + << "\t\t vOut.y = xform->m_VariationWeights[" << varIndex << "] * 0.5 * (" << l << " * cos(" << numPetals << " * th + " << c << ")) * sth;\n" + << "\t\t vOut.z = xform->m_VariationWeights[" << varIndex << "] * 0.5 * ((" << z1 << " * waggle + Sqr(rad * 0.5) * sin(wig) * " << wigScale << ") + " << dist << ");\n" + << "\t\t }\n" + << "\t\t}\n" + << "\t}\n"; + return ss.str(); + } + + virtual vector OpenCLGlobalFuncNames() const override + { + return vector { "Sqr", "Zeps" }; + } + + virtual void Precalc() override + { + m_Cycle = M_2PI / Zeps(m_K); + m_NumPetals = m_K; + m_Ghost = Sqr(m_Transp); + m_Freq = m_F * M_2PI; + m_WigScale = m_Wigsc * T(0.5); + + if (std::abs(m_NumPetals) < T(0.0001)) + m_NumPetals = T(0.0001) * m_PetalsSign; + + m_Smooth12 = std::abs(m_Opt); + m_Smooth3 = std::abs(m_Opt3); + m_AbsOptSc = std::abs(m_OptSc); + + if (m_Smooth12 > 2) + m_Smooth12 = 2; + + m_AntiOpt1 = 2 - m_Smooth12; + + if (m_Smooth3 > 1) + m_Smooth3 = 1; + + m_OptDir = std::copysign(T(1.0), m_Opt); + m_PetalsSign = std::copysign(T(1.0), m_K); + + if (m_Opt3 < 0) + m_OptDir = -1; + + if (m_OptDir > 0) + m_Ghost = 0; + } + +protected: + void Init() + { + string prefix = Prefix(); + m_Params.clear(); + m_Params.push_back(ParamWithName(&m_L, prefix + "pRose3D_l", 1, eParamType::REAL_NONZERO)); + m_Params.push_back(ParamWithName(&m_K, prefix + "pRose3D_k", 3)); + m_Params.push_back(ParamWithName(&m_C, prefix + "pRose3D_c")); + m_Params.push_back(ParamWithName(&m_Z1, prefix + "pRose3D_z1", 1)); + m_Params.push_back(ParamWithName(&m_Z2, prefix + "pRose3D_z2", 1)); + m_Params.push_back(ParamWithName(&m_RefSc, prefix + "pRose3D_refSc", 1)); + m_Params.push_back(ParamWithName(&m_Opt, prefix + "pRose3D_opt", 1)); + m_Params.push_back(ParamWithName(&m_OptSc, prefix + "pRose3D_optSc", 1)); + m_Params.push_back(ParamWithName(&m_Opt3, prefix + "pRose3D_opt3")); + m_Params.push_back(ParamWithName(&m_Transp, prefix + "pRose3D_transp", T(0.5))); + m_Params.push_back(ParamWithName(&m_Dist, prefix + "pRose3D_dist", 1)); + m_Params.push_back(ParamWithName(&m_Wagsc, prefix + "pRose3D_wagsc", 0)); + m_Params.push_back(ParamWithName(&m_Crvsc, prefix + "pRose3D_crvsc", 0)); + m_Params.push_back(ParamWithName(&m_F, prefix + "pRose3D_f", 3)); + m_Params.push_back(ParamWithName(&m_Wigsc, prefix + "pRose3D_wigsc")); + m_Params.push_back(ParamWithName(&m_Offset, prefix + "pRose3D_offset")); + m_Params.push_back(ParamWithName(true, &m_Cycle, prefix + "pRose3D_cycle")); + m_Params.push_back(ParamWithName(true, &m_OptDir, prefix + "pRose3D_opt_dir")); + m_Params.push_back(ParamWithName(true, &m_PetalsSign, prefix + "pRose3D_petals_sign")); + m_Params.push_back(ParamWithName(true, &m_NumPetals, prefix + "pRose3D_num_petals")); + m_Params.push_back(ParamWithName(true, &m_AbsOptSc, prefix + "pRose3D_abs_optSc")); + m_Params.push_back(ParamWithName(true, &m_Smooth12, prefix + "pRose3D_smooth12")); + m_Params.push_back(ParamWithName(true, &m_Smooth3, prefix + "pRose3D_smooth3")); + m_Params.push_back(ParamWithName(true, &m_AntiOpt1, prefix + "pRose3D_anti_opt1")); + m_Params.push_back(ParamWithName(true, &m_Ghost, prefix + "pRose3D_ghost")); + m_Params.push_back(ParamWithName(true, &m_Freq, prefix + "pRose3D_freq")); + m_Params.push_back(ParamWithName(true, &m_WigScale, prefix + "pRose3D_wig_scale")); + } + +private: + T m_L; + T m_K; + T m_C; + T m_Z1; + T m_Z2; + T m_RefSc; + T m_Opt; + T m_OptSc; + T m_Opt3; + T m_Transp; + T m_Dist; + T m_Wagsc; + T m_Crvsc; + T m_F; + T m_Wigsc; + T m_Offset; + T m_Cycle;//Precalc. + T m_OptDir; + T m_PetalsSign; + T m_NumPetals; + T m_AbsOptSc; + T m_Smooth12; + T m_Smooth3; + T m_AntiOpt1; + T m_Ghost; + T m_Freq; + T m_WigScale; +}; + +/// +/// log_db. +/// By DarkBeam, taken from JWildfire. +/// http://jwildfire.org/forum/viewtopic.php?f=23&t=1450&p=2692#p2692 +/// +template +class EMBER_API LogDBVariation : public ParametricVariation +{ +public: + LogDBVariation(T weight = 1.0) : ParametricVariation("log_db", eVariationId::VAR_LOG_DB, weight, true, false, false, false, true) + { + Init(); + } + + PARVARCOPY(LogDBVariation) + + virtual void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand) override + { + int i, adp; + T atanPeriod = 0; + + for (i = 0; i < 7; i++) + { + adp = rand.Rand(10) - 5; + + if (std::abs(adp) >= 3) + adp = 0; + + atanPeriod += adp; + } + + atanPeriod *= m_FixPe; + helper.Out.x = m_Denom * std::log(helper.m_PrecalcSumSquares); + helper.Out.y = m_Weight * (helper.m_PrecalcAtanyx + atanPeriod); + helper.Out.z = m_Weight * helper.In.z; + } + + virtual string OpenCLString() const override + { + ostringstream ss, ss2; + intmax_t i = 0, varIndex = IndexInXform(); + ss2 << "_" << XformIndexInEmber() << "]"; + string index = ss2.str(); + string base = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string fixPeriod = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string denom = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string fixPe = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + ss << "\t{\n" + << "\t\tint i, adp;\n" + << "\t\treal_t atanPeriod = 0;\n" + << "\n" + << "\t\tfor (i = 0; i < 7; i++)\n" + << "\t\t{\n" + << "\t\t adp = MwcNextRange(mwc, 10) - 5;\n" + << "\n" + << "\t\t if (abs(adp) >= 3)\n" + << "\t\t adp = 0;\n" + << "\n" + << "\t\t atanPeriod += adp;\n" + << "\t\t}\n" + << "\n" + << "\t\tatanPeriod *= " << fixPe << ";\n" + << "\t\tvOut.x = " << denom << " * log(precalcSumSquares);\n" + << "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * (precalcAtanyx + atanPeriod);\n" + << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t}\n"; + return ss.str(); + } + + virtual void Precalc() override + { + m_Denom = T(0.5); + + if (m_Base > EPS) + m_Denom = m_Denom / std::log(T(M_E) * m_Base); + + m_Denom *= m_Weight; + m_FixPe = T(M_PI); + + if (m_FixPeriod > EPS) + m_FixPe *= m_FixPeriod; + } +protected: + void Init() + { + string prefix = Prefix(); + m_Params.clear(); + m_Params.push_back(ParamWithName(&m_Base, prefix + "log_db_base", 1)); + m_Params.push_back(ParamWithName(&m_FixPeriod, prefix + "log_db_fix_period", 1)); + m_Params.push_back(ParamWithName(true, &m_Denom, prefix + "log_db_denom")); + m_Params.push_back(ParamWithName(true, &m_FixPe, prefix + "log_db_fix_pe")); + } +private: + T m_Base; + T m_FixPeriod; + T m_Denom; + T m_FixPe; +}; + +MAKEPREPOSTPARVAR(Splits3D, splits3D, SPLITS3D) +MAKEPREPOSTPARVAR(Waves2B, waves2b, WAVES2B) +MAKEPREPOSTPARVAR(JacCn, jac_cn, JAC_CN) +MAKEPREPOSTPARVAR(JacDn, jac_dn, JAC_DN) +MAKEPREPOSTPARVAR(JacSn, jac_sn, JAC_SN) +MAKEPREPOSTPARVAR(PressureWave, pressure_wave, PRESSURE_WAVE) +MAKEPREPOSTVAR(Gamma, gamma, GAMMA) +MAKEPREPOSTPARVAR(PRose3D, pRose3D, PROSE3D) +MAKEPREPOSTPARVAR(LogDB, log_db, LOG_DB) +} diff --git a/Source/Ember/VariationsDC.h b/Source/Ember/VariationsDC.h index 4375b4f..728635e 100644 --- a/Source/Ember/VariationsDC.h +++ b/Source/Ember/VariationsDC.h @@ -140,7 +140,7 @@ public: T h = -m_H + (1 - x0_xor_y0) * m_H; 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 == eVariationType::VARTYPE_REG) ? 0 : helper.In.z; + helper.Out.z = DefaultZ(helper); outPoint.m_ColorX = fmod(std::abs(outPoint.m_ColorX * T(0.5) * (1 + h) + x0_xor_y0 * (1 - h) * T(0.5)), T(1.0)); } @@ -162,7 +162,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 == eVariationType::VARTYPE_REG) ? "0" : "vIn.z") << ";\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t\toutPoint->m_ColorX = fmod(fabs(outPoint->m_ColorX * (real_t)(0.5) * (1 + h) + x0_xor_y0 * (1 - h) * (real_t)(0.5)), (real_t)(1.0));\n" << "\t}\n"; return ss.str(); @@ -588,7 +588,7 @@ public: } } - helper.Out.z = m_Weight * helper.In.z; + helper.Out.z = DefaultZ(helper); outPoint.m_ColorX = fmod(c, T(1.0)); } @@ -668,7 +668,7 @@ public: << "\t\t }\n" << "\t\t}\n" << "\n" - << "\t\tvOut.z = xform->m_VariationWeights[" << varIndex << "] * vIn.z;\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t\toutPoint->m_ColorX = fmod(c, (real_t)(1.0));\n" << "\t}\n"; return ss.str(); @@ -1242,7 +1242,7 @@ public: // Add blur effect to transform helper.Out.x = m_Weight * vx; helper.Out.y = m_Weight * vy; - helper.Out.z = (m_VarType == eVariationType::VARTYPE_REG) ? 0 : helper.In.z; + helper.Out.z = DefaultZ(helper); col = m_Centre + m_Range * p; outPoint.m_ColorX = col - Floor(col); } @@ -1393,7 +1393,7 @@ public: << "\n" << "\t\tvOut.x = xform->m_VariationWeights[" << varIndex << "] * vx; \n" << "\t\tvOut.y = xform->m_VariationWeights[" << varIndex << "] * vy; \n" - << "\t\tvOut.z = " << ((m_VarType == eVariationType::VARTYPE_REG) ? "0" : "vIn.z") << ";\n" + << "\t\tvOut.z = " << DefaultZCl() << "\t\tcol = " << centre << " + " << range << " * p; \n" << "\t\toutPoint->m_ColorX = col - floor(col); \n" << "\t}\n"; diff --git a/Source/Ember/Xform.h b/Source/Ember/Xform.h index 15dde14..21ee809 100644 --- a/Source/Ember/Xform.h +++ b/Source/Ember/Xform.h @@ -616,7 +616,7 @@ public: iterHelper.In.x = iterHelper.m_TransX;//Read must be done before every pre variation because transX/Y are changing. iterHelper.In.y = iterHelper.m_TransY; iterHelper.In.z = iterHelper.m_TransZ; - m_PreVariations[i]->PrecalcHelper(iterHelper, inPoint);//Apply per-variation precalc, the second parameter is unused for pre variations. + m_PreVariations[i]->PrePostPrecalcHelper(iterHelper);//Apply per-variation precalc, the second parameter is unused for pre variations. m_PreVariations[i]->Func(iterHelper, *outPoint, rand); WritePre(iterHelper, m_PreVariations[i]->AssignType()); } @@ -668,7 +668,7 @@ public: iterHelper.In.x = outPoint->m_X;//Read must be done before every post variation because the out point is changing. iterHelper.In.y = outPoint->m_Y; iterHelper.In.z = outPoint->m_Z; - m_PostVariations[i]->PrecalcHelper(iterHelper, outPoint);//Apply per-variation precalc. + m_PostVariations[i]->PrePostPrecalcHelper(iterHelper);//Apply per-variation precalc. m_PostVariations[i]->Func(iterHelper, *outPoint, rand); WritePost(iterHelper, *outPoint, m_PostVariations[i]->AssignType()); } diff --git a/Source/Ember/XmlToEmber.h b/Source/Ember/XmlToEmber.h index 5c08d84..e2e91d1 100644 --- a/Source/Ember/XmlToEmber.h +++ b/Source/Ember/XmlToEmber.h @@ -268,6 +268,7 @@ public: badParams.push_back("post_scrop_cropmode"); badParams.push_back("post_scrop_static"); m_BadVariationNames.push_back(make_pair(make_pair(string("post_scrop"), string("post_smartcrop")), badParams)); + //Note that splits3D can't be done here because it's param names are also used by splits. badParams.clear(); m_BadVariationNames.push_back(make_pair(make_pair(string("pre_blur"), string("pre_gaussian_blur")), badParams));//No other special params for these. m_BadVariationNames.push_back(make_pair(make_pair(string("pre_spin_z"), string("pre_rotate_z")), badParams)); diff --git a/Source/EmberAnimate/EmberAnimate.cpp b/Source/EmberAnimate/EmberAnimate.cpp index 423a1c6..d244f1a 100644 --- a/Source/EmberAnimate/EmberAnimate.cpp +++ b/Source/EmberAnimate/EmberAnimate.cpp @@ -27,7 +27,8 @@ bool EmberAnimate(EmberOptions& opt) //Regular variables. Timing t; bool unsorted = false; - uint channels, padding; + uint channels; + streamsize padding; size_t i, firstUnsortedIndex = 0; string inputPath = GetPath(opt.Input()); vector> embers; @@ -124,9 +125,13 @@ bool EmberAnimate(EmberOptions& opt) if (!InitPaletteList(opt.PalettePath())) return false; + cout << "Parsing ember file " << opt.Input() << endl; + if (!ParseEmberFile(parser, opt.Input(), embers)) return false; + cout << "Finished parsing.\n"; + if (embers.size() <= 1) { cout << "Read " << embers.size() << " embers from file. At least 2 required to animate, exiting." << endl; @@ -227,6 +232,15 @@ bool EmberAnimate(EmberOptions& opt) if (opt.Supersample() > 0) embers[i].m_Supersample = opt.Supersample(); + if (opt.Quality() > 0) + embers[i].m_Quality = T(opt.Quality()); + + if (opt.DeMin() > -1) + embers[i].m_MinRadDE = T(opt.DeMin()); + + if (opt.DeMax() > -1) + embers[i].m_MaxRadDE = T(opt.DeMax()); + if (opt.SubBatchSize() != DEFAULT_SBS) embers[i].m_SubBatchSize = opt.SubBatchSize(); diff --git a/Source/EmberCL/EmberCLStructs.h b/Source/EmberCL/EmberCLStructs.h index 7d31659..127d4eb 100644 --- a/Source/EmberCL/EmberCLStructs.h +++ b/Source/EmberCL/EmberCLStructs.h @@ -73,7 +73,6 @@ static string ConstantDefinesString(bool doublePrecision) "#define COLORMAP_LENGTH_MINUS_1 255u\n" "#define DE_THRESH 100u\n" "#define BadVal(x) (((x) != (x)) || ((x) > 1e10) || ((x) < -1e10))\n" - "#define Rint(A) floor((A) + (((A) < 0) ? -0.5 : 0.5))\n" "#define SQR(x) ((x) * (x))\n" "#define CUBE(x) ((x) * (x) * (x))\n" "#define M_2PI (M_PI * 2)\n" diff --git a/Source/EmberCL/FunctionMapper.cpp b/Source/EmberCL/FunctionMapper.cpp index 77068a3..5c5fc17 100644 --- a/Source/EmberCL/FunctionMapper.cpp +++ b/Source/EmberCL/FunctionMapper.cpp @@ -43,6 +43,14 @@ FunctionMapper::FunctionMapper() "\n" " return sqrt(x);\n" "}\n"; + m_GlobalMap["SafeDivInv"] = + "inline real_t SafeDivInv(real_t q, real_t r)\n" + "{\n" + " if (r < EPS)\n" + " return 1 / r;\n" + "\n" + " return q / r;\n" + "}\n"; m_GlobalMap["Cube"] = "inline real_t Cube(real_t v)\n" "{\n" @@ -125,7 +133,7 @@ FunctionMapper::FunctionMapper() " if (pmq.x == 0 && pmq.y == 0)\n" " return 1.0;\n" "\n" - " return 2 * (((*u).x - (*q).x) * pmq.x + ((*u).y - (*q).y) * pmq.y) / (SQR(pmq.x) + SQR(pmq.y));\n" + " return 2 * (((*u).x - (*q).x) * pmq.x + ((*u).y - (*q).y) * pmq.y) / Zeps(SQR(pmq.x) + SQR(pmq.y));\n" "}\n"; m_GlobalMap["Closest"] = "inline int Closest(real2* p, int n, real2* u)\n" @@ -273,6 +281,93 @@ FunctionMapper::FunctionMapper() "\n" " return n;\n" "}\n"; + m_GlobalMap["JacobiElliptic"] = + "inline void JacobiElliptic(real_t uu, real_t emmc, real_t* sn, real_t* cn, real_t* dn)\n" + "{\n" + " real_t CA = 0.0003;\n" + " real_t a, b, c, d, em[13], en[13];\n" + " int bo;\n" + " int l;\n" + " int ii;\n" + " int i;\n" + " real_t emc = emmc;\n" + " real_t u = uu;\n" + "\n" + " if (emc != 0)\n" + " {\n" + " bo = 0;\n" + "\n" + " if (emc < 0)\n" + " bo = 1;\n" + "\n" + " if (bo != 0)\n" + " {\n" + " d = 1 - emc;\n" + " emc = -emc / d;\n" + " d = sqrt(d);\n" + " u = d * u;\n" + " }\n" + "\n" + " a = 1;\n" + " *dn = 1;\n" + "\n" + " for (i = 0; i < 8; i++)\n" + " {\n" + " l = i;\n" + " em[i] = a;\n" + " emc = sqrt(emc);\n" + " en[i] = emc;\n" + " c = 0.5 * (a + emc);\n" + "\n" + " if (fabs(a - emc) <= CA * a)\n" + " break;\n" + "\n" + " emc = a * emc;\n" + " a = c;\n" + " }\n" + "\n" + " u = c * u;\n" + " *sn = sincos(u, cn);\n" + "\n" + " if (*sn != 0)\n" + " {\n" + " a = *cn / *sn;\n" + " c = a * c;\n" + "\n" + " for (ii = l; ii >= 0; --ii)\n" + " {\n" + " b = em[ii];\n" + " a = c * a;\n" + " c = *dn * c;\n" + " *dn = (en[ii] + a) / (b + a);\n" + " a = c / b;\n" + " }\n" + "\n" + " a = 1 / sqrt(c * c + 1);\n" + "\n" + " if (*sn < 0)\n" + " *sn = -a;\n" + " else\n" + " *sn = a;\n" + "\n" + " *cn = c * *sn;\n" + " }\n" + "\n" + " if (bo != 0)\n" + " {\n" + " a = *dn;\n" + " *dn = *cn;\n" + " *cn = a;\n" + " *sn = *sn / d;\n" + " }\n" + " }\n" + " else\n" + " {\n" + " *cn = 1 / cosh(u);\n" + " *dn = *cn;\n" + " *sn = tanh(u);\n" + " }\n" + "}\n"; } } diff --git a/Source/EmberCL/IterOpenCLKernelCreator.cpp b/Source/EmberCL/IterOpenCLKernelCreator.cpp index b26a9cd..a047ca2 100644 --- a/Source/EmberCL/IterOpenCLKernelCreator.cpp +++ b/Source/EmberCL/IterOpenCLKernelCreator.cpp @@ -122,8 +122,8 @@ string IterOpenCLKernelCreator::CreateIterKernelString(const Ember& ember, if (Variation* var = xform->GetVariation(varIndex)) { xformFuncs << "\n\t//" << var->Name() << ".\n"; - xformFuncs << var->PrecalcOpenCLString(); xformFuncs << xform->ReadOpenCLString(eVariationType::VARTYPE_PRE) << "\n"; + xformFuncs << var->PrePostPrecalcOpenCLString(); xformFuncs << var->OpenCLString() << "\n"; xformFuncs << xform->WriteOpenCLString(eVariationType::VARTYPE_PRE, var->AssignType()) << "\n"; } @@ -188,8 +188,8 @@ string IterOpenCLKernelCreator::CreateIterKernelString(const Ember& ember, if (Variation* var = xform->GetVariation(varIndex)) { xformFuncs << "\n\t//" << var->Name() << ".\n"; - xformFuncs << var->PrecalcOpenCLString(); xformFuncs << xform->ReadOpenCLString(eVariationType::VARTYPE_POST) << "\n"; + xformFuncs << var->PrePostPrecalcOpenCLString(); xformFuncs << var->OpenCLString() << "\n"; xformFuncs << xform->WriteOpenCLString(eVariationType::VARTYPE_POST, var->AssignType()) << (varIndex == varCount - 1 ? "\n" : "\n\n"); } diff --git a/Source/EmberCommon/EmberCommon.h b/Source/EmberCommon/EmberCommon.h index 023888f..27c9c1b 100644 --- a/Source/EmberCommon/EmberCommon.h +++ b/Source/EmberCommon/EmberCommon.h @@ -112,8 +112,22 @@ template static bool InitPaletteList(const string& filename) { PaletteList paletteList;//Even though this is local, the members are static so they will remain. + static vector paths = + { + "./" +#ifndef WIN32 + "~/.fractorium" + "~/.config/fractorium" + "/usr/share/fractorium" + "/usr/local/share/fractorium" +#endif + }; bool added = paletteList.Add(filename); + for (auto& p : paths) + if (!added) + added |= paletteList.Add(p + "/" + filename); + if (!added || !paletteList.Size()) { cout << "Error parsing palette file " << filename << ". Reason: " << endl; diff --git a/Source/EmberCommon/EmberOptions.h b/Source/EmberCommon/EmberOptions.h index 6aac54d..ff650a1 100644 --- a/Source/EmberCommon/EmberOptions.h +++ b/Source/EmberCommon/EmberOptions.h @@ -81,6 +81,9 @@ enum class eOptionIDs : et OPT_SS,//Float value args. OPT_QS, + OPT_QUALITY, + OPT_DE_MIN, + OPT_DE_MAX, OPT_PIXEL_ASPECT, OPT_STAGGER, OPT_AVG_THRESH, @@ -322,13 +325,13 @@ public: INITBOOLOPTION(LockAccum, Eob(eOptionUse::OPT_USE_ALL, eOptionIDs::OPT_LOCK_ACCUM, _T("--lock_accum"), false, SO_NONE, "\t--lock_accum Lock threads when accumulating to the histogram using the CPU. This will drop performance to that of single threading [default: false].\n")); INITBOOLOPTION(DumpKernel, Eob(eOptionUse::OPT_USE_RENDER, eOptionIDs::OPT_DUMP_KERNEL, _T("--dump_kernel"), false, SO_NONE, "\t--dump_kernel Print the iteration kernel string when using OpenCL (ignored for CPU) [default: false].\n")); //Int. - INITINTOPTION(Symmetry, Eoi(eOptionUse::OPT_USE_GENOME, eOptionIDs::OPT_SYMMETRY, _T("--symmetry"), 0, SO_REQ_SEP, "\t--symmetry= Set symmetry of result [default: 0].\n")); - INITINTOPTION(SheepGen, Eoi(eOptionUse::OPT_USE_GENOME, eOptionIDs::OPT_SHEEP_GEN, _T("--sheep_gen"), -1, SO_REQ_SEP, "\t--sheep_gen= Sheep generation of this flame [default: -1].\n")); - INITINTOPTION(SheepId, Eoi(eOptionUse::OPT_USE_GENOME, eOptionIDs::OPT_SHEEP_ID, _T("--sheep_id"), -1, SO_REQ_SEP, "\t--sheep_id= Sheep ID of this flame [default: -1].\n")); + INITINTOPTION(Symmetry, Eoi(eOptionUse::OPT_USE_GENOME, eOptionIDs::OPT_SYMMETRY, _T("--symmetry"), 0, SO_REQ_SEP, "\t--symmetry= Set symmetry of result [default: 0].\n")); + INITINTOPTION(SheepGen, Eoi(eOptionUse::OPT_USE_GENOME, eOptionIDs::OPT_SHEEP_GEN, _T("--sheep_gen"), -1, SO_REQ_SEP, "\t--sheep_gen= Sheep generation of this flame [default: -1].\n")); + INITINTOPTION(SheepId, Eoi(eOptionUse::OPT_USE_GENOME, eOptionIDs::OPT_SHEEP_ID, _T("--sheep_id"), -1, SO_REQ_SEP, "\t--sheep_id= Sheep ID of this flame [default: -1].\n")); #ifdef _WIN32 - INITINTOPTION(Priority, Eoi(eOptionUse::OPT_RENDER_ANIM, eOptionIDs::OPT_PRIORITY, _T("--priority"), int(eThreadPriority::NORMAL), SO_REQ_SEP, "\t--priority= The priority of the CPU rendering threads from -2 - 2. This does not apply to OpenCL rendering.\n")); + INITINTOPTION(Priority, Eoi(eOptionUse::OPT_RENDER_ANIM, eOptionIDs::OPT_PRIORITY, _T("--priority"), int(eThreadPriority::NORMAL), SO_REQ_SEP, "\t--priority= The priority of the CPU rendering threads from -2 - 2. This does not apply to OpenCL rendering.\n")); #else - INITINTOPTION(Priority, Eoi(eOptionUse::OPT_RENDER_ANIM, eOptionIDs::OPT_PRIORITY, _T("--priority"), int(eThreadPriority::NORMAL), SO_REQ_SEP, "\t--priority= The priority of the CPU rendering threads, 1, 25, 50, 75, 99. This does not apply to OpenCL rendering.\n")); + INITINTOPTION(Priority, Eoi(eOptionUse::OPT_RENDER_ANIM, eOptionIDs::OPT_PRIORITY, _T("--priority"), int(eThreadPriority::NORMAL), SO_REQ_SEP, "\t--priority= The priority of the CPU rendering threads, 1, 25, 50, 75, 99. This does not apply to OpenCL rendering.\n")); #endif //Uint. INITUINTOPTION(Seed, Eou(eOptionUse::OPT_USE_ALL, eOptionIDs::OPT_SEED, _T("--seed"), 0, SO_REQ_SEP, "\t--seed= Integer seed to use for the random number generator [default: random].\n")); @@ -355,6 +358,9 @@ public: //Double. INITDOUBLEOPTION(SizeScale, Eod(eOptionUse::OPT_RENDER_ANIM, eOptionIDs::OPT_SS, _T("--ss"), 1, SO_REQ_SEP, "\t--ss= Size scale. All dimensions are scaled by this amount [default: 1.0].\n")); INITDOUBLEOPTION(QualityScale, Eod(eOptionUse::OPT_RENDER_ANIM, eOptionIDs::OPT_QS, _T("--qs"), 1, SO_REQ_SEP, "\t--qs= Quality scale. All quality values are scaled by this amount [default: 1.0].\n")); + INITDOUBLEOPTION(Quality, Eod(eOptionUse::OPT_RENDER_ANIM, eOptionIDs::OPT_QUALITY, _T("--quality"), 0, SO_REQ_SEP, "\t--quality= Override the quality of the flame if not 0 [default: 0].\n")); + INITDOUBLEOPTION(DeMin, Eod(eOptionUse::OPT_RENDER_ANIM, eOptionIDs::OPT_DE_MIN, _T("--demin"), -1, SO_REQ_SEP, "\t--demin= Override the minimum size of the density estimator filter radius if not -1 [default: -1].\n")); + INITDOUBLEOPTION(DeMax, Eod(eOptionUse::OPT_RENDER_ANIM, eOptionIDs::OPT_DE_MAX, _T("--demax"), -1, SO_REQ_SEP, "\t--demax= Override the maximum size of the density estimator filter radius if not -1 [default: -1].\n")); INITDOUBLEOPTION(AspectRatio, Eod(eOptionUse::OPT_USE_ALL, eOptionIDs::OPT_PIXEL_ASPECT, _T("--pixel_aspect"), 1, SO_REQ_SEP, "\t--pixel_aspect= Aspect ratio of pixels (width over height), eg. 0.90909 for NTSC [default: 1.0].\n")); INITDOUBLEOPTION(Stagger, Eod(eOptionUse::OPT_USE_GENOME, eOptionIDs::OPT_STAGGER, _T("--stagger"), 0, SO_REQ_SEP, "\t--stagger= Affects simultaneity of xform interpolation during flame interpolation.\n" "\t Represents how 'separate' the xforms are interpolated. Set to 1 for each\n" @@ -374,7 +380,7 @@ public: INITSTRINGOPTION(Out, Eos(eOptionUse::OPT_USE_RENDER, eOptionIDs::OPT_OUT, _T("--out"), "", SO_REQ_SEP, "\t--out= Name of a single output file. Not recommended when rendering more than one image.\n")); INITSTRINGOPTION(Prefix, Eos(eOptionUse::OPT_RENDER_ANIM, eOptionIDs::OPT_PREFIX, _T("--prefix"), "", SO_REQ_SEP, "\t--prefix= Prefix to prepend to all output files.\n")); INITSTRINGOPTION(Suffix, Eos(eOptionUse::OPT_RENDER_ANIM, eOptionIDs::OPT_SUFFIX, _T("--suffix"), "", SO_REQ_SEP, "\t--suffix= Suffix to append to all output files.\n")); - INITSTRINGOPTION(Format, Eos(eOptionUse::OPT_RENDER_ANIM, eOptionIDs::OPT_FORMAT, _T("--format"), "png", SO_REQ_SEP, "\t--format= Format of the output file. Valid values are: bmp, jpg, png, ppm [default: jpg].\n")); + INITSTRINGOPTION(Format, Eos(eOptionUse::OPT_RENDER_ANIM, eOptionIDs::OPT_FORMAT, _T("--format"), "png", SO_REQ_SEP, "\t--format= Format of the output file. Valid values are: bmp, jpg, png, ppm [default: png].\n")); INITSTRINGOPTION(PalettePath, Eos(eOptionUse::OPT_USE_ALL, eOptionIDs::OPT_PALETTE_FILE, _T("--flam3_palettes"), "flam3-palettes.xml", SO_REQ_SEP, "\t--flam3_palettes= Path and name of the palette file [default: flam3-palettes.xml].\n")); //INITSTRINGOPTION(PaletteImage, Eos(eOptionUse::OPT_USE_ALL, eOptionIDs::OPT_PALETTE_IMAGE, _T("--image"), "", SO_REQ_SEP, "\t--image= Replace palette with png, jpg, or ppm image.\n")); INITSTRINGOPTION(Id, Eos(eOptionUse::OPT_USE_ALL, eOptionIDs::OPT_ID, _T("--id"), "", SO_REQ_SEP, "\t--id= ID to use in tags / image comments.\n")); @@ -483,6 +489,9 @@ public: PARSEUINTOPTION(eOptionIDs::OPT_MAX_XFORMS, MaxXforms); PARSEDOUBLEOPTION(eOptionIDs::OPT_SS, SizeScale);//Float args. PARSEDOUBLEOPTION(eOptionIDs::OPT_QS, QualityScale); + PARSEDOUBLEOPTION(eOptionIDs::OPT_QUALITY, Quality); + PARSEDOUBLEOPTION(eOptionIDs::OPT_DE_MIN, DeMin); + PARSEDOUBLEOPTION(eOptionIDs::OPT_DE_MAX, DeMax); PARSEDOUBLEOPTION(eOptionIDs::OPT_PIXEL_ASPECT, AspectRatio); PARSEDOUBLEOPTION(eOptionIDs::OPT_STAGGER, Stagger); PARSEDOUBLEOPTION(eOptionIDs::OPT_AVG_THRESH, AvgThresh); @@ -743,6 +752,9 @@ public: Eod SizeScale;//Value double. Eod QualityScale; + Eod Quality; + Eod DeMin; + Eod DeMax; Eod AspectRatio; Eod Stagger; Eod AvgThresh; diff --git a/Source/EmberGenome/EmberGenome.cpp b/Source/EmberGenome/EmberGenome.cpp index 138c286..b52a819 100644 --- a/Source/EmberGenome/EmberGenome.cpp +++ b/Source/EmberGenome/EmberGenome.cpp @@ -34,6 +34,14 @@ void SetDefaultTestValues(Ember& ember) ember.m_CurveDE = T(0.6); } +template +void FormatName(Ember& result, ostringstream& os, streamsize padding) +{ + os << std::setw(padding) << result.m_Time; + result.m_Name = os.str(); + os.str(""); +} + /// /// The core of the EmberGenome.exe program. /// Template argument expected to be float or double. @@ -381,6 +389,9 @@ bool EmberGenome(EmberOptions& opt) spread = 1 / T(opt.Frames()); frameCount = 0; + os.str(""); + os << setfill('0'); + auto padding = streamsize(std::log10(((opt.Frames() * opt.Loops()) + opt.Frames()) * embers.size())) + 1; for (i = 0; i < embers.size(); i++) { @@ -390,6 +401,7 @@ bool EmberGenome(EmberOptions& opt) { blend = T(frame) / T(opt.Frames()); tools.Spin(embers[i], pTemplate, result, frameCount++, blend);//Result is cleared and reassigned each time inside of Spin(). + FormatName(result, os, padding); cout << emberToXml.ToString(result, opt.Extras(), opt.PrintEditDepth(), !opt.NoEdits(), false, opt.HexPalette()); } @@ -399,6 +411,7 @@ bool EmberGenome(EmberOptions& opt) frame = size_t(std::round(opt.Frames() * opt.Loops())); blend = T(frame) / T(opt.Frames()); tools.Spin(embers[i], pTemplate, result, frameCount, blend);//Do not increment frameCount here. + FormatName(result, os, padding); } if (i < embers.size() - 1) @@ -412,6 +425,7 @@ bool EmberGenome(EmberOptions& opt) blend = frame / T(opt.Frames()); result.Clear(); tools.SpinInter(&embers[i], pTemplate, result, frameCount++, seqFlag, blend); + FormatName(result, os, padding); cout << emberToXml.ToString(result, opt.Extras(), opt.PrintEditDepth(), !opt.NoEdits(), false, opt.HexPalette()); } } @@ -419,6 +433,7 @@ bool EmberGenome(EmberOptions& opt) result = embers.back(); tools.Spin(embers.back(), pTemplate, result, frameCount, 0); + FormatName(result, os, padding); cout << emberToXml.ToString(result, opt.Extras(), opt.PrintEditDepth(), !opt.NoEdits(), false, opt.HexPalette()); if (opt.Enclosed()) diff --git a/Source/EmberRender/EmberRender.cpp b/Source/EmberRender/EmberRender.cpp index a1ccba7..5a9ccfa 100644 --- a/Source/EmberRender/EmberRender.cpp +++ b/Source/EmberRender/EmberRender.cpp @@ -172,6 +172,15 @@ bool EmberRender(EmberOptions& opt) if (opt.Supersample() > 0) embers[i].m_Supersample = opt.Supersample(); + if (opt.Quality() > 0) + embers[i].m_Quality = T(opt.Quality()); + + if (opt.DeMin() > -1) + embers[i].m_MinRadDE = T(opt.DeMin()); + + if (opt.DeMax() > -1) + embers[i].m_MaxRadDE = T(opt.DeMax()); + if (opt.SubBatchSize() != DEFAULT_SBS) embers[i].m_SubBatchSize = opt.SubBatchSize(); diff --git a/Source/EmberTester/EmberTester.cpp b/Source/EmberTester/EmberTester.cpp index 8816ce1..3d44d9e 100644 --- a/Source/EmberTester/EmberTester.cpp +++ b/Source/EmberTester/EmberTester.cpp @@ -567,7 +567,7 @@ bool TestVarEqual(const Variation* var1, const Variation
* var2) { if (!IsClose(params1[i].ParamVal(), (sT)params2[i].ParamVal(), sT(1e-4))) { - cout << "Param " << params1[i].Name() << " Val were not equal: " << params1[i].ParamVal() << " != " << params2[i].ParamVal() << endl; + cout << "Param " << params1[i].Name() << " Vals were not equal: " << params1[i].ParamVal() << " != " << params2[i].ParamVal() << endl; success = false; } } diff --git a/Source/Fractorium/EmberFile.h b/Source/Fractorium/EmberFile.h index 25bfbd8..c69d991 100644 --- a/Source/Fractorium/EmberFile.h +++ b/Source/Fractorium/EmberFile.h @@ -150,7 +150,9 @@ public: { endSection = str.section('_', -1); num = endSection.toULongLong(&ok); - ret.chop(str.size() - lastUnderscore); + + if (ok) + ret.chop(str.size() - lastUnderscore); } ret += "_" + QString::number(num + 1); @@ -180,7 +182,7 @@ public: newPath = path + base + "." + extension; } while (QFile::exists(newPath)); - + return newPath; } diff --git a/Source/Fractorium/Fractorium.h b/Source/Fractorium/Fractorium.h index cf078ad..3604838 100644 --- a/Source/Fractorium/Fractorium.h +++ b/Source/Fractorium/Fractorium.h @@ -149,6 +149,7 @@ public slots: void OnActionSP(bool checked); void OnActionDP(bool checked); void OnActionStyle(bool checked); + void OnActionStartStopRenderer(bool checked); //Library. void OnEmberTreeItemChanged(QTreeWidgetItem* item, int col); @@ -369,6 +370,7 @@ private: void ShutdownAndRecreateFromOptions(); bool CreateRendererFromOptions(); bool CreateControllerFromOptions(); + void EnableRenderControls(bool enable); //Dialogs. QStringList SetupOpenXmlDialog(); diff --git a/Source/Fractorium/Fractorium.qrc b/Source/Fractorium/Fractorium.qrc index b8604ce..2f3fffc 100644 --- a/Source/Fractorium/Fractorium.qrc +++ b/Source/Fractorium/Fractorium.qrc @@ -46,5 +46,7 @@ Icons/table_gear.png Icons/checkbox_checked.png Icons/checkbox_unchecked.png + Icons/control.png + Icons/control-stop-square.png diff --git a/Source/Fractorium/Fractorium.ui b/Source/Fractorium/Fractorium.ui index 34d0728..46a4dfd 100644 --- a/Source/Fractorium/Fractorium.ui +++ b/Source/Fractorium/Fractorium.ui @@ -7,7 +7,7 @@ 0 0 1451 - 953 + 1054 @@ -75,7 +75,7 @@ 0 0 1184 - 886 + 987 @@ -102,7 +102,7 @@ 0 0 240 - 881 + 981 @@ -157,7 +157,7 @@ 0 0 230 - 850 + 950 @@ -176,398 +176,6 @@ 0 - - - - true - - - - 0 - 0 - - - - - 0 - 22 - - - - - 16777215 - 22 - - - - Qt::NoFocus - - - QFrame::Panel - - - QFrame::Plain - - - Qt::ScrollBarAlwaysOff - - - Qt::ScrollBarAlwaysOff - - - false - - - false - - - false - - - 15 - - - false - - - 15 - - - true - - - false - - - 15 - - - false - - - 15 - - - - Filter - - - AlignHCenter|AlignTop - - - - - - - - true - - - - 0 - 0 - - - - - 0 - 22 - - - - - 16777215 - 22 - - - - Qt::NoFocus - - - QFrame::Panel - - - QFrame::Plain - - - Qt::ScrollBarAlwaysOff - - - Qt::ScrollBarAlwaysOff - - - QAbstractItemView::ScrollPerItem - - - QAbstractItemView::ScrollPerItem - - - false - - - false - - - false - - - 15 - - - false - - - 15 - - - true - - - false - - - 15 - - - false - - - 15 - - - - Color - - - AlignHCenter|AlignTop - - - - - - - - - 0 - 0 - - - - - 0 - 154 - - - - - 16777215 - 154 - - - - Qt::NoFocus - - - false - - - QFrame::Panel - - - QFrame::Plain - - - Qt::ScrollBarAlwaysOff - - - Qt::ScrollBarAlwaysOff - - - QAbstractItemView::NoEditTriggers - - - false - - - false - - - QAbstractItemView::NoSelection - - - QAbstractItemView::SelectItems - - - QAbstractItemView::ScrollPerPixel - - - QAbstractItemView::ScrollPerPixel - - - true - - - Qt::SolidLine - - - false - - - false - - - 2 - - - false - - - false - - - 110 - - - false - - - 35 - - - true - - - false - - - 22 - - - false - - - 22 - - - false - - - - Brightness - - - - - Gamma - - - - - Gamma Threshold - - - - - Vibrancy - - - - - Highlight Power - - - - - Background - - - - - Palette Mode - - - - - Field - - - - - - - - - - Brightness - - - - - 0 - - - - - Gamma - - - - - 0 - - - - - Gamma Threshold - - - - - 0 - - - - - Vibrancy - - - - - 0 - - - - - Highlight Power - - - - - 0 - - - - - Background - - - - - 0 - - - - - Palette Mode - - - - - 0 - - - - @@ -579,13 +187,13 @@ 0 - 154 + 88 16777215 - 154 + 88 @@ -686,21 +294,6 @@ Supersample - - - Temporal Samples - - - - - Affine Interpolation - - - - - Interpolation - - Field @@ -751,36 +344,6 @@ 0 - - - Temporal Samples - - - - - 0 - - - - - Affine Interpolation - - - - - 0 - - - - - Interpolation - - - - - 0 - - @@ -945,8 +508,11 @@ - - + + + + true + 0 @@ -956,13 +522,13 @@ 0 - 154 + 22 16777215 - 154 + 22 @@ -980,50 +546,29 @@ Qt::ScrollBarAlwaysOff - - QAbstractItemView::NoEditTriggers - - - false - - - false - - - QAbstractItemView::NoSelection - - QAbstractItemView::ScrollPerPixel + QAbstractItemView::ScrollPerItem - QAbstractItemView::ScrollPerPixel + QAbstractItemView::ScrollPerItem - true - - - Qt::SolidLine + false false - - 2 - false - - false - - 125 + 15 false - 35 + 15 true @@ -1032,136 +577,26 @@ false - 22 + 15 false - 22 + 15 - - false - - - - Spatial Filter Width - - - - - Spatial Filter Type - - - - - Temporal Filter Width - - - - - Temporal Filter Type - - - - - DE Filter Min Radius - - - - - DE Filter Max Radius - - - - - DE Curve - - - Field + Color + + + AlignHCenter|AlignTop - - - - - - - - Spatial Filter Width - - - - - 0 - - - - - Spatial Filter Type - - - - - 0 - - - - - Temporal Filter Width - - - - - 0 - - - - - Temporal Filter Type - - - - - 0 - - - - - DE Filter Min Radius - - - - - 0 - - - - - DE Filter Max Radius - - - - - 0 - - - - - DE Curve - - - - - 0 - - - - + + Qt::Vertical @@ -1176,6 +611,87 @@ + + + + true + + + + 0 + 0 + + + + + 0 + 22 + + + + + 16777215 + 22 + + + + Qt::NoFocus + + + QFrame::Panel + + + QFrame::Plain + + + Qt::ScrollBarAlwaysOff + + + Qt::ScrollBarAlwaysOff + + + false + + + false + + + false + + + 15 + + + false + + + 15 + + + true + + + false + + + 15 + + + false + + + 15 + + + + Filter + + + AlignHCenter|AlignTop + + + + @@ -1192,6 +708,22 @@ + + + + Qt::Vertical + + + QSizePolicy::Minimum + + + + 20 + 5 + + + + @@ -1482,8 +1014,498 @@ - - + + + + + 0 + 0 + + + + + 0 + 110 + + + + + 16777215 + 110 + + + + Qt::NoFocus + + + QFrame::Panel + + + QFrame::Plain + + + Qt::ScrollBarAlwaysOff + + + Qt::ScrollBarAlwaysOff + + + QAbstractItemView::NoEditTriggers + + + false + + + false + + + QAbstractItemView::NoSelection + + + QAbstractItemView::ScrollPerPixel + + + QAbstractItemView::ScrollPerPixel + + + true + + + Qt::SolidLine + + + false + + + 2 + + + false + + + false + + + 125 + + + false + + + 35 + + + true + + + false + + + 22 + + + false + + + 22 + + + false + + + + Spatial Filter Width + + + + + Spatial Filter Type + + + + + DE Filter Min Radius + + + + + DE Filter Max Radius + + + + + DE Curve + + + + + Field + + + + + + + + + + Spatial Filter Width + + + + + 0 + + + + + Spatial Filter Type + + + + + 0 + + + + + DE Filter Min Radius + + + + + 0 + + + + + DE Filter Max Radius + + + + + 0 + + + + + DE Curve + + + + + 0 + + + + + + + + + 0 + 0 + + + + + 0 + 154 + + + + + 16777215 + 154 + + + + Qt::NoFocus + + + false + + + QFrame::Panel + + + QFrame::Plain + + + Qt::ScrollBarAlwaysOff + + + Qt::ScrollBarAlwaysOff + + + QAbstractItemView::NoEditTriggers + + + false + + + false + + + QAbstractItemView::NoSelection + + + QAbstractItemView::SelectItems + + + QAbstractItemView::ScrollPerPixel + + + QAbstractItemView::ScrollPerPixel + + + true + + + Qt::SolidLine + + + false + + + false + + + 2 + + + false + + + false + + + 110 + + + false + + + 35 + + + true + + + false + + + 22 + + + false + + + 22 + + + false + + + + Brightness + + + + + Gamma + + + + + Gamma Threshold + + + + + Vibrancy + + + + + Highlight Power + + + + + Background + + + + + Palette Mode + + + + + Field + + + + + + + + + + Brightness + + + + + 0 + + + + + Gamma + + + + + 0 + + + + + Gamma Threshold + + + + + 0 + + + + + Vibrancy + + + + + 0 + + + + + Highlight Power + + + + + 0 + + + + + Background + + + + + 0 + + + + + Palette Mode + + + + + 0 + + + + + + + + + 0 + 0 + + + + + 0 + 22 + + + + + 16777215 + 22 + + + + Qt::NoFocus + + + QFrame::Panel + + + QFrame::Plain + + + Qt::ScrollBarAlwaysOff + + + Qt::ScrollBarAlwaysOff + + + false + + + false + + + 1 + + + false + + + 15 + + + false + + + 15 + + + true + + + false + + + 15 + + + false + + + 15 + + + + Animation + + + AlignHCenter|AlignTop + + + + + + Qt::Vertical @@ -1498,8 +1520,149 @@ - - + + + + + 0 + 0 + + + + + 0 + 110 + + + + + 16777215 + 110 + + + + Qt::NoFocus + + + QFrame::Panel + + + QFrame::Plain + + + Qt::ScrollBarAlwaysOff + + + Qt::ScrollBarAlwaysOff + + + QAbstractItemView::NoEditTriggers + + + false + + + QAbstractItemView::NoSelection + + + QAbstractItemView::ScrollPerPixel + + + QAbstractItemView::ScrollPerPixel + + + false + + + 2 + + + false + + + 125 + + + false + + + 35 + + + true + + + false + + + 22 + + + false + + + 22 + + + + Interpolation + + + + + Affine Interpolation + + + + + Temporal Samples + + + + + Temporal Filter Width + + + + + Temporal Filter Type + + + + + Field + + + + + + Interpolation + + + + + Affine Interpolation + + + + + Temporal Samples + + + + + Temporal Filter Width + + + + + Temporal Filter Type + + + + + + Qt::Vertical @@ -1509,7 +1672,7 @@ 20 - 300 + 20 @@ -6472,7 +6635,7 @@ 0 0 256 - 855 + 956 @@ -6561,6 +6724,7 @@ + @@ -6990,6 +7154,30 @@ Show QSS style editor + + + true + + + false + + + true + + + + :/Fractorium/Icons/control-stop-square.png:/Fractorium/Icons/control-stop-square.png + + + Stop Renderer + + + Stop Renderer + + + Ctrl+R + + diff --git a/Source/Fractorium/FractoriumMenus.cpp b/Source/Fractorium/FractoriumMenus.cpp index 3a72374..b8370ad 100644 --- a/Source/Fractorium/FractoriumMenus.cpp +++ b/Source/Fractorium/FractoriumMenus.cpp @@ -823,6 +823,8 @@ void Fractorium::OnFinalRenderClose(int result) { m_RenderStatusLabel->setText("Renderer starting..."); StartRenderTimer();//Re-create the renderer and start rendering again. + ui.ActionStartStopRenderer->setChecked(false);//Re-enable any controls that might have been disabled. + OnActionStartStopRenderer(false); } /// diff --git a/Source/Fractorium/FractoriumParams.cpp b/Source/Fractorium/FractoriumParams.cpp index a2bd65a..25bedef 100644 --- a/Source/Fractorium/FractoriumParams.cpp +++ b/Source/Fractorium/FractoriumParams.cpp @@ -20,8 +20,9 @@ void Fractorium::InitParamsUI() SetFixedTableHeader(ui.GeometryTableHeader->horizontalHeader()); SetFixedTableHeader(ui.FilterTableHeader->horizontalHeader()); SetFixedTableHeader(ui.IterationTableHeader->horizontalHeader()); + SetFixedTableHeader(ui.AnimationTableHeader->horizontalHeader()); //Color. - SetupSpinner(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(table, this, row, 1, m_BrightnessSpin, spinHeight, 0.05, 1000, 1, SIGNAL(valueChanged(double)), SLOT(OnBrightnessChanged(double)), true, 4.0, 4.0, 4.0); SetupSpinner(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(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(table, this, row, 1, m_VibrancySpin, spinHeight, 0, 30, 0.01, SIGNAL(valueChanged(double)), SLOT(OnVibrancyChanged(double)), true, 1.0, 1.0, 0.0); @@ -65,9 +66,6 @@ void Fractorium::InitParamsUI() SetupSpinner(table, this, row, 1, m_SpatialFilterWidthSpin, spinHeight, 0.1, 10, 0.1, SIGNAL(valueChanged(double)), SLOT(OnSpatialFilterWidthChanged(double)), true, 1.0, 1.0, 1.0); comboVals = SpatialFilterCreator::FilterTypes(); SetupCombo(table, this, row, 1, m_SpatialFilterTypeCombo, comboVals, SIGNAL(currentIndexChanged(const QString&)), SLOT(OnSpatialFilterTypeComboCurrentIndexChanged(const QString&))); - SetupSpinner(table, this, row, 1, m_TemporalFilterWidthSpin, spinHeight, 1, 10, 1, SIGNAL(valueChanged(double)), SLOT(OnTemporalFilterWidthChanged(double)), true, 1); - comboVals = TemporalFilterCreator::FilterTypes(); - SetupCombo(table, this, row, 1, m_TemporalFilterTypeCombo, comboVals, SIGNAL(currentIndexChanged(const QString&)), SLOT(OnTemporalFilterTypeComboCurrentIndexChanged(const QString&))); SetupSpinner(table, this, row, 1, m_DEFilterMinRadiusSpin, spinHeight, 0, 25, 1, SIGNAL(valueChanged(double)), SLOT(OnDEFilterMinRadiusWidthChanged(double)), true, 0, 0, 0); SetupSpinner(table, this, row, 1, m_DEFilterMaxRadiusSpin, spinHeight, 0, 25, 1, SIGNAL(valueChanged(double)), SLOT(OnDEFilterMaxRadiusWidthChanged(double)), true, 0.0, 9.0, 0); SetupSpinner(table, this, row, 1, m_DECurveSpin, spinHeight, 0.15, 5, 0.1, SIGNAL(valueChanged(double)), SLOT(OnDEFilterCurveWidthChanged(double)), true, 0.4, 0.4, 0.4); @@ -78,15 +76,21 @@ void Fractorium::InitParamsUI() SetupSpinner( table, this, row, 1, m_FuseSpin, spinHeight, 1, 1000, 5, SIGNAL(valueChanged(int)), SLOT(OnFuseChanged(int)), true, 15, 15, 15); SetupSpinner(table, this, row, 1, m_QualitySpin, spinHeight, 1, dmax, 50, SIGNAL(valueChanged(double)), SLOT(OnQualityChanged(double)), true, 10, 10, 10); SetupSpinner( table, this, row, 1, m_SupersampleSpin, spinHeight, 1, 4, 1, SIGNAL(valueChanged(int)), SLOT(OnSupersampleChanged(int)), true, 1, 1, 1); - SetupSpinner( table, this, row, 1, m_TemporalSamplesSpin, spinHeight, 1, 5000, 1, SIGNAL(valueChanged(int)), SLOT(OnTemporalSamplesChanged(int)), true, 1000); - comboVals.clear(); - comboVals.push_back("Step"); - comboVals.push_back("Linear"); - SetupCombo(table, this, row, 1, m_AffineInterpTypeCombo, comboVals, SIGNAL(currentIndexChanged(int)), SLOT(OnAffineInterpTypeComboCurrentIndexChanged(int))); + //Animation. + row = 0; + table = ui.AnimationTable; comboVals.clear(); comboVals.push_back("Linear"); comboVals.push_back("Smooth"); SetupCombo(table, this, row, 1, m_InterpTypeCombo, comboVals, SIGNAL(currentIndexChanged(int)), SLOT(OnInterpTypeComboCurrentIndexChanged(int))); + comboVals.clear(); + comboVals.push_back("Step"); + comboVals.push_back("Linear"); + SetupCombo( table, this, row, 1, m_AffineInterpTypeCombo, comboVals, SIGNAL(currentIndexChanged(int)), SLOT(OnAffineInterpTypeComboCurrentIndexChanged(int))); + SetupSpinner( table, this, row, 1, m_TemporalSamplesSpin, spinHeight, 1, 5000, 1, SIGNAL(valueChanged(int)), SLOT(OnTemporalSamplesChanged(int)), true, 1000); + SetupSpinner(table, this, row, 1, m_TemporalFilterWidthSpin, spinHeight, 1, 10, 1, SIGNAL(valueChanged(double)), SLOT(OnTemporalFilterWidthChanged(double)), true, 1); + comboVals = TemporalFilterCreator::FilterTypes(); + SetupCombo( table, this, row, 1, m_TemporalFilterTypeCombo, comboVals, SIGNAL(currentIndexChanged(const QString&)), SLOT(OnTemporalFilterTypeComboCurrentIndexChanged(const QString&))); } /// diff --git a/Source/Fractorium/FractoriumRender.cpp b/Source/Fractorium/FractoriumRender.cpp index 52e2dd8..2f8e52b 100644 --- a/Source/Fractorium/FractoriumRender.cpp +++ b/Source/Fractorium/FractoriumRender.cpp @@ -606,6 +606,20 @@ bool FractoriumEmberController::CreateRenderer(eRendererType renderType, cons return ok; } +/// +/// Enable or disable the controls related to changing the renderer. +/// Used when pausing and restarting the renderer. +/// +/// True to enable, else false. +void Fractorium::EnableRenderControls(bool enable) +{ + ui.ActionCpu->setEnabled(enable); + ui.ActionCL->setEnabled(enable); + ui.ActionSP->setEnabled(enable); + ui.ActionDP->setEnabled(enable); + ui.ActionOptions->setEnabled(enable); +} + /// /// Wrapper to stop the timer, shutdown the controller and recreate, then restart the controller and renderer from the options. /// diff --git a/Source/Fractorium/FractoriumToolbar.cpp b/Source/Fractorium/FractoriumToolbar.cpp index 94278a6..8683d11 100644 --- a/Source/Fractorium/FractoriumToolbar.cpp +++ b/Source/Fractorium/FractoriumToolbar.cpp @@ -14,11 +14,12 @@ void Fractorium::InitToolbarUI() spGroup->addAction(ui.ActionSP); spGroup->addAction(ui.ActionDP); SyncOptionsToToolbar(); - connect(ui.ActionCpu, SIGNAL(triggered(bool)), this, SLOT(OnActionCpu(bool)), Qt::QueuedConnection); - connect(ui.ActionCL, SIGNAL(triggered(bool)), this, SLOT(OnActionCL(bool)), Qt::QueuedConnection); - connect(ui.ActionSP, SIGNAL(triggered(bool)), this, SLOT(OnActionSP(bool)), Qt::QueuedConnection); - connect(ui.ActionDP, SIGNAL(triggered(bool)), this, SLOT(OnActionDP(bool)), Qt::QueuedConnection); - connect(ui.ActionStyle, SIGNAL(triggered(bool)), this, SLOT(OnActionStyle(bool)), Qt::QueuedConnection); + connect(ui.ActionCpu, SIGNAL(triggered(bool)), this, SLOT(OnActionCpu(bool)), Qt::QueuedConnection); + connect(ui.ActionCL, SIGNAL(triggered(bool)), this, SLOT(OnActionCL(bool)), Qt::QueuedConnection); + connect(ui.ActionSP, SIGNAL(triggered(bool)), this, SLOT(OnActionSP(bool)), Qt::QueuedConnection); + connect(ui.ActionDP, SIGNAL(triggered(bool)), this, SLOT(OnActionDP(bool)), Qt::QueuedConnection); + connect(ui.ActionStyle, SIGNAL(triggered(bool)), this, SLOT(OnActionStyle(bool)), Qt::QueuedConnection); + connect(ui.ActionStartStopRenderer, SIGNAL(triggered(bool)), this, SLOT(OnActionStartStopRenderer(bool)), Qt::QueuedConnection); } /// @@ -82,6 +83,28 @@ void Fractorium::OnActionStyle(bool checked) m_QssDialog->show(); } +/// +/// Called when the start/stop renderer button is clicked. +/// +/// Check state, stop renderer if true, else start. +void Fractorium::OnActionStartStopRenderer(bool checked) +{ + EnableRenderControls(!checked); + + if (checked) + { + m_Controller->StopRenderTimer(true); + ui.ActionStartStopRenderer->setToolTip("Start Renderer"); + ui.ActionStartStopRenderer->setIcon(QIcon(":/Fractorium/Icons/control.png")); + } + else + { + m_Controller->StartRenderTimer(); + ui.ActionStartStopRenderer->setToolTip("Stop Renderer"); + ui.ActionStartStopRenderer->setIcon(QIcon(":/Fractorium/Icons/control-stop-square.png")); + } +} + /// /// Sync options data to the check state of the toolbar buttons. /// This does not trigger a clicked() event. diff --git a/Source/Fractorium/Icons/control-stop-square.png b/Source/Fractorium/Icons/control-stop-square.png new file mode 100644 index 0000000..74018fb Binary files /dev/null and b/Source/Fractorium/Icons/control-stop-square.png differ diff --git a/Source/Fractorium/Icons/control.png b/Source/Fractorium/Icons/control.png new file mode 100644 index 0000000..8d616ea Binary files /dev/null and b/Source/Fractorium/Icons/control.png differ