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 * spherical fold ABox
10 * from Fractal Forums and M3D
11 * @reference
12 * http://www.fractalforums.com/mandelbulb-3d/custom-formulas-and-transforms-release-t17106/
13 * This formula contains aux.color
14
15 * This file has been autogenerated by tools/populateUiInformation.php
16 * from the file "fractal_transf_spherical_fold_abox.cpp" in the folder formula/definition
17 * D O    N O T    E D I T    T H I S    F I L E !
18 */
19
20REAL4 TransfSphericalFoldAboxIteration(REAL4 z, __constant sFractalCl *fractal, sExtendedAuxCl *aux)
21{
22	REAL r2 = dot(z, z);
23	z += fractal->mandelbox.offset;
24	REAL sqrtMinR = fractal->transformCommon.sqtR;
25	if (r2 < sqrtMinR)
26	{
27		z *= fractal->transformCommon.mboxFactor1;
28		aux->DE *= fractal->transformCommon.mboxFactor1;
29		if (fractal->foldColor.auxColorEnabledFalse)
30		{
31			aux->color += fractal->mandelbox.color.factorSp1;
32		}
33	}
34	else if (r2 < 1.0f)
35	{
36		z *= 1.0f / r2;
37		aux->DE *= 1.0f / r2;
38		if (fractal->foldColor.auxColorEnabledFalse)
39		{
40			aux->color += fractal->mandelbox.color.factorSp2;
41		}
42	}
43	z -= fractal->mandelbox.offset;
44	return z;
45}