Skip to content

Commit

Permalink
abox13 color test
Browse files Browse the repository at this point in the history
color tiling test
  • Loading branch information
mclarekin committed Apr 3, 2024
1 parent 973063f commit 4b3669e
Show file tree
Hide file tree
Showing 6 changed files with 735 additions and 61 deletions.
82 changes: 57 additions & 25 deletions mandelbulber2/formula/definition/fractal_abox_mod13.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ void cFractalAboxMod13::FormulaCode(CVector4 &z, const sFractal *fractal, sExten
{
CVector4 c = aux.const_c;
double colorAdd = 0.0;
CVector4 zCol = z;
double rrCol = 0.0;
// invert c
if (fractal->transformCommon.functionEnabledAzFalse
&& aux.i >= fractal->transformCommon.startIterationsE
Expand Down Expand Up @@ -70,34 +72,37 @@ void cFractalAboxMod13::FormulaCode(CVector4 &z, const sFractal *fractal, sExten
z.z = fabs(z.z + fractal->transformCommon.additionConstant111.z)
- fabs(z.z - fractal->transformCommon.additionConstant111.z) - z.z;
}

if (fractal->foldColor.auxColorEnabledFalse)
{
if (z.x != oldZ.x) colorAdd += fractal->mandelbox.color.factor.x;
if (z.y != oldZ.y) colorAdd += fractal->mandelbox.color.factor.y;
if (z.z != oldZ.z) colorAdd += fractal->mandelbox.color.factor.z;
}
}
if (fractal->transformCommon.functionEnabledFalse
&& aux.i >= fractal->transformCommon.startIterationsD
&& aux.i < fractal->transformCommon.stopIterationsD1)
{
CVector4 limit = fractal->transformCommon.additionConstant111;
CVector4 length = 2.0 * limit;
CVector4 tgladS = 1.0 / length;
CVector4 Add = CVector4(0.0, 0.0, 0.0, 0.0);
if (fabs(z.x) < limit.x) Add.x = z.x * z.x * tgladS.x;
if (fabs(z.y) < limit.y) Add.y = z.y * z.y * tgladS.y;
if (fabs(z.z) < limit.z) Add.z = z.z * z.z * tgladS.z;
if (fabs(z.x) > limit.x && fabs(z.x) < length.x)
Add.x = (length.x - fabs(z.x)) * (length.x - fabs(z.x)) * tgladS.x;
if (fabs(z.y) > limit.y && fabs(z.y) < length.y)
Add.y = (length.y - fabs(z.y)) * (length.y - fabs(z.y)) * tgladS.y;
if (fabs(z.z) > limit.z && fabs(z.z) < length.z)
Add.z = (length.z - fabs(z.z)) * (length.z - fabs(z.z)) * tgladS.z;
Add *= fractal->transformCommon.scale3D000;
z.x = (z.x - (sign(z.x) * (Add.x)));
z.y = (z.y - (sign(z.y) * (Add.y)));
z.z = (z.z - (sign(z.z) * (Add.z)));

if (fractal->transformCommon.functionEnabledFalse
&& aux.i >= fractal->transformCommon.startIterationsD
&& aux.i < fractal->transformCommon.stopIterationsD1)
{
CVector4 limit = fractal->transformCommon.additionConstant111;
CVector4 length = 2.0 * limit;
CVector4 tgladS = 1.0 / length;
CVector4 Add = CVector4(0.0, 0.0, 0.0, 0.0);
if (fabs(z.x) < limit.x) Add.x = z.x * z.x * tgladS.x;
if (fabs(z.y) < limit.y) Add.y = z.y * z.y * tgladS.y;
if (fabs(z.z) < limit.z) Add.z = z.z * z.z * tgladS.z;
if (fabs(z.x) > limit.x && fabs(z.x) < length.x)
Add.x = (length.x - fabs(z.x)) * (length.x - fabs(z.x)) * tgladS.x;
if (fabs(z.y) > limit.y && fabs(z.y) < length.y)
Add.y = (length.y - fabs(z.y)) * (length.y - fabs(z.y)) * tgladS.y;
if (fabs(z.z) > limit.z && fabs(z.z) < length.z)
Add.z = (length.z - fabs(z.z)) * (length.z - fabs(z.z)) * tgladS.z;
Add *= fractal->transformCommon.scale3D000;
z.x = (z.x - (sign(z.x) * (Add.x)));
z.y = (z.y - (sign(z.y) * (Add.y)));
z.z = (z.z - (sign(z.z) * (Add.z)));
}
zCol = z;
}
// swap
if (fractal->transformCommon.functionEnabledSwFalse)
Expand All @@ -109,7 +114,7 @@ void cFractalAboxMod13::FormulaCode(CVector4 &z, const sFractal *fractal, sExten
&& aux.i < fractal->transformCommon.stopIterationsS)
{
double rr = z.Dot(z);

rrCol = rr;
z += fractal->mandelbox.offset;

// if (r2 < 1e-21) r2 = 1e-21;
Expand Down Expand Up @@ -217,9 +222,36 @@ void cFractalAboxMod13::FormulaCode(CVector4 &z, const sFractal *fractal, sExten
aux.DE = aux.DE * fractal->analyticDE.scale1
+ fractal->analyticDE.offset0;

// color updated v2.13
if (fractal->foldColor.auxColorEnabled)
// color updated v2.13 and v2.32
if (fractal->foldColor.auxColorEnabled && aux.i >= fractal->foldColor.startIterationsA
&& aux.i < fractal->foldColor.stopIterationsA)
{
if (fractal->foldColor.auxColorEnabledAFalse)
{
colorAdd = 0.0;
if (zCol.x != oldZ.x)
colorAdd += fractal->mandelbox.color.factor.x
* (fabs(zCol.x) - fractal->transformCommon.additionConstant111.x);
if (zCol.y != oldZ.y)
colorAdd += fractal->mandelbox.color.factor.y
* (fabs(zCol.y) - fractal->transformCommon.additionConstant111.y);
if (zCol.z != oldZ.z)
colorAdd += fractal->mandelbox.color.factor.z
* (fabs(zCol.z) - fractal->transformCommon.additionConstant111.z);

if (rrCol < fractal->transformCommon.maxR2d1)
{
if (rrCol < fractal->transformCommon.minR2p25)
colorAdd +=
fractal->mandelbox.color.factorSp1 * (fractal->transformCommon.minR2p25 - rrCol)
+ fractal->mandelbox.color.factorSp2
* (fractal->transformCommon.maxR2d1 - fractal->transformCommon.minR2p25);
else
colorAdd +=
fractal->mandelbox.color.factorSp2 * (fractal->transformCommon.maxR2d1 - rrCol);
}
}

aux.color += colorAdd;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ void cFractalTransfHybridColor2::FormulaCode(
double distL = 0.0;
double newR = 0.0;
double lastVec = 0.0;
double colTiling = 0.0;

// summation of r
if (fractal->transformCommon.functionEnabledMFalse)
Expand Down Expand Up @@ -96,8 +97,46 @@ void cFractalTransfHybridColor2::FormulaCode(
orbitPoints *= fractal->transformCommon.scaleA1;
}


if (fractal->transformCommon.functionEnabledTFalse)
if (fractal->transformCommon.functionEnabledTFalse)
{
// REAL4 tV = 0.0f;
// if (fractal->foldColor.auxColorEnabledA) tV = z;
// else tV = aux->const_c;
// REAL4 tV = aux->const_c * (1.0f - fractal->foldColor.difs0000.w) + z *
//fractal->foldColor.difs0000.w; // x * (1-a) +y * a

double Ax = 2.0 * fractal->transformCommon.scale3D111.x;
double Ay = 2.0 * fractal->transformCommon.scale3D111.y;

double bb = ((z.x + Ax) / Ax) + fractal->transformCommon.additionConstantP000.x;
bb = fabs(bb - round(bb)) * fractal->transformCommon.offsetC111.x;
double cc = ((z.y + Ay) / Ay) + fractal->transformCommon.additionConstantP000.y;
cc = fabs(cc - round(cc)) * fractal->transformCommon.offsetC111.y;
bb = bb + cc;

double dd = ((aux.const_c.x + Ax) / Ax) + fractal->transformCommon.additionConstantP000.x;
dd = fabs(dd - round(dd)) * fractal->transformCommon.offsetC111.x;
double ee = ((aux.const_c.y + Ay) / Ay) + fractal->transformCommon.additionConstantP000.y;
ee = fabs(ee - round(ee)) * fractal->transformCommon.offsetC111.y;
dd = dd + ee;

bb = dd * (1.0 - fractal->foldColor.difs0000.w) + bb * fractal->foldColor.difs0000.w; // mix


colTiling = fractal->foldColor.difs1 * bb;
}








// build componentMaster
componentMaster = (distL + orbitPoints + lastVec + newR);
componentMaster = (distL + orbitPoints + lastVec + newR + colTiling);
componentMaster *= fractal->transformCommon.scale;

if (!fractal->transformCommon.functionEnabledFalse)
Expand Down
80 changes: 55 additions & 25 deletions mandelbulber2/formula/opencl/abox_mod13.cl
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ REAL4 AboxMod13Iteration(REAL4 z, __constant sFractalCl *fractal, sExtendedAuxCl
{
REAL4 c = aux->const_c;
REAL colorAdd = 0.0f;
REAL4 zCol = z;
REAL rrCol = 0.0f;
// invert c
if (fractal->transformCommon.functionEnabledAzFalse
&& aux->i >= fractal->transformCommon.startIterationsE
Expand Down Expand Up @@ -65,28 +67,30 @@ REAL4 AboxMod13Iteration(REAL4 z, __constant sFractalCl *fractal, sExtendedAuxCl
if (z.y != oldZ.y) colorAdd += fractal->mandelbox.color.factor.y;
if (z.z != oldZ.z) colorAdd += fractal->mandelbox.color.factor.z;
}
}
if (fractal->transformCommon.functionEnabledFalse
&& aux->i >= fractal->transformCommon.startIterationsD
&& aux->i < fractal->transformCommon.stopIterationsD1)
{
REAL4 limit = fractal->transformCommon.additionConstant111;
REAL4 length = 2.0f * limit;
REAL4 tgladS = 1.0f / length;
REAL4 Add = (REAL4){0.0f, 0.0f, 0.0f, 0.0f};
if (fabs(z.x) < limit.x) Add.x = z.x * z.x * tgladS.x;
if (fabs(z.y) < limit.y) Add.y = z.y * z.y * tgladS.y;
if (fabs(z.z) < limit.z) Add.z = z.z * z.z * tgladS.z;
if (fabs(z.x) > limit.x && fabs(z.x) < length.x)
Add.x = (length.x - fabs(z.x)) * (length.x - fabs(z.x)) * tgladS.x;
if (fabs(z.y) > limit.y && fabs(z.y) < length.y)
Add.y = (length.y - fabs(z.y)) * (length.y - fabs(z.y)) * tgladS.y;
if (fabs(z.z) > limit.z && fabs(z.z) < length.z)
Add.z = (length.z - fabs(z.z)) * (length.z - fabs(z.z)) * tgladS.z;
Add *= fractal->transformCommon.scale3D000;
z.x = (z.x - (sign(z.x) * (Add.x)));
z.y = (z.y - (sign(z.y) * (Add.y)));
z.z = (z.z - (sign(z.z) * (Add.z)));

if (fractal->transformCommon.functionEnabledFalse
&& aux->i >= fractal->transformCommon.startIterationsD
&& aux->i < fractal->transformCommon.stopIterationsD1)
{
REAL4 limit = fractal->transformCommon.additionConstant111;
REAL4 length = 2.0f * limit;
REAL4 tgladS = 1.0f / length;
REAL4 Add = (REAL4){0.0f, 0.0f, 0.0f, 0.0f};
if (fabs(z.x) < limit.x) Add.x = z.x * z.x * tgladS.x;
if (fabs(z.y) < limit.y) Add.y = z.y * z.y * tgladS.y;
if (fabs(z.z) < limit.z) Add.z = z.z * z.z * tgladS.z;
if (fabs(z.x) > limit.x && fabs(z.x) < length.x)
Add.x = (length.x - fabs(z.x)) * (length.x - fabs(z.x)) * tgladS.x;
if (fabs(z.y) > limit.y && fabs(z.y) < length.y)
Add.y = (length.y - fabs(z.y)) * (length.y - fabs(z.y)) * tgladS.y;
if (fabs(z.z) > limit.z && fabs(z.z) < length.z)
Add.z = (length.z - fabs(z.z)) * (length.z - fabs(z.z)) * tgladS.z;
Add *= fractal->transformCommon.scale3D000;
z.x = (z.x - (sign(z.x) * (Add.x)));
z.y = (z.y - (sign(z.y) * (Add.y)));
z.z = (z.z - (sign(z.z) * (Add.z)));
}
zCol = z;
}
// swap
if (fractal->transformCommon.functionEnabledSwFalse)
Expand All @@ -98,7 +102,7 @@ REAL4 AboxMod13Iteration(REAL4 z, __constant sFractalCl *fractal, sExtendedAuxCl
&& aux->i < fractal->transformCommon.stopIterationsS)
{
REAL rr = dot(z, z);

rrCol = rr;
z += fractal->mandelbox.offset;

// if (r2 < 1e-21f) r2 = 1e-21f;
Expand Down Expand Up @@ -207,9 +211,35 @@ REAL4 AboxMod13Iteration(REAL4 z, __constant sFractalCl *fractal, sExtendedAuxCl
aux->DE = aux->DE * fractal->analyticDE.scale1 + fractal->analyticDE.offset0;

// color updated v2.13
if (fractal->foldColor.auxColorEnabled)
if (fractal->foldColor.auxColorEnabled && aux->i >= fractal->foldColor.startIterationsA
&& aux->i < fractal->foldColor.stopIterationsA)
{
if (fractal->foldColor.auxColorEnabledAFalse)
{
colorAdd = 0.0f;
if (zCol.x != oldZ.x)
colorAdd += fractal->mandelbox.color.factor.x
* (fabs(zCol.x) - fractal->transformCommon.additionConstant111.x);
if (zCol.y != oldZ.y)
colorAdd += fractal->mandelbox.color.factor.y
* (fabs(zCol.y) - fractal->transformCommon.additionConstant111.y);
if (zCol.z != oldZ.z)
colorAdd += fractal->mandelbox.color.factor.z
* (fabs(zCol.z) - fractal->transformCommon.additionConstant111.z);

if (rrCol < fractal->transformCommon.maxR2d1)
{
if (rrCol < fractal->transformCommon.minR2p25)
colorAdd +=
fractal->mandelbox.color.factorSp1 * (fractal->transformCommon.minR2p25 - rrCol)
+ fractal->mandelbox.color.factorSp2
* (fractal->transformCommon.maxR2d1 - fractal->transformCommon.minR2p25);
else
colorAdd +=
fractal->mandelbox.color.factorSp2 * (fractal->transformCommon.maxR2d1 - rrCol);
}
}
aux->color += colorAdd;
}
return z;
}
}
39 changes: 38 additions & 1 deletion mandelbulber2/formula/opencl/transf_hybrid_color2.cl
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ REAL4 TransfHybridColor2Iteration(REAL4 z, __constant sFractalCl *fractal, sExte
REAL distL = 0.0f;
REAL newR = 0.0f;
REAL lastVec = 0.0f;
REAL colTiling = 0.0f;

// summation of r
if (fractal->transformCommon.functionEnabledMFalse)
Expand Down Expand Up @@ -84,8 +85,44 @@ REAL4 TransfHybridColor2Iteration(REAL4 z, __constant sFractalCl *fractal, sExte
orbitPoints *= fractal->transformCommon.scaleA1;
}



if (fractal->transformCommon.functionEnabledTFalse)
{
// REAL4 tV = 0.0f;
// if (fractal->foldColor.auxColorEnabledA) tV = z;
// else tV = aux->const_c;
// REAL4 tV = aux->const_c * (1.0f - fractal->foldColor.difs0000.w) + z *
//fractal->foldColor.difs0000.w; // x * (1-a) +y * a

REAL Ax = 2.0f * fractal->transformCommon.scale3D111.x;
REAL Ay = 2.0f * fractal->transformCommon.scale3D111.y;

REAL bb = ((z.x + Ax) / Ax) + fractal->transformCommon.additionConstantP000.x;
bb = fabs(bb - round(bb)) * fractal->transformCommon.offsetC111.x;
REAL cc = ((z.y + Ay) / Ay) + fractal->transformCommon.additionConstantP000.y;
cc = fabs(cc - round(cc)) * fractal->transformCommon.offsetC111.y;
bb = bb + cc;

REAL dd = ((aux->const_c.x + Ax) / Ax) + fractal->transformCommon.additionConstantP000.x;
dd = fabs(dd - round(dd)) * fractal->transformCommon.offsetC111.x;
REAL ee = ((aux->const_c.y + Ay) / Ay) + fractal->transformCommon.additionConstantP000.y;
ee = fabs(ee - round(ee)) * fractal->transformCommon.offsetC111.y;
dd = dd + ee;

bb = dd * (1.0f - fractal->foldColor.difs0000.w) + bb * fractal->foldColor.difs0000.w; // mix


colTiling = fractal->foldColor.difs1 * bb;
}






// build componentMaster
componentMaster = (distL + orbitPoints + lastVec + newR);
componentMaster = (distL + orbitPoints + lastVec + newR + colTiling);
componentMaster *= fractal->transformCommon.scale;

if (!fractal->transformCommon.functionEnabledFalse)
Expand Down
Loading

0 comments on commit 4b3669e

Please sign in to comment.