15 local function make_mandelbulb(max_iter, power, texture)
27 -- convert to polar coordinates
28 theta = math.acos(z[3]/r)
29 phi = math.atan(z[2],z[1])
30 dr = math.pow(r, power-1.0)*power*dr + 1.0
32 -- scale and rotate the point
33 zr = math.pow(r ,power)
37 -- convert back to cartesian coordinates
38 z = V.new{math.sin(theta)*math.cos(phi),
39 math.sin(phi)*math.sin(theta),
44 return {dist = 0.5*math.log(r)*r/dr,
50 -- sdf = make_mandelbulb(T.make_count_texture(0.1)),
51 sdf = make_mandelbulb(100, 8,
54 T.make_solid_pigment{0,0.5,1.0},
57 camera = {location = V.new{0,-5,0},
63 Render.bg_col = {0,0,0}
64 Render.render(scene, 640, 480, "out/mandelbulb.ppm")