From 90e7097d7f04b9abbf866df53ef6f81ca2376698 Mon Sep 17 00:00:00 2001 From: Person Date: Sun, 4 Feb 2018 11:44:22 -0800 Subject: [PATCH] --User changes -Added pixel_flow variation from user bezo97. --- Source/Ember/Ember.cpp | 9 ++++ Source/Ember/Variation.h | 3 ++ Source/Ember/VariationList.cpp | 1 + Source/Ember/VariationsDC.h | 98 ++++++++++++++++++++++++++++++++++ Source/Ember/XmlToEmber.cpp | 7 ++- 5 files changed, 117 insertions(+), 1 deletion(-) diff --git a/Source/Ember/Ember.cpp b/Source/Ember/Ember.cpp index 04f10e7..a2b33a5 100644 --- a/Source/Ember/Ember.cpp +++ b/Source/Ember/Ember.cpp @@ -402,6 +402,13 @@ uint Timing::m_ProcessorCount; EXPORTPREPOSTREGVAR(TileLog, T) \ EXPORTPREPOSTREGVAR(TruchetFill, T) \ EXPORTPREPOSTREGVAR(Waves2Radial, T) \ + EXPORTPREPOSTREGVAR(Panorama1, T) \ + EXPORTPREPOSTREGVAR(Panorama2, T) \ + EXPORTPREPOSTREGVAR(Helicoid, T) \ + EXPORTPREPOSTREGVAR(Helix, T) \ + EXPORTPREPOSTREGVAR(Sphereblur, T) \ + EXPORTPREPOSTREGVAR(Cpow3, T) \ + EXPORTPREPOSTREGVAR(Concentric, T) \ template EMBER_API class PostSmartcropVariation; /*Only implemented as post.*/ \ EXPORTPREPOSTREGVAR(DCBubble, T) \ EXPORTPREPOSTREGVAR(DCCarpet, T) \ @@ -412,6 +419,8 @@ uint Timing::m_ProcessorCount; EXPORTPREPOSTREGVAR(DCPerlin, T) \ EXPORTPREPOSTREGVAR(DCZTransl, T) \ EXPORTPREPOSTREGVAR(DCTriangle, T) \ + EXPORTPREPOSTREGVAR(RandCubes, T) \ + EXPORTPREPOSTREGVAR(PixelFlow, T) \ template EMBER_API class VariationList; \ template EMBER_API class SpatialFilter; \ template EMBER_API class GaussianFilter; \ diff --git a/Source/Ember/Variation.h b/Source/Ember/Variation.h index 78ee52b..0ce7e2a 100644 --- a/Source/Ember/Variation.h +++ b/Source/Ember/Variation.h @@ -268,6 +268,7 @@ enum class eVariationId : et VAR_PHOENIX_JULIA, VAR_PIE , VAR_PIE3D , + VAR_PIXEL_FLOW , VAR_POINCARE , VAR_POINCARE3D , VAR_POLAR , @@ -610,6 +611,7 @@ enum class eVariationId : et VAR_PRE_PHOENIX_JULIA, VAR_PRE_PIE, VAR_PRE_PIE3D, + VAR_PRE_PIXEL_FLOW, VAR_PRE_POINCARE, VAR_PRE_POINCARE3D, VAR_PRE_POLAR, @@ -952,6 +954,7 @@ enum class eVariationId : et VAR_POST_PHOENIX_JULIA, VAR_POST_PIE, VAR_POST_PIE3D, + VAR_POST_PIXEL_FLOW, VAR_POST_POINCARE, VAR_POST_POINCARE3D, VAR_POST_POLAR, diff --git a/Source/Ember/VariationList.cpp b/Source/Ember/VariationList.cpp index 2899ea5..c01b75c 100644 --- a/Source/Ember/VariationList.cpp +++ b/Source/Ember/VariationList.cpp @@ -372,6 +372,7 @@ VariationList::VariationList() ADDPREPOSTREGVAR(DCTriangle) ADDPREPOSTREGVAR(DCZTransl) ADDPREPOSTREGVAR(RandCubes) + ADDPREPOSTREGVAR(PixelFlow) for (auto var : m_Variations) const_cast*>(var)->Precalc();//Modify once here, then const after this. diff --git a/Source/Ember/VariationsDC.h b/Source/Ember/VariationsDC.h index 1e1c1c9..3b86c9b 100644 --- a/Source/Ember/VariationsDC.h +++ b/Source/Ember/VariationsDC.h @@ -1551,6 +1551,103 @@ private: T m_Density; }; +/// +/// pixel_flow. +/// +template +class PixelFlowVariation : public ParametricVariation +{ +public: + PixelFlowVariation(T weight = 1.0) : ParametricVariation("pixel_flow", eVariationId::VAR_PIXEL_FLOW, weight) + { + Init(); + } + + PARVARCOPY(PixelFlowVariation) + + virtual void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand) override + { + T xl, yl; + sincos(m_Rad, &xl, &yl); + auto blockx = (int)Floor(helper.In.x * m_Width);//Calculate which block we're in. + blockx += int(2 - 4 * VarFuncs::Hash(int(blockx * m_Seed + 1)));//Varying width and length. + auto blocky = (int)Floor(helper.In.y * m_Width); + blocky += int(2 - 4 * VarFuncs::Hash(int(blocky * m_Seed + 1))); + T fLen = (VarFuncs::Hash(int(blocky + blockx * -m_Seed)) + VarFuncs::Hash(int(blockx + blocky * m_Seed * T(0.5)))) * T(0.5); //doesnt matter just needs to be random enough + T r01 = rand.Frand01(); + T fade = fLen * r01 * r01 * r01 * r01;//Fading effect. + helper.Out.x = m_Weight * m_Len * xl * fade; + helper.Out.y = m_Weight * m_Len * yl * fade; + helper.Out.z = DefaultZ(helper); + + if (m_EnableDC) + outPoint.m_ColorX = r01;//Direct color. + } + + virtual string OpenCLString() const override + { + ostringstream ss, ss2; + intmax_t i = 0, varIndex = IndexInXform(); + ss2 << "_" << XformIndexInEmber() << "]"; + string index = ss2.str(); + string weight = WeightDefineString(); + string angle = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string len = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string width = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string seed = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string dc = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string rad = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + ss << "\t{\n" + << "\t\treal_t xl, yl;\n" + << "\t\txl = sincos(" << rad << ", &yl);\n" + << "\t\tint blockx = (int)floor(vIn.x * " << width << ");\n" + << "\t\tblockx += (int)(2 - 4 * Hash((int)(blockx * " << seed << " + 1)));\n" + << "\t\tint blocky = (int)floor(vIn.y * " << width << ");\n" + << "\t\tblocky += (int)(2 - 4 * Hash((int)(blocky * " << seed << " + 1)));\n" + << "\t\treal_t fLen = (Hash((int)(blocky + blockx * -" << seed << ")) + Hash((int)(blockx + blocky * " << seed << " * (real_t)0.5))) * (real_t)0.5;\n" + << "\t\treal_t r01 = MwcNext01(mwc);\n" + << "\t\treal_t fade = fLen * r01 * r01 * r01 * r01;\n" + << "\t\tvOut.x = " << weight << " * " << len << " * xl * fade;\n" + << "\t\tvOut.y = " << weight << " * " << len << " * yl * fade;\n" + << "\t\tvOut.z = " << DefaultZCl() + << "\t\tif (" << dc << ")\n" + << "\t\t\toutPoint->m_ColorX = r01;\n" + << "\t}\n"; + return ss.str(); + } + + virtual void Precalc() override + { + m_Rad = m_Angle * DEG_2_RAD_T; + } + + virtual vector OpenCLGlobalFuncNames() const override + { + return vector { "Hash" }; + } + +protected: + void Init() + { + string prefix = Prefix(); + m_Params.clear(); + m_Params.push_back(ParamWithName(&m_Angle, prefix + "pixel_flow_angle", 90)); + m_Params.push_back(ParamWithName(&m_Len, prefix + "pixel_flow_len", T(0.1))); + m_Params.push_back(ParamWithName(&m_Width, prefix + "pixel_flow_width", 200)); + m_Params.push_back(ParamWithName(&m_Seed, prefix + "pixel_flow_seed", 42, eParamType::INTEGER)); + m_Params.push_back(ParamWithName(&m_EnableDC, prefix + "pixel_flow_enable_dc", 0, eParamType::INTEGER, 0, 1)); + m_Params.push_back(ParamWithName(true, &m_Rad, prefix + "pixel_flow_rad")); + } + +private: + T m_Angle; + T m_Len; + T m_Width; + T m_Seed; + T m_EnableDC; + T m_Rad;//Precalc. +}; + MAKEPREPOSTPARVAR(DCBubble, dc_bubble, DC_BUBBLE) MAKEPREPOSTPARVAR(DCCarpet, dc_carpet, DC_CARPET) MAKEPREPOSTPARVARASSIGN(DCCube, dc_cube, DC_CUBE, eVariationAssignType::ASSIGNTYPE_SUM) @@ -1561,4 +1658,5 @@ MAKEPREPOSTPARVAR(DCTriangle, dc_triangle, DC_TRIANGLE) MAKEPREPOSTPARVAR(DCZTransl, dc_ztransl, DC_ZTRANSL) MAKEPREPOSTPARVAR(DCPerlin, dc_perlin, DC_PERLIN) MAKEPREPOSTPARVAR(RandCubes, randCubes, RAND_CUBES) +MAKEPREPOSTPARVARASSIGN(PixelFlow, pixel_flow, PIXEL_FLOW, eVariationAssignType::ASSIGNTYPE_SUM) } diff --git a/Source/Ember/XmlToEmber.cpp b/Source/Ember/XmlToEmber.cpp index 82dc176..dbff28b 100644 --- a/Source/Ember/XmlToEmber.cpp +++ b/Source/Ember/XmlToEmber.cpp @@ -172,7 +172,12 @@ XmlToEmber::XmlToEmber() { "radius", "concentric_radius" }, //{ "density", "concentric_density" },//Can't have two, which means you can never properly paste from Apophysis with both of these in one xform. { "R_blur", "concentric_R_blur" }, - { "Z_blur", "concentric_Z_blur" } + { "Z_blur", "concentric_Z_blur" }, + { "angle", "pixel_flow_angle" }, + { "len", "pixel_flow_len" }, + { "width", "pixel_flow_width" }, + //{ "seed", "pixel_flow_seed" },//randCubes above already uses "seed", but it's just for randomness, so it shouldn't matter. + { "enable_dc", "pixel_flow_enable_dc" } }; m_FlattenNames = {