Welcome to Fractal Forums

Fractal Software => Programming => Topic started by: Owl on July 02, 2012, 09:02:11 AM




Title: simple code for mandelbox
Post by: Owl on July 02, 2012, 09:02:11 AM
hello,
i'm new here and like few others i understand code better than math formulas :)
i'm trying to generate mandelbox in houdini(www.sidefx.com) but i'm stuck, i've made mandelbulb which if i get it correctly, looks like this:
(http://img269.imageshack.us/img269/2736/mandelbulb.jpg) (http://imageshack.us/photo/my-images/269/mandelbulb.jpg/)

and on code looks like:

Code:
p0[xyz] = p[xyz]      //point position
n = 8       // power
itter = 15 // number of iterations

for (i=0, i<itter, i++){
 p[xyz] => sp[r theta phi]  // to spherical
 r= pow(r, n)
 theta = theta * 8
 phi = phi * 8
 sp[r theta phi] => p[xyz] // back to cartesian
 p[xyz] = p[xyz] + p0[xyz]
}

i'm using original sample position as c which seems to give correct results, am i right?

And, i think, i get folding too.
(this one is from wiki)
Code:
function iterate(z):
    for each component in z:
        if component > 1:
            component := 2 - component
        else if component < -1:
            component := -2 - component

    if magnitude of z < 0.5:
        z := z * 4
    else if magnitude of z < 1:
        z := z / (magnitude of z)^2
   
    z := scale * z + c


what i don't get, is how to put it together? mandelbox is mandelbrot folded into a box, right?

they both have loops/iterations should i do mandelbulb and then fold it?
or is it one step of folding + step mandelbulb? (i think i've tried it too)

I've found lots of examples and snippets of code, but it still doesn't work :/ i'm probably missing something obvious.

P.S. If anyone is interested in houdini version of mandelbulb i'm attaching the file
and will defenately do so with mandelbox after i get it :)


Title: Re: simple code for mandelbox
Post by: Syntopia on July 02, 2012, 10:09:18 AM
Look nice, your rendering. How fast is it to render an image like that? Using a raytracer such as Houdini, without any DE optimization must be very slow, right?

i'm using original sample position as c which seems to give correct results, am i right?

Yes. You can also use a fixed constant, which will give you a JuliaBox / JuliaBulb.

Wrt to the Mandelbox: It is not directly related to the Mandelbulb, and you shouldn't mix code. The formula you wrote should be all you need: iterate the function, and check if the magnitude of z becomes larger than some threshold. Use scale=2 for testing.


Title: Re: simple code for mandelbox
Post by: Owl on July 02, 2012, 10:36:48 AM
thanks, for a quick reply

well i'm using volumes so generation of the bulb takes ~ 1 min 500x500x500 voxel container so its 500^3 samples per iteration
and rendering 29 sec.

just to clarify - houdini is a 3d software, i use mantra (render engine in houdini), this render is done with micro polygons and shadow maps, thou i could try to ray trace it eventually :)
(they have a free non-commercial version if someone is interested)

will, come back with results :)


Title: Re: simple code for mandelbox
Post by: KRAFTWERK on July 02, 2012, 11:20:43 AM
WOW, I love the fury look of your bulb... Might try out houdini some day...


Title: Re: simple code for mandelbox
Post by: Owl on July 02, 2012, 12:04:11 PM
and it works! (dont know what i did wrong the firs time, but now it ok :)
(http://img515.imageshack.us/img515/2268/mandelbox.jpg) (http://imageshack.us/photo/my-images/515/mandelbox.jpg/)
its a lot noisier than mandelbulb... now its probably time to look for optimization posibilities, but since its not a ray cast, i'm not sure whether same methods apply.

its furry because its a volume like a cloud, so it looks softier :)

and a scene file as promised ;)


Title: Re: simple code for mandelbox
Post by: ker2x on July 05, 2012, 04:04:24 PM
fluffy \o/  ;D

i really really like houdini, it's an awesome software.
I only have the "apprentice" edition. Houdini being, afaik, the most expensive 3D software ever :)
Do you know if i can do that using the Apprentice edition ?
thank you


Title: Re: simple code for mandelbox
Post by: Owl on July 06, 2012, 10:50:36 AM
fluffy \o/  ;D

i really really like houdini, it's an awesome software.
I only have the "apprentice" edition. Houdini being, afaik, the most expensive 3D software ever :)
Do you know if i can do that using the Apprentice edition ?
thank you

It is expensive and it offers so much :D
Yes sure you can, you can take my sceene an start with it, i've moved it to cvex (render time calculation :) ) so look for it in SHOP context
Haven't done colors yet, how do you calculate them? based a ramp values based on a resulting vector magnitude?

anyway here's the scene, otl, and a new image :)
Full ray trace, 11 min 27 sec
(http://s14.postimage.org/bvt19b5rl/mandelbox_rt.jpg)

somehow i can't upload hip file, so i'm putting it online and just dropping a link :)
http://www64.zippyshare.com/v/85035747/file.html

 


Title: Re: simple code for mandelbox
Post by: Syntopia on July 06, 2012, 11:27:26 AM
Looks great, but I can't understand the rounded corners - I don't think they are a consequence of the volumetric rendering.

Do you have some kind of escape conditions (like: if (length(z)>10.0) break;)? You might want to raise the bailout value a bit (to at least 10.0).
 



Title: Re: simple code for mandelbox
Post by: Owl on July 17, 2012, 09:39:23 AM
probably the scale was to big i had a container of 6x6x6
here is a 4x4x4
https://vimeo.com/45886560


Title: Re: simple code for mandelbox
Post by: zephmann on September 06, 2012, 06:28:14 PM
Cool stuff!

Here is a link to a similar thread over at odforce about creating Mandelbulbs in Houdini, including some scene files from Jeff Lait, who is one of the senior mathematicians at Side Effects.

http://forums.odforce.net/index.php?/topic/10207-3d-mandelbrot-primitive/


Title: Re: simple code for mandelbox
Post by: faxingberlin on July 28, 2016, 12:57:34 PM
It is expensive and it offers so much :D
Yes sure you can, you can take my sceene an start with it, i've moved it to cvex (render time calculation :) ) so look for it in SHOP context
Haven't done colors yet, how do you calculate them? based a ramp values based on a resulting vector magnitude?

anyway here's the scene, otl, and a new image :)
Full ray trace, 11 min 27 sec
(http://s14.postimage.org/bvt19b5rl/mandelbox_rt.jpg)

somehow i can't upload hip file, so i'm putting it online and just dropping a link :)
http://www64.zippyshare.com/v/85035747/file.html

 

Looks really awesome!

i can't access uploaded hip file (http://www64.zippyshare.com/v/85035747/file.html)

Could you upload again?