Jump to content

3d mandelbrot primitive?


rende

Recommended Posts

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:

p5cGk.pngGrbDc.png

Edited by rende
Link to comment
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
Link to comment
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)

uaqkQ.jpg

Ltm0w.jpg

Edited by rende
Link to comment
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 ;)

Link to comment
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?

Link to comment
Share on other sites

  • 2 weeks later...

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...

Link to comment
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

post-3968-125935770142_thumb.png

post-3968-125935786186_thumb.png

post-3968-125935816298_thumb.png

post-3968-125935866842_thumb.png

  • Like 2
Link to comment
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

post-3968-125943827403_thumb.jpg

  • Like 1
Link to comment
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
Link to comment
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.

Link to comment
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

Link to comment
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

post-3968-125954545498_thumb.jpg

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...