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 * transfDIFSGridIteration  fragmentarium code, mdifs by knighty (jan 2012)
10 * and  Buddhi
11
12 * This file has been autogenerated by tools/populateUiInformation.php
13 * from the file "fractal_transf_difs_grid.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 TransfDIFSGridIteration(REAL4 z, __constant sFractalCl *fractal, sExtendedAuxCl *aux)
18{
19	REAL4 zc = z;
20
21	REAL size = fractal->transformCommon.scale1;
22	REAL grid = 0.0f;
23
24	zc.z /= fractal->transformCommon.scaleF1;
25
26	if (fractal->transformCommon.rotationEnabled)
27	{
28		zc = Matrix33MulFloat4(fractal->transformCommon.rotationMatrix, zc);
29	}
30
31	REAL xFloor = fabs(zc.x - size * floor(zc.x / size + 0.5f));
32	REAL yFloor = fabs(zc.y - size * floor(zc.y / size + 0.5f));
33	REAL gridXY = min(xFloor, yFloor);
34
35	if (!fractal->transformCommon.functionEnabledJFalse)
36		grid = native_sqrt(gridXY * gridXY + zc.z * zc.z);
37	else
38		grid = max(fabs(gridXY), fabs(zc.z));
39
40	aux->dist = min(aux->dist, (grid - fractal->transformCommon.offset0005) / (aux->DE + 1.0f));
41	return z;
42}