Commit e2b64285 authored by BrutPitt's avatar BrutPitt
Browse files

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

parent 157f6b0d
......@@ -226,7 +226,7 @@ GLuint particlesBaseClass::render(GLuint fbIdx, emitterBaseClass *emitter, bool
glClearBufferfv(GL_DEPTH , 0, &f);
// clear Color buffer
vec4 bkgColor(!isFullScreenPiP ? cPit.getPipBkgrndColor() : backgroundColor());
vec4 bkgColor((!isFullScreenPiP && cPit.getPIPposition()!=cPit.pip::splitView) ? cPit.getPipBkgrndColor() : backgroundColor());
if(!showAxes()) glClearBufferfv(GL_COLOR, 0, value_ptr(bkgColor));
if(blendActive || showAxes()) {
......
......@@ -103,72 +103,83 @@ void AttractorBase::StepAsync(float *&ptr, vec4 &v, vec4 &vp)
{
(this->*stepFn)(v,vp);
std::unique_lock<std::mutex> guard(mut);
*(ptr++) = vp.x;
*(ptr++) = vp.y;
*(ptr++) = vp.z;
*((vec3 *)ptr) = *((vec3 *)&vp);
*(ptr++) = colorFunc(v, vp);
*(ptr+3) = colorFunc(v, vp);
ptr+=4;
v = vp;
//v = vp;
}
void AttractorBase::Step(float *&ptr, vec4 &v, vec4 &vp)
{
(this->*stepFn)(v,vp);
*((vec3 *)ptr) = *((vec3 *)&vp);
*(ptr+3) = colorFunc(v, vp);
ptr+=4;
v = vp;
}
uint32_t AttractorBase::Step(float *ptr, uint32_t numElements)
{
/*
auto f = [&]() {
vec4 v = getCurrent(), vp;
(this->*stepFn)(v,vp);
StepAsync(ptr, v, vp);
};
//std::async(std::launch::async, (void (AttractorBase::*)(float *&, vec4 &, vec4 &v))&AttractorBase::StepAsync, this, ptr, v, vp);
//std::async(std::launch::async, func, ptr, v, vp);
//std::async([&] { f(); });
//f();
std::vector<std::thread> threadsVec;
};
for(int i=0; i<16; i++)
threadsVec.push_back(std::thread(f));
static timerClass t;
for(auto &th: threadsVec) {
if (th.joinable())
th.join();
t.start();
uint32_t computetdElems = 0;
#pragma omp parallel for
for(int32_t elems = numElements; elems>0; elems--) {
f();
computetdElems++;
if(!(computetdElems&0x3F) && t.elapsed()>0.1f) elems = 0;
}
*/
(this->*stepFn)(v,vp);
//Insert(vec4(vp));
return computetdElems;
*/
vec4 v = getCurrent(), vp;
*(ptr++) = vp.x;
*(ptr++) = vp.y;
*(ptr++) = vp.z;
static timerClass t;
*(ptr++) = colorFunc(v, vp);
uint32_t elems = numElements;
t.start();
while(elems--) {
Step(ptr, v, vp);
if(!(elems&0x3F) && t.elapsed()>0.1f) break;
}
v = vp;
Insert(vec4(vp));
return numElements-elems-1;
}
uint32_t AttractorBase::Step(float *ptr, uint32_t numElements)
{
vec4 v = getCurrent(), vp;
/*
vec4 v = getCurrent(), vp;
static timerClass t;
uint32_t elems = numElements;
t.start();
while(elems--) {
Step(ptr, v, vp);
Step(ptr, v, vp);
if(!(elems&0x3F) && t.elapsed()>0.1f) break;
}
Insert(vec4(vp));
return numElements-elems-1;
}
*/
/*
// 4Dim version to test
......@@ -329,17 +340,16 @@ void AttractorBase::searchLyapunov()
////////////////////////////////////////////////////////////////////////////
void volumetricFractals::Step(vec4 &v, vec4 &vp)
{
int i;
do {
i = 0;
vec4 p0(random3Dpoint());
v = p0;// vec4(0.f);
vec4 vx = p0;// vec4(0.f);
for(float val = 0.f; i<maxIter && val<upperLimit; i++) {
val = innerStep(v, vp, p0);
val = innerStep(vx, vp, p0);
}
vp = p0;
} while(i<plotRange.x || i>plotRange.y);
......@@ -348,61 +358,6 @@ void volumetricFractals::Step(vec4 &v, vec4 &vp)
outColor = float(i) / float(maxIter);
}
/*
void volSinRealMandel::Step(vec4 &v, vec4 &vp)
{
int i;
do {
i = 0;
vec4 p0(random3Dpoint());
v = vec4(0.f);
for(float val = 0.f; i<maxIter && val<upperLimit; i++) {
val = dot(vec3(vp), vec3(vp));
v = vp;
}
vp = p0;
} while(i<kMax || (skipConvergent && i>=maxIter));
outColor = float(i) / float(maxIter);
}
void volQuatJulia::Step(vec4 &v, vec4 &vp)
{
int i;
do {
i = 0;
vec4 p0(random3Dpoint());
v = p0;
for(float val = 0.f; i<maxIter && val<upperLimit; i++) {
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;
val = dot(vp, vp);
v = vp + c;
}
vp = p0;
} while(i<kMax || (skipConvergent && i>=maxIter));
outColor = float(i) / float(maxIter);
}
*/
// Attractors Thread helper class
////////////////////////////////////////////////////////////////////////////
......
......@@ -169,6 +169,26 @@ public:
float getInputVMax() { return inputVMax; }
vector<vec4> vVal;
// QuadRays
// http://www.grunch.net/synergetics/quadintro.html
vec3 quad2xyz(const vec4 &quad) {
const float r2 = 0.7071067811865475244; //1.f/sqrt(2.f);
return vec3(r2 * (quad.x - quad.y - quad.z + quad.w),
r2 * (quad.x - quad.y + quad.z - quad.w),
r2 * (quad.x + quad.y - quad.z - quad.w));
}
vec4 xyz2quad(const vec3 p) {
const float r2 = 0.7071067811865475244; //1.f/sqrt(2.f);
vec4 quad(r2 * (p.x>=0 ? p.x : 0 + p.y>=0 ? p.y : 0 + p.z>=0 ? p.z : 0),
r2 * (p.x>=0 ? 0 :-p.x + p.y>=0 ? 0 :-p.y + p.z>=0 ? p.z : 0),
r2 * (p.x>=0 ? 0 :-p.x + p.y>=0 ? p.y : 0 + p.z>=0 ? 0 :-p.z),
r2 * (p.x>=0 ? p.x : 0 + p.y>=0 ? 0 :-p.y + p.z>=0 ? 0 :-p.z));
const float minVal = std::min(quad.x, std::min(quad.y, std::min(quad.z, quad.w)));
for(int i=3; i>=0; i--) quad[i]-=minVal;
return quad;
}
protected:
enum aType { genericTpo, dtTpo, dlaTpo, fractalTpo };
void searchLyapunov();
......
......@@ -102,9 +102,6 @@ void quatJulia_IIM::Step(vec4 &v, vec4 &vp)
mainFunc(v,vp);
}
// stochastic adaptation of P.Nylander's Mathematica formula of quaternion Julia set
// http://bugman123.com/Hypercomplex/index.html
////////////////////////////////////////////////////////////////////////////
......
......@@ -112,7 +112,6 @@ public:
virtual void initStep() {
attractorScalarK::initStep();
}
protected:
};
......@@ -317,4 +316,3 @@ protected:
void Step(vec4 &v, vec4 &vp);
void startData();
};
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