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 * box fold 4D Tglad
10 * This formula contains aux.color
11
12 * This file has been autogenerated by tools/populateUiInformation.php
13 * from the file "fractal_transf_box_fold4d_tglad.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 TransfBoxFold4dTgladIteration(REAL4 z, __constant sFractalCl *fractal, sExtendedAuxCl *aux)
18{
19	REAL4 oldZ = z;
20	REAL4 limit = fractal->transformCommon.offset1111;
21
22	if (!fractal->transformCommon.functionEnabledCyFalse)
23	{
24		z.x = fabs(z.x + limit.x) - fabs(z.x - limit.x) - z.x;
25		z.y = fabs(z.y + limit.y) - fabs(z.y - limit.y) - z.y;
26		z.z = fabs(z.z + limit.z) - fabs(z.z - limit.z) - z.z;
27		z.w = fabs(z.w + limit.w) - fabs(z.w - limit.w) - z.w;
28	}
29	else
30	{
31		if (fractal->transformCommon.functionEnabledAx)
32		{
33			if (aux->i > fractal->transformCommon.startIterationsA)
34			{
35				limit.x *= (1.0f
36										 - 1.0f
37												 / (1.0f
38														+ (aux->i - fractal->transformCommon.startIterationsA)
39																/ fractal->transformCommon.offset0000.x))
40									 * fractal->transformCommon.scale1111.x;
41			}
42			z.x = fabs(z.x + limit.x) - fabs(z.x - limit.x) - z.x;
43		}
44		if (fractal->transformCommon.functionEnabledAy)
45		{
46			if (aux->i > fractal->transformCommon.startIterationsB)
47			{
48				limit.y *= (1.0f
49										 - 1.0f
50												 / (1.0f
51														+ (aux->i - fractal->transformCommon.startIterationsB)
52																/ fractal->transformCommon.offset0000.y))
53									 * fractal->transformCommon.scale1111.y;
54			}
55			z.y = fabs(z.y + limit.y) - fabs(z.y - limit.y) - z.y;
56		}
57		if (fractal->transformCommon.functionEnabledAz)
58		{
59			if (aux->i > fractal->transformCommon.startIterationsB)
60			{
61				limit.z *= (1.0f
62										 - 1.0f
63												 / (1.0f
64														+ (aux->i - fractal->transformCommon.startIterationsC)
65																/ fractal->transformCommon.offset0000.z))
66									 * fractal->transformCommon.scale1111.z;
67			}
68			z.z = fabs(z.z + limit.z) - fabs(z.z - limit.z) - z.z;
69		}
70		if (fractal->transformCommon.functionEnabledAw)
71		{
72			if (aux->i > fractal->transformCommon.startIterationsB)
73			{
74				limit.w *= (1.0f
75										 - 1.0f
76												 / (1.0f
77														+ (aux->i - fractal->transformCommon.startIterationsD)
78																/ fractal->transformCommon.offset0000.w))
79									 * fractal->transformCommon.scale1111.w;
80			}
81			z.w = fabs(z.w + limit.w) - fabs(z.w - limit.w) - z.w;
82		}
83	}
84
85	if (fractal->foldColor.auxColorEnabledFalse)
86	{
87		if (!fractal->transformCommon.functionEnabledCxFalse)
88		{
89			if (z.x != oldZ.x) aux->color += fractal->mandelbox.color.factor4D.x;
90			if (z.y != oldZ.y) aux->color += fractal->mandelbox.color.factor4D.y;
91			if (z.z != oldZ.z) aux->color += fractal->mandelbox.color.factor4D.z;
92			if (z.w != oldZ.w) aux->color += fractal->mandelbox.color.factor4D.w;
93		}
94		else
95		{
96			if (z.x != oldZ.x) aux->color += fractal->mandelbox.color.factor4D.x * (fabs(z.x) - limit.x);
97			if (z.y != oldZ.y) aux->color += fractal->mandelbox.color.factor4D.y * (fabs(z.y) - limit.y);
98			if (z.z != oldZ.z) aux->color += fractal->mandelbox.color.factor4D.z * (fabs(z.z) - limit.z);
99			if (z.w != oldZ.w) aux->color += fractal->mandelbox.color.factor4D.w * (fabs(z.w) - limit.w);
100		}
101	}
102	return z;
103}