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 Tiling 4d
10
11 * This file has been autogenerated by tools/populateUiInformation.php
12 * from the file "fractal_transf_step_xy.cpp" in the folder formula/definition
13 * D O    N O T    E D I T    T H I S    F I L E !
14 */
15
16REAL4 TransfStepXYIteration(REAL4 z, __constant sFractalCl *fractal, sExtendedAuxCl *aux)
17{
18	REAL4 zc = (z);
19	REAL4 colVec = (REAL4){0.0f, 0.0f, 0.0f, 0.0f};
20	zc *= fractal->transformCommon.scale3D111;
21
22	REAL Step = zc.y - 2.0f * floor(zc.y / 2.0f);
23
24	if (Step > 1.0f)
25	{
26		zc.x += fractal->transformCommon.offset05;
27		colVec.x += 1.0f;
28	}
29	else
30		colVec.y += 1.0f;
31
32	Step = zc.x - 2.0f * floor(zc.x / 2.0f);
33
34	if (Step > 1.0f) colVec.z += 1.0f;
35
36	if (fractal->transformCommon.functionEnabledAxFalse)
37	{
38		zc.x = zc.x - floor(zc.x);
39		zc.y = zc.y - floor(zc.y);
40	}
41	// offset and scale
42	zc.x -= fractal->transformCommon.offsetA05;
43	zc.y -= fractal->transformCommon.offsetB05;
44	zc *= fractal->transformCommon.scale2;
45	aux->DE *= fractal->transformCommon.scale2;
46
47	if (fractal->transformCommon.functionEnabledAy)
48	{
49		REAL4 boxSize = fractal->transformCommon.offset111;
50		zc = fabs(zc) - boxSize;
51		zc.x = max(zc.x, 0.0f);
52		zc.y = max(zc.y, 0.0f);
53		zc.z = max(zc.z, 0.0f);
54		REAL zcd;
55		if (!fractal->transformCommon.functionEnabledAzFalse)
56			zcd = length(zc);
57		else
58			zcd = max(max(zc.x, zc.y), zc.z);
59		zcd -= fractal->transformCommon.offset0;
60
61		aux->dist = min(aux->dist, zcd / (aux->DE + 1.0f));
62	}
63
64	if (fractal->analyticDE.enabled)
65	{
66		if (!fractal->analyticDE.enabledFalse)
67			aux->DE = aux->DE * fractal->analyticDE.scale1 + fractal->analyticDE.offset0;
68		else
69		{
70			aux->DE =
71				aux->DE * length(zc) / length(z) * fractal->analyticDE.scale1 + fractal->analyticDE.offset0;
72		}
73	}
74	if (!fractal->transformCommon.functionEnabledAwFalse) z = zc;
75
76	// aux->color
77	if (fractal->foldColor.auxColorEnabled)
78	{
79		aux->color += fractal->foldColor.difs0000.x * colVec.x;
80		aux->color += fractal->foldColor.difs0000.y * colVec.y;
81		aux->color += fractal->foldColor.difs0000.z * colVec.z;
82	}
83	return z;
84}