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 * benesi T5
10 * @reference
11 * http://www.fractalforums.com/new-theories-and-research/
12 * do-m3d-formula-have-to-be-distance-estimation-formulas/
13
14 * This file has been autogenerated by tools/populateUiInformation.php
15 * from the file "fractal_transf_benesi_t5b.cpp" in the folder formula/definition
16 * D O    N O T    E D I T    T H I S    F I L E !
17 */
18
19REAL4 TransfBenesiT5bIteration(REAL4 z, __constant sFractalCl *fractal, sExtendedAuxCl *aux)
20{
21	Q_UNUSED(aux);
22
23	REAL tempXZ = z.x * SQRT_2_3_F - z.z * SQRT_1_3_F;
24	z = (REAL4){(tempXZ - z.y) * SQRT_1_2_F, (tempXZ + z.y) * SQRT_1_2_F,
25		z.x * SQRT_1_3_F + z.z * SQRT_2_3_F, z.w};
26
27	// if (z.x > -1e-21f && z.x < 1e-21f)
28	// z.x = (z.x > 0) ? 1e-21f : -1e-21f;
29	// if (z.y > -1e-21f && z.y < 1e-21f)
30	// z.y = (z.y > 0) ? 1e-21f : -1e-21f;
31	// if (z.z > -1e-21f && z.z < 1e-21f)
32	// z.z = (z.z > 0) ? 1e-21f : -1e-21f;
33	REAL4 tempV2 = z;
34	tempV2.x = fabs(native_powr(native_powr(z.y, fractal->transformCommon.int8X)
35																+ native_powr(z.z, fractal->transformCommon.int8X),
36		fractal->transformCommon.power025.x));
37	tempV2.y = fabs(native_powr(native_powr(z.x, fractal->transformCommon.int8Y)
38																+ native_powr(z.z, fractal->transformCommon.int8Y),
39		fractal->transformCommon.power025.y));
40	tempV2.z = fabs(native_powr(native_powr(z.x, fractal->transformCommon.int8Z)
41																+ native_powr(z.y, fractal->transformCommon.int8Z),
42		fractal->transformCommon.power025.z));
43	z = (fabs(tempV2 - fractal->transformCommon.offsetC111)) * fractal->transformCommon.scale3Dd222;
44
45	REAL avgScale = length(z) / length(tempV2);
46	if (fractal->analyticDE.enabled)
47	{
48		aux->DE = aux->DE * avgScale * fractal->analyticDE.scale1 + fractal->analyticDE.offset1;
49	}
50
51	if (fractal->transformCommon.rotationEnabled)
52		z = Matrix33MulFloat4(fractal->transformCommon.rotationMatrix, z);
53
54	tempXZ = (z.y + z.x) * SQRT_1_2_F;
55	z = (REAL4){z.z * SQRT_1_3_F + tempXZ * SQRT_2_3_F, (z.y - z.x) * SQRT_1_2_F,
56		z.z * SQRT_2_3_F - tempXZ * SQRT_1_3_F, z.w};
57	return z;
58}