top of page
Search
  • Writer's pictureBaldingWizard

Animated Mandelbulb

I've been playing about with changing some of the inputs to the Mandelbulb preset. Here's an example. The expression text to produce this is based on the preset with inputs added to provide an offset to the Theta and Phi angles. For the animation I vary Theta from 0.0 to pi/2 and for Phi from 0.0 to pi/4, making it loopable. The expression used 20 iterations and rendered in about 5 minutes.

Here's the complete expression text :


# Mandelbulb : Generate a Mandelbulb (3d-mandelbrot)

#Define the group for one 'iteration' of the Mandelbulb calculation
group:start(mandelbulbiteration, N, iBlown, Limit, iOffset[], iVector[],ThetaAngleOffset, PhiAngleOffset)

#Split the input vector into x,y,z
_x = iVector[x]
_y = iVector[y]
_z = iVector[z]

#Calculate the coordinates
_r = (_x*_x + _y*_y + _z*_z)**0.5
_theta = atan2((_x*_x+_y*_y)**0.5,_z)+ThetaAngleOffset
_phi = atan2(_y,_x)+PhiAngleOffset

_rn = _r ** N

_newx = _rn * sin(_theta*N) * cos(_phi*N)
_newy = _rn * sin(_theta*N) * sin(_phi*N)
_newz = _rn * cos(_theta*N)

#New distance from centre
_newR = (_newx*_newx + _newy*_newy + _newz*_newz)**0.5

#Determine whether our new point lies outside the sphere
oBlown = or(iBlown, _newR> Limit) 

oVector[] = vadd(combine(_newx, _newy, _newz), iOffset[])
Intensity = _r - _newR

#End the group - the name should match the 'start'
group:end(mandelbulbiteration) 

#-----------------------------------------------------------------------------------------

#Add a group node named 'iteration1', setting the inputs to the group input values
group:add(mandelbulbiteration,iteration1,N{8},0,Limit{2},Input[], Input[])

#Add second group node named iteration2 and linked to the first
group:add(mandelbulbiteration,iteration2,N,group:iteration1[oBlown],Limit,Input[], group:iteration1[oVector],ThetaAngleOffset,PhiAngleOffset)

#Add some more iterations
group:add(mandelbulbiteration,iteration3,N,group:iteration2[oBlown],Limit,Input[], group:iteration2[oVector],ThetaAngleOffset,PhiAngleOffset)
group:add(mandelbulbiteration,iteration4,N,group:iteration3[oBlown],Limit,Input[], group:iteration3[oVector],ThetaAngleOffset,PhiAngleOffset)
group:add(mandelbulbiteration,iteration5,N,group:iteration4[oBlown],Limit,Input[], group:iteration4[oVector],ThetaAngleOffset,PhiAngleOffset)
group:add(mandelbulbiteration,iteration6,N,group:iteration5[oBlown],Limit,Input[], group:iteration5[oVector],ThetaAngleOffset,PhiAngleOffset)
group:add(mandelbulbiteration,iteration7,N,group:iteration6[oBlown],Limit,Input[], group:iteration6[oVector],ThetaAngleOffset,PhiAngleOffset)
group:add(mandelbulbiteration,iteration8,N,group:iteration7[oBlown],Limit,Input[], group:iteration7[oVector],ThetaAngleOffset,PhiAngleOffset)
group:add(mandelbulbiteration,iteration9,N,group:iteration8[oBlown],Limit,Input[], group:iteration8[oVector],ThetaAngleOffset,PhiAngleOffset)
group:add(mandelbulbiteration,iteration10,N,group:iteration9[oBlown],Limit,Input[], group:iteration9[oVector],ThetaAngleOffset,PhiAngleOffset)
group:add(mandelbulbiteration,iteration11,N,group:iteration10[oBlown],Limit,Input[], group:iteration9[oVector],ThetaAngleOffset,PhiAngleOffset)
group:add(mandelbulbiteration,iteration12,N,group:iteration11[oBlown],Limit,Input[], group:iteration9[oVector],ThetaAngleOffset,PhiAngleOffset)
group:add(mandelbulbiteration,iteration13,N,group:iteration12[oBlown],Limit,Input[], group:iteration9[oVector],ThetaAngleOffset,PhiAngleOffset)
group:add(mandelbulbiteration,iteration14,N,group:iteration13[oBlown],Limit,Input[], group:iteration9[oVector],ThetaAngleOffset,PhiAngleOffset)
group:add(mandelbulbiteration,iteration15,N,group:iteration14[oBlown],Limit,Input[], group:iteration9[oVector],ThetaAngleOffset,PhiAngleOffset)
group:add(mandelbulbiteration,iteration16,N,group:iteration15[oBlown],Limit,Input[], group:iteration9[oVector],ThetaAngleOffset,PhiAngleOffset)
group:add(mandelbulbiteration,iteration17,N,group:iteration16[oBlown],Limit,Input[], group:iteration9[oVector],ThetaAngleOffset,PhiAngleOffset)
group:add(mandelbulbiteration,iteration18,N,group:iteration17[oBlown],Limit,Input[], group:iteration9[oVector],ThetaAngleOffset,PhiAngleOffset)
group:add(mandelbulbiteration,iteration19,N,group:iteration18[oBlown],Limit,Input[], group:iteration9[oVector],ThetaAngleOffset,PhiAngleOffset)
group:add(mandelbulbiteration,iteration20,N,group:iteration19[oBlown],Limit,Input[], group:iteration9[oVector],ThetaAngleOffset,PhiAngleOffset)
    
#Define the outputs
Inside = not(group:iteration20[oBlown])
Intensity = group:iteration20[Intensity]



112 views1 comment

Recent Posts

See All
bottom of page