-
Notifications
You must be signed in to change notification settings - Fork 1
/
Mandelbulb_pwrs1234_ cosmix.frag
286 lines (266 loc) · 5.97 KB
/
Mandelbulb_pwrs1234_ cosmix.frag
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
// cos atan2 Mandelbulb, mix integer powers 1,2,3,4
// z = z^4 + z^3 + z^2 + z + c
// deviated away from work by 3DickUlus and sabine62
// https://fractalforums.org/fractal-mathematics-and-new-theories/28/is-there-a-name-for-this-fractal/2748/msg14759#msg14759
// mclarekin 2/6/19
#info Mandelbulb Distance Estimator
#define providesInit
#include "MathUtils.frag"
#include "DE-Raytracer.frag"
//#include "DE-Kn2cr11.frag"
#group Mandelbulb
// Number of fractal iterations.
uniform int Iterations; slider[0,9,100]
// Number of color iterations.
uniform int ColorIterations; slider[0,9,100]
// Bailout radius
uniform float Bailout; slider[0,5,30]
uniform vec3 RotAngle; slider[(-180,-180,-180),(0,0,0),(180,180,180)]
uniform vec3 JuliaC; slider[(-2,-2,-2),(0,0,0),(2,2,2)]
uniform vec3 cPixelMul; slider[(-2,-2,-2),(0,0,0),(2,2,2)]
uniform bool one; checkbox[true]
uniform bool two; checkbox[true]
uniform bool three; checkbox[true]
uniform bool four; checkbox[true]
uniform vec4 w8ts; slider[(-2,-2,-2,-2),(1,1,1,1),(2,2,2,2)]
uniform float DEoffset; slider[-4,0,4]
mat3 rot;
void init() {
rot = rotationMatrixXYZ(RotAngle);
}
float r;
vec3 sin3(float theta, float phi)
{
float sinth = sin(theta);
return vec3(sinth*cos(phi), sin(phi)*sinth, cos(theta));
}
vec3 powN4(inout vec3 z, float theta, float phi, inout float dr) {
float Rs = r*r*r;
dr = Rs*4.*dr + 1.0;
float zr = Rs*r;
theta = theta*4.;
phi = phi*4.;
z = zr*sin3(theta, phi);
vec3 z4=z;
return z4;
}
vec3 powN3(inout vec3 z, float theta, float phi, inout float dr) {
float Rs = r*r;
dr = Rs*3.*dr + 1.0;
float zr = Rs*r;
theta = theta*3.;
phi = phi*3.;
z = zr*sin3(theta, phi);
vec3 z3=z;
return z3;
}
vec3 powN2(inout vec3 z, float theta, float phi, inout float dr) {
dr = r*2.*dr + 1.0;
float zr = r*r;
theta = theta*2.;
phi = phi*2.;
z = zr*sin3(theta, phi);
vec3 z2=z;
return z2;
}
float DE(vec3 pos) {
vec3 cPixel=pos*cPixelMul;
vec3 z = pos;
r = length(z);
float dr=1.0;
int i=0;
vec3 z1,z2,z3,z4;
vec3 zer0 = vec3(0.0,0.0,0.0);
vec3 zorg2=zer0;
vec3 zorg3=zer0;
vec3 zorg4=zer0;
float dr1 = 0.;
float dr2 = 0.;
float dr3 = 0.;
float dr4 = 0.;
while(r<Bailout && (i<Iterations)) {
float theta = acos(z.z/r);
float phi = atan(z.y,z.x);
if (four)
{
zorg4=z;
dr4 = dr;
powN4(zorg4, theta, phi, dr4);
z4=zorg4;
}
if (three)
{
zorg3=z;
dr3 = dr;
powN3(zorg3, theta, phi, dr3);
z3=zorg3;
}
if (two)
{
zorg2=z;
dr2 = dr;
powN2(zorg2, theta, phi, dr2);
z2=zorg2;
}
if (one)
{
z1=z;
dr1 = r;
}
z = (z1*w8ts.x)+(z2*w8ts.y)+(z3*w8ts.z)+(z4*w8ts.w);
dr =abs((dr1*w8ts.x) + (dr2*w8ts.y)+(dr3*w8ts.z)+(dr4*w8ts.w) + DEoffset);
//z*=rot;
z+= JuliaC + cPixel;
r=length(z);
z *= rot;
if (i<ColorIterations) orbitTrap = min(orbitTrap, abs(vec4(z.x,z.y,z.z,r*r)));
i++;
}
return 0.5*log(r)*r/dr;
}
#preset 24
FOV = 0.4
Eye = 0,-4.28750229,0
Target = 0,3.71250224,0
Up = 0,0,1
EquiRectangular = false
AutoFocus = false
FocalPlane = 1
Aperture = 0
Gamma = 2
ToneMapping = 4
Exposure = 1
Brightness = 1
Contrast = 1
AvgLumin = 0.5,0.5,0.5
Saturation = 1
LumCoeff = 0.212500006,0.715399981,0.0720999986
Hue = 0
GaussianWeight = 1
AntiAliasScale = 2
DepthToAlpha = false
ShowDepth = false
DepthMagnitude = 1
Detail = -3.35502958
DetailAO = 0
FudgeFactor = 0.746710527
MaxDistance = 1000
MaxRaySteps = 2464
Dither = 0.5
NormalBackStep = 1
AO = 0,0,0,0.699999988
Specular = 0.4
SpecularExp = 16
SpecularMax = 10
SpotLight = 1,1,1,0.400000006
SpotLightDir = 0.100000001,0.100000001
CamLight = 1,1,1,1
CamLightMin = 0
Glow = 1,1,1,0
GlowMax = 20
Fog = 0
HardShadow = 0
ShadowSoft = 2
QualityShadows = false
Reflection = 0
DebugSun = false
BaseColor = 0.717647076,1,0.666666687
OrbitStrength = 0.204697986
X = 0.5,0.600000024,0.600000024,0.699999988
Y = 1,0.600000024,0,0.400000006
Z = 0.800000012,0.779999971,1,0.5
R = 0.400000006,0.699999988,1,0.119999997
BackgroundColor = 0.600000024,0.5,0.449999988
GradientBackground = 0.3
CycleColors = false
Cycles = 1.1
EnableFloor = false
FloorNormal = 0,0,1
FloorHeight = 0
FloorColor = 1,1,1
Iterations = 9
ColorIterations = 9
Bailout = 15
RotAngle = 90,90,90
JuliaC = 0,0,0
cPixelMul = 0,0,0
one = false
two = true
three = false
four = true
w8ts = 1,1,1,1
DEoffset = 0
#endpreset
#preset 13
FOV = 0.4
Eye = -0.311673403,-0.491046041,-4.38735676
Target = 0.592350721,1.03523362,6.73156929
Up = 0.002707441,0.990285814,-0.136155322
EquiRectangular = false
AutoFocus = false
FocalPlane = 1
Aperture = 0
Gamma = 2
ToneMapping = 4
Exposure = 1
Brightness = 1
Contrast = 1
AvgLumin = 0.5,0.5,0.5
Saturation = 1
LumCoeff = 0.212500006,0.715399981,0.0720999986
Hue = 0
GaussianWeight = 1
AntiAliasScale = 2
DepthToAlpha = false
ShowDepth = false
DepthMagnitude = 1
Detail = -2.89940828
DetailAO = 0
FudgeFactor = 0.746710527
MaxDistance = 1000
MaxRaySteps = 2464
Dither = 0.5
NormalBackStep = 1
AO = 0,0,0,0.699999988
Specular = 0.4
SpecularExp = 16
SpecularMax = 10
SpotLight = 1,1,1,0.400000006
SpotLightDir = 0.100000001,0.100000001
CamLight = 1,1,1,1
CamLightMin = 0
Glow = 1,1,1,0
GlowMax = 20
Fog = 0
HardShadow = 0
ShadowSoft = 2
QualityShadows = false
Reflection = 0
DebugSun = false
BaseColor = 0.717647076,1,0.666666687
OrbitStrength = 0.204697986
X = 0.5,0.600000024,0.600000024,0.699999988
Y = 1,0.600000024,0,0.400000006
Z = 0.800000012,0.779999971,1,0.5
R = 0.400000006,0.699999988,1,0.119999997
BackgroundColor = 0.600000024,0.5,0.449999988
GradientBackground = 0.3
CycleColors = false
Cycles = 1.1
EnableFloor = false
FloorNormal = 0,0,1
FloorHeight = 0
FloorColor = 1,1,1
Iterations = 9
ColorIterations = 9
Bailout = 5
RotAngle = 0,74.4169611,0
JuliaC = 0,0,0
cPixelMul = 0,0.112956811,0
one = true
two = false
three = true
four = false
w8ts = 1,1,1,1
DEoffset = 0
#endpreset