Commit 78e3583d authored by BrutPitt's avatar BrutPitt
Browse files

ver 1.6.0 WiP - new experiment: 3D/4D fractals (volumetric -> sparse random dots)

parent ff95afa1
......@@ -329,34 +329,26 @@ void AttractorBase::searchLyapunov()
////////////////////////////////////////////////////////////////////////////
void volBedouin::Step(vec4 &v, vec4 &vp)
{
void volumetricFractals::Step(vec4 &v, vec4 &vp)
{
int i;
do {
i = 0;
vec4 p0(random3Dpoint());
v = vec4(0.f);
v = p0;// vec4(0.f);
for(float val = 0.f; i<maxIter && val<upperLimit; i++) {
vp.x = v.x*v.x - v.y*v.y - v.z*v.z + sin(p0.x);
vp.y = 2.f*v.x*v.z + sin(p0.y);
vp.z = 2.f*v.x*v.y + sin(p0.z);
val = dot(vec3(vp), vec3(vp));
v = vp;
val = innerStep(v, vp, p0);
}
vp = p0;
} while(i<kMax || (skipConvergent && i>=maxIter));
} while(i<plotRange.x || i>plotRange.y);
//while(i<skipTop || (whatPlot == skipConvergent && i>=maxIter) || (whatPlot == skipDivergent && i<(maxIter-150)));
outColor = float(i) / float(maxIter);
}
/*
void volSinRealMandel::Step(vec4 &v, vec4 &vp)
{
......@@ -368,9 +360,6 @@ void volSinRealMandel::Step(vec4 &v, vec4 &vp)
for(float val = 0.f; i<maxIter && val<upperLimit; i++) {
vp.x = v.x*v.x + 2.f*v.y*v.z + sin(p0.x);
vp.y = v.z*v.z + 2.f*v.x*v.y + sin(p0.y);
vp.z = v.y*v.y + 2.f*v.x*v.z + sin(p0.z);
val = dot(vec3(vp), vec3(vp));
......@@ -380,8 +369,6 @@ void volSinRealMandel::Step(vec4 &v, vec4 &vp)
vp = p0;
} while(i<kMax || (skipConvergent && i>=maxIter));
outColor = float(i) / float(maxIter);
}
......@@ -389,7 +376,6 @@ void volSinRealMandel::Step(vec4 &v, vec4 &vp)
void volQuatJulia::Step(vec4 &v, vec4 &vp)
{
vec4 c(kVal[0], kVal[1], kVal[2], kVal[3]);
int i;
do {
i = 0;
......@@ -413,7 +399,7 @@ void volQuatJulia::Step(vec4 &v, vec4 &vp)
outColor = float(i) / float(maxIter);
}
*/
......
......@@ -307,10 +307,12 @@ protected:
//--------------------------------------------------------------------------
class volumetricFractals : public attractorScalarK
{
//enum dotPlot { all, skipConvergent, skipDivergent };
public:
volumetricFractals() {
vMin = -1.5; vMax = 1.5; kMin = -1.0; kMax = 1.0;
m_POV = vec3( 0.f, 0, 7.f);
stepFn = (stepPtrFn) &volumetricFractals::Step;
}
virtual inline float colorFunc(const vec4 &v, const vec4 &vp) { return outColor; }
......@@ -322,47 +324,83 @@ public:
fastPrng64.xoshiro256p_Range(sMin.z,sMax.z), 0.f);
}
virtual float innerStep(vec4 &v, vec4 &vp, const vec4 &c) = 0;
protected:
void Step(vec4 &v, vec4 &vp);
int maxIter = 256;
int skipTop = 12;
float upperLimit = 64.f;
float outColor = 0;
vec3 sMin = vec3(-1.f), sMax = vec3(1.0);
bool skipConvergent = true;
vec3 sMin = vec3(-1.5f), sMax = vec3(1.5);
ivec2 plotRange = ivec2(12, 256);
};
class volBedouin : public volumetricFractals
{
public:
volBedouin() { stepFn = (stepPtrFn) &volBedouin::Step; }
inline float innerStep(vec4 &v, vec4 &vp, const vec4 &p0) {
vp.x = v.x*v.x - v.y*v.y - v.z*v.z + sin(p0.x);
vp.y = 2.f*v.x*v.z + sin(p0.y);
vp.z = 2.f*v.x*v.y + sin(p0.z);
v = vp;
return dot(vec3(vp), vec3(vp));
}
protected:
void Step(vec4 &v, vec4 &vp);
void startData();
};
class volRealMandel : public volumetricFractals
{
public:
inline float innerStep(vec4 &v, vec4 &vp, const vec4 &p0) {
vp.x = v.x*v.x - v.y*v.y - v.z*v.z + p0.x;
vp.y = 2.f*v.x*v.y + p0.y;
vp.z = 2.f*v.x*v.z + p0.z;
v = vp;
return dot(vec3(vp), vec3(vp));
}
protected:
void startData();
};
class volSinRealMandel : public volumetricFractals
{
public:
volSinRealMandel() { stepFn = (stepPtrFn) &volSinRealMandel::Step; }
inline float innerStep(vec4 &v, vec4 &vp, const vec4 &p0) {
vp.x = v.x*v.x + 2.f*v.y*v.z + sin(p0.x);
vp.y = v.z*v.z + 2.f*v.x*v.y + sin(p0.y);
vp.z = v.y*v.y + 2.f*v.x*v.z + sin(p0.z);
v = vp;
return dot(vec3(vp), vec3(vp));
}
protected:
void Step(vec4 &v, vec4 &vp);
void startData();
};
class volQuatJulia : public volumetricFractals
{
public:
volQuatJulia() {stepFn = (stepPtrFn) &volQuatJulia::Step; }
inline float innerStep(vec4 &v, vec4 &vp, const vec4 &p0) {
vp.x = v.x*v.x - v.y*v.y - v.z*v.z - v.w*v.w;
vp.y = 2.f*v.x*v.y;
vp.z = 2.f*v.x*v.z;
vp.w = 2.f*v.x*v.w;
v = vp + *((vec4 *)kVal.data());
return dot(v, v);
}
int getPtSize() { return attPt4D; }
protected:
void Step(vec4 &v, vec4 &vp);
void startData();
private:
};
//--------------------------------------------------------------------------
......@@ -659,6 +697,7 @@ public:
PB(glynnJB_IIM , u8"\uf0da", FRACTAL_COLOR , "Glynn JuliaBulb" )
PB(volBedouin , u8"\uf0da", VOLFRAC_COLOR , "Bedouin" )
PB(volRealMandel , u8"\uf0da", VOLFRAC_COLOR , "RealMandel" )
PB(volSinRealMandel , u8"\uf0da", VOLFRAC_COLOR , "SinRealMandel" )
PB(volQuatJulia , u8"\uf0da", VOLFRAC_COLOR , "quatJulia" )
......
......@@ -885,6 +885,15 @@ void volSinRealMandel::startData()
Insert(vVal[0]);
}
void volRealMandel::startData()
{
vVal.push_back(vec4(.1f, -.17f, .7f, 0.f));
kVal.push_back(.1f);
kVal.push_back(-.17f);
kVal.push_back(.7f);
Insert(vVal[0]);
}
void volQuatJulia::startData()
{
......
......@@ -278,14 +278,17 @@ void volumetricFractals::additionalDataCtrls()
const float halfW = ImGui::GetContentRegionAvail().x*.5 - ImGui::GetStyle().ItemSpacing.x;
ImGui::PushItemWidth(halfW);
ImGui::DragFloat3("minVol", value_ptr(sMin), .01f);
ImGui::DragFloat3("##minVol", value_ptr(sMin), .01f);
ImGui::SameLine();
ImGui::DragFloat3("maxVol", value_ptr(sMax), .01f);
ImGui::PopItemWidth();
ImGui::DragFloat3("##maxVol", value_ptr(sMax), .01f);
//ImGui::AlignTextToFramePadding(); ImGui::NewLine();
ImGui::Checkbox(" skip conv", &skipConvergent);
ImGui::DragIntRange2("##range", &plotRange.x, &plotRange.y, .2, 0, maxIter);
//ImGui::Combo("skip dots", (int *) &whatPlot, "plot all dots\0" "skip convergents\0" "skip divergents\0");
//ImGui::Checkbox(" skip conv", &skipConvergent);
ImGui::PopItemWidth();
ImGui::NewLine();
......@@ -294,20 +297,14 @@ void volumetricFractals::additionalDataCtrls()
{
int i = maxIter;
if(ImGui::DragInt("##itr", &i, 1, skipTop, 35000, "Iter: %03d")) {
if(i<skipTop) skipTop = i-1;
if(ImGui::DragInt("##itr", &i, 1, plotRange.x, 35000, "Iter: %03d")) {
if(i<plotRange.x) plotRange.x = i-1;
maxIter = i;
}
}
ImGui::SameLine();
{
int i = skipTop;
if(ImGui::DragInt("##skp", &i, .25, 0, maxIter, "Skip: %03d")) skipTop = i>=maxIter ? maxIter-1 : i;
}
ImGui::SameLine();
ImGui::PopItemWidth();
}
void attractorDtType::additionalDataCtrls()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment