1/** 2 * Mandelbulber v2, a 3D fractal generator _%}}i*<. ____ _______ 3 * Copyright (C) 2020 Mandelbulber Team _>]|=||i=i<, / __ \___ ___ ___ / ___/ / 4 * \><||i|=>>%) / /_/ / _ \/ -_) _ \/ /__/ /__ 5 * This file is part of Mandelbulber. )<=i=]=|=i<> \____/ .__/\__/_//_/\___/____/ 6 * The project is licensed under GPLv3, -<>>=|><|||` /_/ 7 * see also COPYING file in this folder. ~+{i%+++ 8 * 9 * MandelbulbAbsPower2Iteration 10 * @reference /http://www.fractalforums.com/gallery-b177/buffalo-fractals 11 12 * This file has been autogenerated by tools/populateUiInformation.php 13 * from the file "fractal_mandelbulb_abs_power2.cpp" in the folder formula/definition 14 * D O N O T E D I T T H I S F I L E ! 15 */ 16 17REAL4 MandelbulbAbsPower2Iteration(REAL4 z, __constant sFractalCl *fractal, sExtendedAuxCl *aux) 18{ 19 REAL4 c = aux->const_c; 20 21 // pre rotation 22 if (fractal->transformCommon.rotationEnabled 23 && aux->i >= fractal->transformCommon.startIterationsR 24 && aux->i < fractal->transformCommon.stopIterationsR) 25 { 26 z = Matrix33MulFloat4(fractal->transformCommon.rotationMatrix, z); 27 } 28 // pre-offset 29 if (fractal->transformCommon.functionEnabledDFalse 30 && aux->i >= fractal->transformCommon.startIterationsD 31 && aux->i < fractal->transformCommon.stopIterationsD) 32 { 33 z += fractal->transformCommon.offsetA000; 34 } 35 36 aux->DE = aux->DE * 2.0f * aux->r; 37 38 // pre abs. abs(z.x) and abs(z.y) effect newy. abs(z.z) effects newz 39 if (fractal->buffalo.preabsx) z.x = fabs(z.x); 40 if (fractal->buffalo.preabsy) z.y = fabs(z.y); 41 if (fractal->buffalo.preabsz) z.z = fabs(z.z); 42 43 REAL4 zz = z * z; 44 REAL4 newZ = z; 45 REAL temp = 1.0f - zz.z / (zz.x + zz.y); 46 newZ.x = (zz.x - zz.y) * temp; 47 newZ.y = 2.0f * z.x * z.y * temp; 48 newZ.z = (fractal->buffalo.posz ? 2.0f : -2.0f) * z.z * native_sqrt(zz.x + zz.y); 49 z = newZ; 50 51 z.x = fractal->buffalo.absx ? fabs(z.x) : z.x; 52 z.y = fractal->buffalo.absy ? fabs(z.y) : z.y; 53 z.z = fractal->buffalo.absz ? fabs(z.z) : z.z; 54 55 // offset 56 if (fractal->transformCommon.functionEnabledM 57 && aux->i >= fractal->transformCommon.startIterationsM 58 && aux->i < fractal->transformCommon.stopIterationsM) 59 { 60 z += fractal->transformCommon.offset000; 61 } 62 // rotation 63 if (fractal->transformCommon.functionEnabled 64 && aux->i >= fractal->transformCommon.startIterationsS 65 && aux->i < fractal->transformCommon.stopIterationsS) 66 { 67 z = Matrix33MulFloat4(fractal->mandelbox.mainRot, z); 68 } 69 70 // addCpixel 71 if (fractal->transformCommon.addCpixelEnabledFalse 72 && aux->i >= fractal->transformCommon.startIterationsE 73 && aux->i < fractal->transformCommon.stopIterationsE) 74 { 75 REAL4 tempC = c; 76 if (fractal->transformCommon.alternateEnabledFalse) // alternate 77 { 78 tempC = aux->c; 79 switch (fractal->mandelbulbMulti.orderOfXYZ) 80 { 81 case multi_OrderOfXYZCl_xyz: 82 default: tempC = (REAL4){tempC.x, tempC.y, tempC.z, tempC.w}; break; 83 case multi_OrderOfXYZCl_xzy: tempC = (REAL4){tempC.x, tempC.z, tempC.y, tempC.w}; break; 84 case multi_OrderOfXYZCl_yxz: tempC = (REAL4){tempC.y, tempC.x, tempC.z, tempC.w}; break; 85 case multi_OrderOfXYZCl_yzx: tempC = (REAL4){tempC.y, tempC.z, tempC.x, tempC.w}; break; 86 case multi_OrderOfXYZCl_zxy: tempC = (REAL4){tempC.z, tempC.x, tempC.y, tempC.w}; break; 87 case multi_OrderOfXYZCl_zyx: tempC = (REAL4){tempC.z, tempC.y, tempC.x, tempC.w}; break; 88 } 89 aux->c = tempC; 90 } 91 else 92 { 93 switch (fractal->mandelbulbMulti.orderOfXYZ) 94 { 95 case multi_OrderOfXYZCl_xyz: 96 default: tempC = (REAL4){c.x, c.y, c.z, c.w}; break; 97 case multi_OrderOfXYZCl_xzy: tempC = (REAL4){c.x, c.z, c.y, c.w}; break; 98 case multi_OrderOfXYZCl_yxz: tempC = (REAL4){c.y, c.x, c.z, c.w}; break; 99 case multi_OrderOfXYZCl_yzx: tempC = (REAL4){c.y, c.z, c.x, c.w}; break; 100 case multi_OrderOfXYZCl_zxy: tempC = (REAL4){c.z, c.x, c.y, c.w}; break; 101 case multi_OrderOfXYZCl_zyx: tempC = (REAL4){c.z, c.y, c.x, c.w}; break; 102 } 103 } 104 z += tempC * fractal->transformCommon.constantMultiplier111; 105 } 106 107 // final abs 108 if (fractal->transformCommon.functionEnabledPFalse 109 && aux->i >= fractal->transformCommon.startIterationsH 110 && aux->i < fractal->transformCommon.stopIterationsH) 111 { 112 if (fractal->transformCommon.functionEnabledCxFalse) z.x = fabs(z.x); 113 if (fractal->transformCommon.functionEnabledCyFalse) z.y = fabs(z.y); 114 if (fractal->transformCommon.functionEnabledCzFalse) z.z = fabs(z.z); 115 } 116 117 // Analytic DE tweak 118 if (fractal->analyticDE.enabledFalse) 119 aux->DE = aux->DE * fractal->analyticDE.scale1 + fractal->analyticDE.offset0; 120 return z; 121}