mirror of
https://bitbucket.org/mfeemster/fractorium.git
synced 2025-01-21 13:10:04 -05:00
--User changes
-Add inkdrop variation.
This commit is contained in:
parent
3b265338fc
commit
2c4fb3b72d
@ -490,6 +490,7 @@ uint Timing::m_ProcessorCount;
|
||||
EXPORTPREPOSTREGVAR(Waves3, T) \
|
||||
EXPORTPREPOSTREGVAR(Waves4, T) \
|
||||
EXPORTPREPOSTREGVAR(Gnarly, T) \
|
||||
EXPORTPREPOSTREGVAR(Inkdrop, T) \
|
||||
template EMBER_API class VariationList<T>; \
|
||||
template EMBER_API class SpatialFilter<T>; \
|
||||
template EMBER_API class GaussianFilter<T>; \
|
||||
|
@ -241,6 +241,7 @@ enum class eVariationId : et
|
||||
VAR_HYPERTILE3D1,
|
||||
VAR_HYPERTILE3D2,
|
||||
VAR_IDISC ,
|
||||
VAR_INKDROP,
|
||||
VAR_INTERFERENCE2,
|
||||
VAR_JAC_CN ,
|
||||
VAR_JAC_DN ,
|
||||
@ -656,6 +657,7 @@ enum class eVariationId : et
|
||||
VAR_PRE_HYPERTILE3D1,
|
||||
VAR_PRE_HYPERTILE3D2,
|
||||
VAR_PRE_IDISC,
|
||||
VAR_PRE_INKDROP,
|
||||
VAR_PRE_INTERFERENCE2,
|
||||
VAR_PRE_JAC_CN,
|
||||
VAR_PRE_JAC_DN,
|
||||
@ -1070,6 +1072,7 @@ enum class eVariationId : et
|
||||
VAR_POST_HYPERTILE3D1,
|
||||
VAR_POST_HYPERTILE3D2,
|
||||
VAR_POST_IDISC,
|
||||
VAR_POST_INKDROP,
|
||||
VAR_POST_INTERFERENCE2,
|
||||
VAR_POST_JAC_CN,
|
||||
VAR_POST_JAC_DN,
|
||||
|
@ -430,6 +430,7 @@ VariationList<T>::VariationList()
|
||||
ADDPREPOSTREGVAR(Waves4)
|
||||
ADDPREPOSTREGVAR(Waves42)
|
||||
ADDPREPOSTREGVAR(Gnarly)
|
||||
ADDPREPOSTREGVAR(Inkdrop)
|
||||
//ADDPREPOSTREGVAR(LinearXZ)
|
||||
//ADDPREPOSTREGVAR(LinearYZ)
|
||||
//DC are special.
|
||||
|
@ -7187,6 +7187,90 @@ private:
|
||||
T m_R2;//Precalc.
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// inkdrop by Jess.
|
||||
/// </summary>
|
||||
template <typename T>
|
||||
class InkdropVariation : public ParametricVariation<T>
|
||||
{
|
||||
public:
|
||||
InkdropVariation(T weight = 1.0) : ParametricVariation<T>("inkdrop", eVariationId::VAR_INKDROP, weight)
|
||||
{
|
||||
Init();
|
||||
}
|
||||
|
||||
PARVARCOPY(InkdropVariation)
|
||||
|
||||
virtual void Func(IteratorHelper<T>& helper, Point<T>& outPoint, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override
|
||||
{
|
||||
T distx = helper.In.x - m_X;
|
||||
T disty = helper.In.y - m_Y;
|
||||
T dist2 = SQR(distx) + SQR(disty);
|
||||
T adjust = std::sqrt(dist2 + m_Rad2) - std::sqrt(dist2);
|
||||
T bearing = std::atan2(disty, distx);
|
||||
T x = helper.In.x + (std::cos(bearing) * adjust);
|
||||
T y = helper.In.y + (std::sin(bearing) * adjust);
|
||||
helper.Out.x = m_Weight * x;
|
||||
helper.Out.y = m_Weight * 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 weight = WeightDefineString();
|
||||
string r = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
string x = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
string y = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
string rad2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index;
|
||||
ss << "\t{\n"
|
||||
<< "\t\treal_t distx = vIn.x - " << x << ";\n"
|
||||
<< "\t\treal_t disty = vIn.y - " << y << ";\n"
|
||||
<< "\t\treal_t dist2 = SQR(distx) + SQR(disty);\n"
|
||||
<< "\t\treal_t adjust = sqrt(dist2 + " << rad2 << ") - sqrt(dist2);\n"
|
||||
<< "\n"
|
||||
<< "\t\treal_t bearing = atan2(disty, distx);\n"
|
||||
<< "\t\treal_t x = fma(cos(bearing), adjust, vIn.x);\n"
|
||||
<< "\t\treal_t y = fma(sin(bearing), adjust, vIn.y);\n"
|
||||
<< "\n"
|
||||
<< "\t\tvOut.x = " << weight << " * x;\n"
|
||||
<< "\t\tvOut.y = " << weight << " * y;\n"
|
||||
<< "\t\tvOut.z = " << DefaultZCl()
|
||||
<< "\t}\n";
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
virtual void Precalc() override
|
||||
{
|
||||
m_Rad2 = SQR(m_R);
|
||||
}
|
||||
|
||||
virtual vector<string> OpenCLGlobalFuncNames() const override
|
||||
{
|
||||
return vector<string> { "Zeps" };
|
||||
}
|
||||
|
||||
protected:
|
||||
void Init()
|
||||
{
|
||||
string prefix = Prefix();
|
||||
m_Params.clear();
|
||||
m_Params.push_back(ParamWithName<T>(&m_R, prefix + "inkdrop_r", T(0.5), eParamType::REAL, 0));
|
||||
m_Params.push_back(ParamWithName<T>(&m_X, prefix + "inkdrop_x"));
|
||||
m_Params.push_back(ParamWithName<T>(&m_Y, prefix + "inkdrop_y"));
|
||||
m_Params.push_back(ParamWithName<T>(true, &m_Rad2, prefix + "inkdrop_rad2"));//Precalc.
|
||||
}
|
||||
|
||||
private:
|
||||
T m_R;
|
||||
T m_X;
|
||||
T m_Y;
|
||||
T m_Rad2;//Precalc.
|
||||
};
|
||||
|
||||
MAKEPREPOSTPARVAR(Splits3D, splits3D, SPLITS3D)
|
||||
MAKEPREPOSTPARVAR(Waves2B, waves2b, WAVES2B)
|
||||
MAKEPREPOSTPARVAR(JacCn, jac_cn, JAC_CN)
|
||||
@ -7256,4 +7340,5 @@ MAKEPREPOSTPARVAR(Waves42, waves42, WAVES42)
|
||||
MAKEPREPOSTPARVAR(Waves3, waves3, WAVES3)
|
||||
MAKEPREPOSTPARVAR(Waves4, waves4, WAVES4)
|
||||
MAKEPREPOSTPARVAR(Gnarly, gnarly, GNARLY)
|
||||
MAKEPREPOSTPARVAR(Inkdrop, inkdrop, INKDROP)
|
||||
}
|
||||
|
@ -744,16 +744,17 @@ bool SearchVar(const Variation<T>* var, const vector<string>& stringVec, bool ma
|
||||
/// <param name="stringVec">The vector of variation pointers to search</param>
|
||||
/// <param name="stringVec">The vector of strings to search for</param>
|
||||
/// <param name="findAll">True to find all variations which match any strings, false to break after the first match is found.</param>
|
||||
/// <param name="matchAll">True to find all variations which match all strings, false to stop searching a variation after the first match succeeds.</param>
|
||||
/// <returns>A vector of pointers to variations whose OpenCL string matched at least one string in stringVec</returns>
|
||||
template <typename T>
|
||||
static vector<const Variation<T>*> FindVarsWith(const vector<const Variation<T>*>& vars, const vector<string>& stringVec, bool findAll = true)
|
||||
static vector<const Variation<T>*> FindVarsWith(const vector<const Variation<T>*>& vars, const vector<string>& stringVec, bool findAll = true, bool matchAll = false)
|
||||
{
|
||||
vector<const Variation<T>*> vec;
|
||||
auto vl = VariationList<T>::Instance();
|
||||
|
||||
for (auto& v : vars)
|
||||
{
|
||||
if (SearchVar<T>(v, stringVec, false))
|
||||
if (SearchVar<T>(v, stringVec, matchAll))
|
||||
{
|
||||
vec.push_back(v);
|
||||
|
||||
|
@ -1583,6 +1583,26 @@ void TestOperations()
|
||||
}
|
||||
}
|
||||
|
||||
void TestArbitrary()
|
||||
{
|
||||
vector<string> stringVec;
|
||||
auto varList = VariationList<float>::Instance();
|
||||
auto& vars = varList->AllVars();
|
||||
stringVec.push_back(" = vIn.x - ");
|
||||
stringVec.push_back(" = vIn.y - ");
|
||||
stringVec.push_back("sqrt(");
|
||||
stringVec.push_back("atan2(");
|
||||
stringVec.push_back("sin(");
|
||||
stringVec.push_back("cos(");
|
||||
//stringVec.push_back("sincos(");
|
||||
auto varVec = FindVarsWith<float>(vars, stringVec, true, true);
|
||||
|
||||
for (auto& it : varVec)
|
||||
{
|
||||
cout << "Variation " << it->Name() << " contained the desired strings." << endl;
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void TestVarsSimilar()
|
||||
{
|
||||
@ -2448,6 +2468,9 @@ int _tmain(int argc, _TCHAR* argv[])
|
||||
t.Tic();
|
||||
TestOperations<float>();
|
||||
t.Toc("TestOperations()");
|
||||
t.Tic();
|
||||
TestArbitrary();
|
||||
t.Toc("TestArbitrary()");
|
||||
//t.Tic();
|
||||
//TestVarsSimilar<float>();
|
||||
//t.Toc("TestVarsSimilar()");
|
||||
|
Loading…
Reference in New Issue
Block a user