Added Gnarly Variation

This commit is contained in:
Michel Mastriani 2019-05-27 20:26:02 -03:00
parent f9901da797
commit ba1cdb87da
4 changed files with 118 additions and 0 deletions

View File

@ -489,6 +489,7 @@ uint Timing::m_ProcessorCount;
EXPORTPREPOSTREGVAR(Waves42, T) \ EXPORTPREPOSTREGVAR(Waves42, T) \
EXPORTPREPOSTREGVAR(Waves3, T) \ EXPORTPREPOSTREGVAR(Waves3, T) \
EXPORTPREPOSTREGVAR(Waves4, T) \ EXPORTPREPOSTREGVAR(Waves4, T) \
EXPORTPREPOSTREGVAR(Gnarly, T) \
template EMBER_API class VariationList<T>; \ template EMBER_API class VariationList<T>; \
template EMBER_API class SpatialFilter<T>; \ template EMBER_API class SpatialFilter<T>; \
template EMBER_API class GaussianFilter<T>; \ template EMBER_API class GaussianFilter<T>; \

View File

@ -212,6 +212,7 @@ enum class eVariationId : et
VAR_GLYNNSIM3 , VAR_GLYNNSIM3 ,
VAR_GLYNNSIM4 , VAR_GLYNNSIM4 ,
VAR_GLYNNSIM5 , VAR_GLYNNSIM5 ,
VAR_GNARLY ,
VAR_GRIDOUT , VAR_GRIDOUT ,
VAR_HANDKERCHIEF, VAR_HANDKERCHIEF,
VAR_HEART , VAR_HEART ,
@ -626,6 +627,7 @@ enum class eVariationId : et
VAR_PRE_GLYNNSIM3, VAR_PRE_GLYNNSIM3,
VAR_PRE_GLYNNSIM4, VAR_PRE_GLYNNSIM4,
VAR_PRE_GLYNNSIM5, VAR_PRE_GLYNNSIM5,
VAR_PRE_GNARLY,
VAR_PRE_GRIDOUT, VAR_PRE_GRIDOUT,
VAR_PRE_HANDKERCHIEF, VAR_PRE_HANDKERCHIEF,
VAR_PRE_HEART, VAR_PRE_HEART,
@ -1039,6 +1041,7 @@ enum class eVariationId : et
VAR_POST_GLYNNSIM3, VAR_POST_GLYNNSIM3,
VAR_POST_GLYNNSIM4, VAR_POST_GLYNNSIM4,
VAR_POST_GLYNNSIM5, VAR_POST_GLYNNSIM5,
VAR_POST_GNARLY,
VAR_POST_GRIDOUT, VAR_POST_GRIDOUT,
VAR_POST_HANDKERCHIEF, VAR_POST_HANDKERCHIEF,
VAR_POST_HEART, VAR_POST_HEART,

View File

@ -429,6 +429,7 @@ VariationList<T>::VariationList()
ADDPREPOSTREGVAR(Waves3) ADDPREPOSTREGVAR(Waves3)
ADDPREPOSTREGVAR(Waves4) ADDPREPOSTREGVAR(Waves4)
ADDPREPOSTREGVAR(Waves42) ADDPREPOSTREGVAR(Waves42)
ADDPREPOSTREGVAR(Gnarly)
//ADDPREPOSTREGVAR(LinearXZ) //ADDPREPOSTREGVAR(LinearXZ)
//ADDPREPOSTREGVAR(LinearYZ) //ADDPREPOSTREGVAR(LinearYZ)
//DC are special. //DC are special.

View File

@ -7076,6 +7076,118 @@ private:
T m_Yfact001;//Precalc. T m_Yfact001;//Precalc.
}; };
/// <summary>
/// Gnarly.
/// </summary>
template <typename T>
class GnarlyVariation : public ParametricVariation<T>
{
public:
GnarlyVariation(T weight = 1.0) : ParametricVariation<T>("gnarly", eVariationId::VAR_GNARLY, weight)
{
Init();
}
PARVARCOPY(GnarlyVariation)
virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override
{
T Vx, Vy;
T Cx, Cy;
T Lx, Ly;
T r, theta, s, c;
Vx = helper.In.x;
Vy = helper.In.y;
if (m_GnarlyCellSize != T(0))
{
Cx = (Floor<T>(Vx / m_GnarlyCellSize) + T(0.5)) * m_GnarlyCellSize;
Cy = (Floor<T>(Vy / m_GnarlyCellSize) + T(0.5)) * m_GnarlyCellSize;
Lx = Vx - Cx;
Ly = Vy - Cy;
if ((Lx * Lx + Ly * Ly) <= m_R2)
{
r = (Lx * Lx + Ly * Ly) / m_R2;
theta = m_GnarlyTwist * std::log(r);
sincos(theta, &s, &c);
Vx = Cx + c * Lx + s * Ly;
Vy = Cy - s * Lx + c * Ly;
}
}
helper.Out.x += m_Weight * Vx;
helper.Out.y += m_Weight * Vy;
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 weight = WeightDefineString();
string cellsize = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
string twist = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
string r2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
ss << "\t{\n"
<< "\t\treal_t Vx, Vy, Cx, Cy, Lx, Ly;\n"
<< "\t\treal_t r, theta, s, c;\n"
<< "\n"
<< "\t\tVx = vIn.x;\n"
<< "\t\tVy = vIn.y;\n"
<< "\n"
<< "\t\tif (" << cellsize << " != (real_t)(0))\n"
<< "\t\t{\n"
<< "\t\t\tCx = (floor(Vx / " << cellsize << ") + (real_t)(0.5)) * " << cellsize << ";\n"
<< "\t\t\tCy = (floor(Vy / " << cellsize << ") + (real_t)(0.5)) * " << cellsize << ";\n"
<< "\n"
<< "\t\t\tLx = Vx - Cx;\n"
<< "\t\t\tLy = Vy - Cy;\n"
<< "\n"
<< "\t\t\tif ((Lx * Lx + Ly * Ly) <= " << r2 << ")\n"
<< "\t\t\t{\n"
<< "\t\t\t\tr = (Lx * Lx + Ly * Ly) / " << r2 << ";\n"
<< "\t\t\t\ttheta = " << twist << " * log(r);\n"
<< "\t\t\t\ts = sin(theta);\n"
<< "\t\t\t\tc = cos(theta);\n"
<< "\t\t\t\tVx = Cx + c * Lx + s * Ly;\n"
<< "\t\t\t\tVy = Cy - s * Lx + c * Ly;\n"
<< "\t\t\t}\n"
<< "\t\t}\n"
<< "\n"
<< "\t\tvOut.x += " << weight << " * Vx;\n"
<< "\t\tvOut.y += " << weight << " * Vy;\n"
<< "\t\tvOut.z = " << DefaultZCl()
<< "\t}\n";
return ss.str();
}
virtual void Precalc() override
{
T radius = T(0.5) * m_GnarlyCellSize;
m_R2 = Zeps(radius * radius);
}
protected:
void Init()
{
string prefix = Prefix();
m_Params.clear();
m_Params.push_back(ParamWithName<T>(&m_GnarlyCellSize, prefix + "gnarly_cellsize", T(1)));
m_Params.push_back(ParamWithName<T>(&m_GnarlyTwist, prefix + "gnarly_twist", T(1)));
m_Params.push_back(ParamWithName<T>(true, &m_R2, prefix + "gnarly_r2"));//Precalc.
}
private:
T m_GnarlyCellSize;
T m_GnarlyTwist;
T m_R2;//Precalc.
};
MAKEPREPOSTPARVAR(Splits3D, splits3D, SPLITS3D) MAKEPREPOSTPARVAR(Splits3D, splits3D, SPLITS3D)
MAKEPREPOSTPARVAR(Waves2B, waves2b, WAVES2B) MAKEPREPOSTPARVAR(Waves2B, waves2b, WAVES2B)
MAKEPREPOSTPARVAR(JacCn, jac_cn, JAC_CN) MAKEPREPOSTPARVAR(JacCn, jac_cn, JAC_CN)
@ -7144,4 +7256,5 @@ MAKEPREPOSTPARVAR(Waves23, waves23, WAVES23)
MAKEPREPOSTPARVAR(Waves42, waves42, WAVES42) MAKEPREPOSTPARVAR(Waves42, waves42, WAVES42)
MAKEPREPOSTPARVAR(Waves3, waves3, WAVES3) MAKEPREPOSTPARVAR(Waves3, waves3, WAVES3)
MAKEPREPOSTPARVAR(Waves4, waves4, WAVES4) MAKEPREPOSTPARVAR(Waves4, waves4, WAVES4)
MAKEPREPOSTPARVAR(Gnarly, gnarly, GNARLY)
} }