Logo by HPDZ - Contribute your own Logo!

END OF AN ERA, FRACTALFORUMS.COM IS CONTINUED ON FRACTALFORUMS.ORG

it was a great time but no longer maintainable by c.Kleinhuis contact him for any data retrieval,
thanks and see you perhaps in 10 years again

this forum will stay online for reference
News: Did you know ? you can use LaTex inside Postings on fractalforums.com!
 
*
Welcome, Guest. Please login or register. April 24, 2024, 11:22:30 AM


Login with username, password and session length


The All New FractalForums is now in Public Beta Testing! Visit FractalForums.org and check it out!


Pages: [1] 2 3 ... 5   Go Down
  Print  
Share this topic on DiggShare this topic on FacebookShare this topic on GoogleShare this topic on RedditShare this topic on StumbleUponShare this topic on Twitter
Author Topic: the simpliest naive bruteforce code for mandelbulb  (Read 15145 times)
0 Members and 2 Guests are viewing this topic.
ker2x
Fractal Molossus
**
Posts: 795


WWW
« 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 smiley

edit : if it can be structured like this. what is the code of "iterate" ? smiley

--
Keru
« Last Edit: July 27, 2011, 05:36:33 PM by ker2x » Logged

often times... there are other approaches which are kinda crappy until you put them in the context of parallel machines
(en) http://www.blog-gpgpu.com/ , (fr) http://www.keru.org/ ,
Sysadmin & DBA @ http://www.over-blog.com/
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


WWW
« 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)) smiley

thank you very much smiley
Logged

often times... there are other approaches which are kinda crappy until you put them in the context of parallel machines
(en) http://www.blog-gpgpu.com/ , (fr) http://www.keru.org/ ,
Sysadmin & DBA @ http://www.over-blog.com/
ker2x
Fractal Molossus
**
Posts: 795


WWW
« 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

often times... there are other approaches which are kinda crappy until you put them in the context of parallel machines
(en) http://www.blog-gpgpu.com/ , (fr) http://www.keru.org/ ,
Sysadmin & DBA @ http://www.over-blog.com/
ker2x
Fractal Molossus
**
Posts: 795


WWW
« 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  sad



Thank you again smiley
Logged

often times... there are other approaches which are kinda crappy until you put them in the context of parallel machines
(en) http://www.blog-gpgpu.com/ , (fr) http://www.keru.org/ ,
Sysadmin & DBA @ http://www.over-blog.com/
ker2x
Fractal Molossus
**
Posts: 795


WWW
« 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 grin

Logged

often times... there are other approaches which are kinda crappy until you put them in the context of parallel machines
(en) http://www.blog-gpgpu.com/ , (fr) http://www.keru.org/ ,
Sysadmin & DBA @ http://www.over-blog.com/
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


WWW
« 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  grin ) and not doing raymarching at all.
However, i'll probably use DE sooner or later, so thank you for this formula smiley

For now my main problem is that i'm not happy with the mandelbulb formula and the "trajectory" of the plots.  sad
Simply said : no orbits, just lines.  cry

Something is wrong here, and i'm planning to find it smiley
Logged

often times... there are other approaches which are kinda crappy until you put them in the context of parallel machines
(en) http://www.blog-gpgpu.com/ , (fr) http://www.keru.org/ ,
Sysadmin & DBA @ http://www.over-blog.com/
ker2x
Fractal Molossus
**
Posts: 795


WWW
« Reply #8 on: July 29, 2011, 11:01:20 AM »

Something is wrong here, and i'm planning to find it smiley

Found it, and it was in my code.
Shame on me  cry
Logged

often times... there are other approaches which are kinda crappy until you put them in the context of parallel machines
(en) http://www.blog-gpgpu.com/ , (fr) http://www.keru.org/ ,
Sysadmin & DBA @ http://www.over-blog.com/
ker2x
Fractal Molossus
**
Posts: 795


WWW
« Reply #9 on: July 29, 2011, 11:37:17 AM »

And i think to myself ... What a wonderfull wooooooorld !  whistling and rolling eyes

Logged

often times... there are other approaches which are kinda crappy until you put them in the context of parallel machines
(en) http://www.blog-gpgpu.com/ , (fr) http://www.keru.org/ ,
Sysadmin & DBA @ http://www.over-blog.com/
ker2x
Fractal Molossus
**
Posts: 795


WWW
« Reply #10 on: July 29, 2011, 11:42:46 AM »

Logged

often times... there are other approaches which are kinda crappy until you put them in the context of parallel machines
(en) http://www.blog-gpgpu.com/ , (fr) http://www.keru.org/ ,
Sysadmin & DBA @ http://www.over-blog.com/
cKleinhuis
Administrator
Fractal Senior
*******
Posts: 7044


formerly known as 'Trifox'


WWW
« Reply #11 on: July 29, 2011, 12:12:12 PM »

the 3d buddha is emerges wink
Logged

---

divide and conquer - iterate and rule - chaos is No random!
ker2x
Fractal Molossus
**
Posts: 795


WWW
« Reply #12 on: July 29, 2011, 12:21:15 PM »

the 3d buddha is emerges wink

Yes it is ! love
The holy-holy-grail  angel
Logged

often times... there are other approaches which are kinda crappy until you put them in the context of parallel machines
(en) http://www.blog-gpgpu.com/ , (fr) http://www.keru.org/ ,
Sysadmin & DBA @ http://www.over-blog.com/
A Noniem
Alien
***
Posts: 38


« Reply #13 on: July 29, 2011, 12:38:50 PM »

the 3d buddha is emerges wink

Yes it is ! love
The holy-holy-grail  angel

There are more efficient ways to get the holy grail though.
Logged
ker2x
Fractal Molossus
**
Posts: 795


WWW
« Reply #14 on: July 29, 2011, 12:50:21 PM »

the 3d buddha is emerges wink

Yes it is ! love
The holy-holy-grail  angel

There are more efficient ways to get the holy grail though.

I'm sure of it  grin
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

often times... there are other approaches which are kinda crappy until you put them in the context of parallel machines
(en) http://www.blog-gpgpu.com/ , (fr) http://www.keru.org/ ,
Sysadmin & DBA @ http://www.over-blog.com/
Pages: [1] 2 3 ... 5   Go Down
  Print  
 
Jump to:  

Related Topics
Subject Started by Replies Views Last post
I arrive, and I come with code. Meet & Greet CraigM 3 1632 Last post January 16, 2009, 12:13:07 PM
by Cyclops
some code Mandelbulb 3d Jesse 7 3090 Last post August 15, 2011, 10:27:15 PM
by Jesse
Break the code Fractal Humor KRAFTWERK 11 7190 Last post November 25, 2011, 05:27:04 PM
by cKleinhuis
Mandelbulb Source Code? Programming neosettler 5 5588 Last post April 14, 2015, 11:38:51 AM
by DarkBeam
Set S of S: Simpliest location, eXtreme Depth. Images Showcase (Rate My Fractal) SeryZone 4 1489 Last post October 31, 2014, 08:52:09 PM
by SeryZone

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines

Valid XHTML 1.0! Valid CSS! Dilber MC Theme by HarzeM
Page created in 0.15 seconds with 24 queries. (Pretty URLs adds 0.014s, 2q)