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 * knotv2 10 * knot thingy by knighty (2012). Based on an idea by DarkBeam from fractalforums 11 *(http://www.fractalforums.com/new-theories-and-research/not-fractal-but-funny-trefoil-knot-routine/30/) 12 13 * This file has been autogenerated by tools/populateUiInformation.php 14 * from the file "fractal_knot_v2.cpp" in the folder formula/definition 15 * D O N O T E D I T T H I S F I L E ! 16 */ 17 18REAL4 KnotV2Iteration(REAL4 z, __constant sFractalCl *fractal, sExtendedAuxCl *aux) 19{ 20 if (fractal->transformCommon.functionEnabledAxFalse) z.x = fabs(z.x); 21 if (fractal->transformCommon.functionEnabledAyFalse) z.y = fabs(z.y); 22 if (fractal->transformCommon.functionEnabledAzFalse) z.z = fabs(z.z); 23 z += fractal->transformCommon.offset000; 24 25 REAL4 zc = z; 26 REAL tempA = zc.y; 27 REAL tempB = zc.z; 28 if (fractal->transformCommon.functionEnabledJFalse) 29 { 30 REAL temp = tempA; 31 tempA = tempB; 32 tempB = temp; 33 } 34 35 zc.z *= fractal->transformCommon.scaleA1; 36 REAL rxz = native_sqrt(zc.x * zc.x + tempA * tempA); 37 REAL ang = atan2(tempA, zc.x); 38 REAL t = tempB; 39 40 REAL colorDist = 0.0f; 41 for (int n = 0; n < fractal->transformCommon.int3; n++) 42 { 43 zc = (REAL4){rxz, t, ang + M_PI_2x_F * n, 0.0f}; 44 45 zc.x -= fractal->transformCommon.offsetA2; 46 47 REAL ra = 48 zc.z * ((REAL)fractal->transformCommon.int3X) / ((REAL)fractal->transformCommon.int3Z); 49 REAL raz = 50 zc.z * ((REAL)fractal->transformCommon.int8Y) / ((REAL)fractal->transformCommon.int3Z); 51 52 zc.x = 53 zc.x 54 - (fractal->transformCommon.offset1 * native_cos(ra) + fractal->transformCommon.offsetA2); 55 zc.y = 56 zc.y 57 - (fractal->transformCommon.offset1 * native_sin(raz) + fractal->transformCommon.offsetA2); 58 59 aux->DE0 = native_sqrt(zc.x * zc.x + zc.y * zc.y) - fractal->transformCommon.offset01; 60 61 if (fractal->transformCommon.functionEnabledKFalse) aux->DE0 /= aux->DE; 62 63 if (!fractal->transformCommon.functionEnabledDFalse) 64 aux->dist = min(aux->dist, aux->DE0); 65 else 66 aux->dist = aux->DE0; 67 } 68 if (fractal->transformCommon.functionEnabledEFalse) z = zc; 69 70 // aux->color 71 if (fractal->foldColor.auxColorEnabled) 72 { 73 REAL colorAdd = 0.0f; 74 75 if (fmod(ang, 2.0f) < 1.0f) colorAdd += fractal->foldColor.difs0000.x; 76 colorAdd += fractal->foldColor.difs0000.y * (zc.x); 77 colorAdd += fractal->foldColor.difs0000.z * (zc.y); 78 colorAdd += fractal->foldColor.difs0000.w * (zc.z); 79 80 colorAdd += fractal->foldColor.difs1; 81 if (fractal->foldColor.auxColorEnabledA) 82 { 83 if (colorDist != aux->dist) aux->color += colorAdd; 84 } 85 else 86 aux->color += colorAdd; 87 } 88 89 // DE tweak 90 if (fractal->analyticDE.enabledFalse) aux->dist = aux->dist * fractal->analyticDE.scale1; 91 return z; 92}