ker2x
Fractal Molossus
Posts: 795
|
|
« on: July 27, 2011, 05:34:32 PM » |
|
I'm willing to play with the mandelbulb with code i actually understand (no DE stuff or raymarching or anything). What would be an very simple (possibly short) code to display a mandelbulb please ? something eventually structured like this : for x for y for z iterate end end end thank you edit : if it can be structured like this. what is the code of "iterate" ? -- Keru
|
|
« Last Edit: July 27, 2011, 05:36:33 PM by ker2x »
|
Logged
|
|
|
|
eiffie
Guest
|
|
« Reply #1 on: July 27, 2011, 07:42:25 PM » |
|
This is NOT the way you want to render a mandelbulb (raymarching and DE actually make it easier). But since you ask I will see if I remember it off the top of my head. Replace iterate with:
nx=x ny=y nz=z p=8.0 //order of the bulb r=sqrt(x*x+y*y+z*z) iter=0 while iter<MAX_ITERATIONS && r<2.0 th=atan(y,x)*p ph=asin(z/r)*p r2p=pow(r,p) nx=r2p*cos(ph)*cos(th)+x ny=r2p*cos(ph)*sin(th)+y nz=r2p*sin(ph)+z r=sqrt(x*x+y*y+z*z) iter=iter+1 end while if(iter==MAX_ITERATIONS)then you are "inside" the bulb else you are "outside" the bulb
Now you have to turn your x,y,z coords into 2d screen space, find the normal at each point and color accordingly. This method will be extremely slow.
CAUTION: I may have missed something here as well. Hopefully someone will catch it.
|
|
|
Logged
|
|
|
|
ker2x
Fractal Molossus
Posts: 795
|
|
« Reply #2 on: July 27, 2011, 09:28:42 PM » |
|
This is NOT the way you want to render a mandelbulb (raymarching and DE actually make it easier). But since you ask I will see if I remember it off the top of my head.
Because : - i'm much better at understanding code than formula - i have some idea about doing "something" with that, but i needed to understand that mandelbulb formula (and without all the stuff that is not part of the formula (DE, optimisation, etc)) thank you very much
|
|
|
Logged
|
|
|
|
ker2x
Fractal Molossus
Posts: 795
|
|
« Reply #3 on: July 27, 2011, 10:19:50 PM » |
|
th=atan(y,x)*p is th=atan(y/x)*p, isn't it ?
|
|
|
Logged
|
|
|
|
ker2x
Fractal Molossus
Posts: 795
|
|
« Reply #4 on: July 27, 2011, 11:49:26 PM » |
|
beside the typo stated above and some easily spotted confusion between x/y/z and nx/ny/nz, i can say that the code is correct. My very first experiment at "something" that have 2 name "FlowaBulb" and "DustBulb". Not sure yet. Thoses who know my previous experiments can easily guess what i'm trying to do. And, yes, it's so slow that it hurts Thank you again
|
|
|
Logged
|
|
|
|
ker2x
Fractal Molossus
Posts: 795
|
|
« Reply #5 on: July 27, 2011, 11:55:31 PM » |
|
later ... Yes, a LOT of feature are missing about color, saturation, contrast, brightness, lightning, you-name-it! It no's crashing and it have a mandelbulb shape, it's not that bad then
|
|
|
Logged
|
|
|
|
eiffie
Guest
|
|
« Reply #6 on: July 28, 2011, 05:49:58 PM » |
|
Good you caught that typo. I assume you are already ray-marching thru z until you hit the bulb so why not add DE like this: dr=1.0 inside iterate: dr=dr*p*pow(r,p-1.0)+1.0 after iterate advance z by 0.5*log(r)*r/dr
It will greatly increase the speed and make experimenting with coloring much more enjoyable.
|
|
|
Logged
|
|
|
|
ker2x
Fractal Molossus
Posts: 795
|
|
« Reply #7 on: July 29, 2011, 09:38:00 AM » |
|
Good you caught that typo. I assume you are already ray-marching thru z until you hit the bulb so why not add DE like this: dr=1.0 inside iterate: dr=dr*p*pow(r,p-1.0)+1.0 after iterate advance z by 0.5*log(r)*r/dr
It will greatly increase the speed and make experimenting with coloring much more enjoyable.
I'm rendering 3D buddhabrot (buddhabulb ? i'm tired of mistyping "buddha", that why i call it FlowaBulb ) and not doing raymarching at all. However, i'll probably use DE sooner or later, so thank you for this formula For now my main problem is that i'm not happy with the mandelbulb formula and the "trajectory" of the plots. Simply said : no orbits, just lines. Something is wrong here, and i'm planning to find it
|
|
|
Logged
|
|
|
|
ker2x
Fractal Molossus
Posts: 795
|
|
« Reply #8 on: July 29, 2011, 11:01:20 AM » |
|
Something is wrong here, and i'm planning to find it Found it, and it was in my code. Shame on me
|
|
|
Logged
|
|
|
|
|
|
cKleinhuis
|
|
« Reply #11 on: July 29, 2011, 12:12:12 PM » |
|
the 3d buddha is emerges
|
|
|
Logged
|
---
divide and conquer - iterate and rule - chaos is No random!
|
|
|
ker2x
Fractal Molossus
Posts: 795
|
|
« Reply #12 on: July 29, 2011, 12:21:15 PM » |
|
the 3d buddha is emerges Yes it is ! The holy-holy-grail
|
|
|
Logged
|
|
|
|
A Noniem
|
|
« Reply #13 on: July 29, 2011, 12:38:50 PM » |
|
the 3d buddha is emerges Yes it is ! The holy-holy-grail There are more efficient ways to get the holy grail though.
|
|
|
Logged
|
|
|
|
ker2x
Fractal Molossus
Posts: 795
|
|
« Reply #14 on: July 29, 2011, 12:50:21 PM » |
|
the 3d buddha is emerges Yes it is ! The holy-holy-grail There are more efficient ways to get the holy grail though. I'm sure of it But, to me, the process is as important as the result itself, i want to do it myself (instead of using someone else program) and i start with code i can understand and write then modify to optimize it. (an OpenCL version is, of course, planned)
|
|
|
Logged
|
|
|
|
|