Welcome to od|forum

Register now to gain access to all of our features. Once registered and logged in, you will be able to contribute to this site by submitting your own content or replying to existing content. You'll be able to customize your profile, receive reputation points as a reward for submitting content, while also communicating with other members via your own private inbox, plus much more! This message will be removed once you have signed in.

# 3d mandelbrot primitive?

25 posts in this topic

http://www.skytopia.com/project/fractal/mandelbulb.html

http://www.skytopia.com/project/fractal/2mandelbulb.html

Just saw that and read through a bit of the forum thread linked off it and wondered if its possible to somehow plug that formula into a object node and get mantra to render similar 3d fractals? I'm really new with houdini so dont even know what to search for, or if its possible. I doubt you can generate the geometry with polygons (even a rough approximation)... it will have to be at render time right?

edit: looks like that site just died from traffic. heres the thread: http://www.fractalforums.com/3d-fractal-generation/true-3d-mandlebrot-type-fractal/

3d vs 2d fractal:

Edited by rende

##### Share on other sites

That's a great goal. I can't wait to see more. If I had more time right now i'd take a stab at it but i'm extremely busy at the moment with other projects. BUT, i'll leave you with a couple resources I'd highly suggest if you're interested in this kind of thing. There is a video from TTC (The Teaching Company) called CHAOS... It's about Chaos Theory. In there there are quite a few chapters on Fractals. Here's the link to it. Another is Arthur C. Clarke - The Colors of Infinity. Then one more is Fractals Mandelbrot Set - M-SET! (I think the other two might be over on YouTube.) Hope they are of some help... (not necessarily so much on the "how to do it in houdini") ways but it's definitely worth watching if you're interested in this kind of thing

Also I know After Effects has a Mandelbrot function that you can use as an effect... You might be able to get more ideas from looking into the way they are using it.

Cheers,

Jonathan

Edited by itriix

##### Share on other sites

That's a great goal. I can't wait to see more. If I had more time right now i'd take a stab at it but i'm extremely busy at the moment with other projects. BUT, i'll leave you with a couple resources I'd highly suggest if you're interested in this kind of thing. There is a video from TTC (The Teaching Company) called CHAOS... It's about Chaos Theory. In there there are quite a few chapters on Fractals. Here's the link to it. Another is Arthur C. Clarke - The Colors of Infinity. Then one more is Fractals Mandelbrot Set - M-SET! (I think the other two might be over on YouTube.) Hope they are of some help... (not necessarily so much on the "how to do it in houdini") ways but it's definitely worth watching if you're interested in this kind of thing

Also I know After Effects has a Mandelbrot function that you can use as an effect... You might be able to get more ideas from looking into the way they are using it.

Cheers,

Jonathan

Thanks for the links. I've written a simple c++ mandelbrot generator ages ago while messing around with pixel plotting libraries and opengl. Just need to figure out how to apply the formula to a 3d container to trace against. Basicly in 2d you just run your screen x/y coord through the formula and you get a value you can use to print a color.

Anyways, out of curiousity I slapped together a python sop and piped in a block of grids to see what will happen. Getting some very funky results, although its slow when you get to ridiculous point counts.

python code:

import math
geo = hou.pwd().geometry()

n = hou.Node.evalParm(hou.pwd(), "nlevel")

for pt in geo.points():
pos = pt.attribValue("P")
x = pos[0]
y = pos[1]
z = pos[2]

r = math.sqrt(x*x + y*y + z*z )
theta = math.atan2(math.sqrt(x*x + y*y) , z)
phi = math.atan2(y,x)

newx = r**n * math.sin(theta*n) * math.cos(phi*n)
newy = r**n * math.sin(theta*n) * math.sin(phi*n)
newz = r**n * math.cos(theta*n)

newpos = (newx, newy, newz)
pt.setPosition(newpos)

Edited by rende

##### Share on other sites

hey, i found another link that might be of very big interest to you

##### Share on other sites

hey rende,

A friend passed me the skytopia... link a couple of days ago. I didn't even realize there was a post about it down here.

I'm pretty interested in this stuff as well, As soon as I find some time, I'll start playin around with this.

thanks for sharing the py code btw.

keep it up

##### Share on other sites

hey rende,

A friend passed me the skytopia... link a couple of days ago. I didn't even realize there was a post about it down here.

I'm pretty interested in this stuff as well, As soon as I find some time, I'll start playin around with this.

thanks for sharing the py code btw.

keep it up

cool. Any ideas on how to generate the geometry? Closest i can think of is to march the points of a grid from the camera towards the surface, but that wont create backfaces etc.. and be very slow. Is there anything in the HDK that can help?

##### Share on other sites

From what i've read on the several links, i think the best approach will be to use voxels in order to represent the formula... I don't know really how to do it, perhaps using a custom vex shader on a iso or sdf volume, cause i think that only mantra could generate the amount of geometry. Or maybe some custom dso...

I'm very interested about what would be the differents approach you might think of guys...

##### Share on other sites

I also saw this and was intrigued.

The simplest way to generate the geometry is just to use a Volume VOP on a blank volume to run a certain number of iterations. Then iso surface the result at the 1.0 contour to get the set at that iteration. The problem, obviously, is memory, running 500^3 to get a nice surface takes a fair bit.

The better way is with a volume shader. To do this, I used a low iteration 200^3 version to get a rough shell for the set so I wouldn't have mantra marching over empty voxels. Then drop the mandelbulb vop generator in.

Note I'm using the slow sin/atan formulation, you'll find a link in the original for a much faster way to compute the 8th power.

The attached file uses the hdk surfacer example rather than convert as it is significantly faster. It also does lots of 500^3 volumes so be careful running it on memory constrained machines.

The images are from using successfully smaller volumes to generate the samples in, thereby cutting away smaller pieces of the set.

mandelbulb_B.hip

mandelbulb.otl

2 people like this

##### Share on other sites

I also saw this and was intrigued.

Awesome! I can't wait to take a look at you're files.

Jonathan

##### Share on other sites

I went to the work of wiring up the non-trig version of the formula and was frustrated when I got different results. I then realized my new results were correct, there was something different happening with the original version I had. The big clue is the lack of north/south symmetry in the above examples.

Attached is mandelbulb otl with the mandelbulb8 version which does the power 8 version without any trig (and correctly) 5 iterations are used.

I've also had enough time for some renders to complete. Treating as a volume with PBR enabled, environment + direct light, 13x13 sampling and 0.001 volume stepsize, I get the attached. (gamma corrected to 2.2) Rendering time is approximately forever (12-18 hours a frame), so for my fly-through I've reverted to ray tracing rather than PBR.

mandelbulb.otl

1 person likes this

##### Share on other sites

Thanks a lot for this Jeff... I was trying to do it with a vex surface shader and was stuck... I got nice results but not what i wanted... Thanks to your file i was able to correct my vex shader... And now it's working great !!! But now i've got some questions for you about how you achieve to replicate the formula inside houdini ::

According to your file you add x to the newx variable and clamp that value. Daniel White's formula on his website is : newx = pow(r,n) * sin(theta*n) * cos(phi*n); and yours is : newx = clamp(pow(r,n) * sin(theta*n) * cos(phi*n) + x, -4, 4); I can figure out for the clamp value but how did you find that you'll have to add x to Daniel's formula... I will be very interested about knowing the way you find out.

And i will look closely to your new otl, to find out how you do without the sin/atan formulation.

I've attached my vex shader for those interested, but i think it's not as efficient as Jeff's files... To use it just create a volume sop with initial values set to {1,1,1} and size to {2,2,2}, and assign the 3dmandelbrot shader (otl) to it. As the basis for this shader is the vex volume cloud shader, don't forget to add shadows in order to see some detail...

nd_3dmandelbrot.otl

Edited by Div

##### Share on other sites

It is a bit confusing because two formulas are given, one for how to compute (x,y,z)^n and another for how to do the actual iteration.

The iteration is always

(nx,ny,nz) = (ox,ox,oy)^n + (x,y,z)

written often as

z = z^n + c

where x,y,z are the original coordinates, the ox,oy,oz the previous iteration value, and nx,ny,nz the new iteration value.

This is why my forumula, which does the full iteration, has the extra +x which isn't on the website where they are only talking about the (x,y,z)^n component.

The clamping is something extra I did for higher iterations. When the point spirals out too far it will keep going to infinity. It does this very, very, quickly with power of 8 and you soon exceed numerical range and get NANs or INFs or other rubbish. To avoid this, I just clamp points when they reach a certain escape threshold. I picked 4 at random as being surely large enough that any point outside the (-4,-4,-4)x(4,4,4) box will surely never reconverge. I didn't see anything on the site as to a proper official value like there is for Mandelbrot sets.

A more efficient idea is to not use a for loop, but a while loop, so you early-exit as soon as you spiral out so as to not have to do all the iterations for trivially rejected points.

##### Share on other sites

I've also had enough time for some renders to complete. Treating as a volume with PBR enabled, environment + direct light, 13x13 sampling and 0.001 volume stepsize, I get the attached. (gamma corrected to 2.2) Rendering time is approximately forever (12-18 hours a frame), so for my fly-through I've reverted to ray tracing rather than PBR.

Beautiful! Once again thanks for sharing!

Cheers,

Jonathan

##### Share on other sites

The low quality fly through is done. No motion blur, 3x3 raytrace with a 0.01 stepsize. 3m30s per frame on the fast machines (53m on slow machines!) Running another render using a 0.001 stepsize to cut the noise which is running 2h per frame so far.

mandelbulb_F.avi

Great work Jeff.

##### Share on other sites

awesome Thought this thread was dead so didn't check back for a while. Thanks for sharing

Edited by rende

##### Share on other sites

Wow, very nice Jeff! The fly through is looking great. Thought about adding some color?

Jonathan

Edited by itriix

##### Share on other sites

megacool work Jeff, thanks for sharing!!!

##### Share on other sites

Thanks a lot Jeff for all your explanations...

##### Share on other sites

Attached is the fly through using shorter volume step size, .001, you'll see that there is a lot less noise. Still hard to see the detail up close because the lighting gets to be so harsh.

Also attached is a PBR render at 2560x1600 with .01 stepsize and 13x13 samples. I've tiled a 23x23 and 0.001 render and put it at lowest priority so I may get a better quality version in a week or two :>

mandelbulb_G.avi

1 person likes this