Title: New here Post by: Imagyx on September 21, 2011, 06:49:35 PM Hi. I'm new here and hope to get a little help.
I wrote myself a program to calculate the classic 2D-Mandelbrot years ago and it's gotten bigger and bigger. But I want to try something new and write a program for the 3D-Mandelbulb. I found this forum and hope to find some simple tutorial first, can you help me with that ? Actually I want to write that one in Java, as well as the 2D-program before, which is easy to use and enables me to use full power of all 4 cores. (I don't know how to work with the GPU, I want to try it this way) Greetz@ all people having fun here with fractals & Co. :) Title: Re: New here Post by: Syntopia on September 21, 2011, 09:52:54 PM Yesterday I posted an introduction to rendering the Mandelbulb:
http://blog.hvidtfeldts.net/index.php/2011/09/distance-estimated-3d-fractals-v-the-mandelbulb-different-de-approximations/ It is part 5 of a mini series of posts on distance estimated 3d fractals, so you might want to read the first parts too. Title: Re: New here Post by: Imagyx on September 22, 2011, 12:17:27 AM Thank you a lot, that is exactly what I was hoping to find, but couldn't.
I read through all five parts once and I will reread it again tomorrow. The description seems to be able to lead me to a first simple implementation..(and maybe more) Great work !! When I'm done with that program or any problems appear I will post here again. :) Title: Re: New here Post by: Imagyx on September 22, 2011, 05:35:55 PM I tried to use some of the stuff mentioned in the tutorial, but
it doesn't start from scratch, so I have some problems here: Let me post the actual code first, maybe you can help me with that. I think I don't actually understand where to start. Code:
I think the main problem is the definition of Code: V3D w = new V3D(0,0,0); What is a first correct viewpoint ? E.g. when I want to iterate through the normal 2D-Mandelbrot I start with c between [-3,3]x[-3,3] and get the picture in the middle of my screen. So that's what I mean with a good starting viewpoint. w is the actual z I'm iterating, but I chose w here because x,y,z are already the coordinates of w and I want to avoid something like z.x,z.y,z.z :D Please help me :-\ Title: Re: New here Post by: Syntopia on September 22, 2011, 06:01:17 PM The Mandelbulb is located at the origin of the coordinate system, and has approximately unit radius. For testing you could use this DE:
float DE(vec3 pos) { return length(pos)-1.0; } If you can see a sphere, you should be able to see the Mandelbulb at the same location. For the camera rays, you probably want some kind of perspective projection, but you could start out by mapping the viewport corners from (-2,-2,-2) to (2,2,-2) as start positions, and then ray march at a direction along the positive z-axis. Title: Re: New here Post by: Imagyx on September 22, 2011, 11:37:51 PM I did it !!! :beer:
First the sphere.... (http://nocache-nocookies.digitalgott.com/gallery/8/5672_22_09_11_11_37_10.png) ...and now the mandelbulb: (http://nocache-nocookies.digitalgott.com/gallery/8/5672_22_09_11_11_35_07.png) (I used a colorset from my 2D-program, nice to know I can use all the colorsets from earlier for 3D as well ^-^ ) So thank you very much for your fast help, I think I might be able to do some experiments now. Title: Re: New here Post by: cKleinhuis on September 23, 2011, 01:18:56 AM hello and welcome to the forums ;) !
:beer: :beer: :beer: Title: Re: New here Post by: Imagyx on September 23, 2011, 03:13:28 PM Hello and thank you :)
I have another question now ^^ I managed to get another viewpoint with exchanging axes. I don't have the rays going in a positive z-direction but also the possibility now to go in positive x- or y-direction which gives a new view of the mandelbulb. But how can I rotate freely ? Title: Re: New here Post by: Syntopia on September 23, 2011, 03:35:56 PM Hi, nice to see you got it working!
One way to rotate the Mandelbulb is to simply multiply the argument to the DE-function by a 3D rotation matrix (for instance expressed using Euler angles). But at some point you will need some proper perspective projection. Try searching for 'pinhole camera model' - there must be some tutorials out there. Title: Re: New here Post by: Imagyx on September 23, 2011, 05:09:34 PM Yeah, thanks to your advice and nice tutorials it's finally there :)
The idea with a rotation matrix is a good one, only I didn't know where to apply it ^^ I'm trying step by step, so the rotation first, "pinhole camera" later... let's see where this goes. Title: Re: New here Post by: Imagyx on September 23, 2011, 08:48:12 PM I have a first zoom in that is now possible.
Looks really nice I think. But I still have some problems with rotating, I need more time to understand completely what I actually do there ^-^ Another important question is, how can I get more detail when zooming in. I tried to change different parameters, but I think a parameter-stepping is necessary, am I right there ? So depending on how far I move towards the fractal I need to adjust some of the parameters ? Which would that be? The number of raySteps, the minDistance, the number of iterations in rayStepping ? I tried all of them alone and together, but it got worse. Also the colorchoice doesn't only depend on the number of raySteps alone, right ? Enough so far, more the next days ;D Title: Re: New here Post by: Imagyx on September 26, 2011, 03:36:01 PM I think I understand the effect of the different parameters a little better now.
I post a new rendered picture below which took ~ 200 sec. to render with a resolution of 3000x3000. But I still need to figure out how to rotate freely in my application, so this one is only some positive x-zoom again with different colors, zoomed more deeply. (If you ever wonder, what is he saying ??? I'm not a native english speaker, so correct me if there's something wrong, please, I take no offense :) ) Title: Re: New here Post by: Syntopia on September 26, 2011, 10:30:31 PM Your english in fine - at least to me, but I'm not native english speaking either :-)
Did you try the rotation matrix thing, something like: Code: Matrix3x3 rotationMatrix = Matrix3x3::fromEulerAngles(...); Title: Re: New here Post by: Imagyx on September 27, 2011, 03:23:31 PM That is exactly what I did.
I calculated my rotation matrix as mentioned in http://upload.wikimedia.org/math/d/7/d/d7d24840d643af424de6a73730aea6d9.png on http://en.wikipedia.org/wiki/Rotation_representation_%28mathematics%29 for three angles (each for one axis). It works for one axis, but with the other two angles the mandebulb vanishes from my screen. I think I may know my problem: Code: V3D z = new V3D(origin.xyz); Without rotating the raymarching goes along the z-axis, but with rotation I have to change something here, right ? Code: z.xyz[2] += distance; Title: Re: New here Post by: Syntopia on September 27, 2011, 08:53:39 PM That is exactly what I did. Well, it is not what your code says :-) The idea is to rotate the fractal, and keep the camera fixed. You can do this by applying the rotation inside the DE-function, i.e: put 'z = Draw3D.rotationMatrix.mult(z);' inside the 'DistanceEstimator(...);' function. Title: Re: New here Post by: Imagyx on September 27, 2011, 10:23:57 PM I'm sorry, I thought I did the right thing, but this actually makes more sense now that you say it.
Awesome, at least everthing else I did was right, so that little change was all I needed :embarrass: so close.... Now here's some evidence ^-^ done with 50° rotation for one axis. I really like it and being used to handle the other parameters now as well I think I can take the next step, soft shadowing with some extra rays maybe :hmh: But enough for today. Thanks a lot again!! Title: Re: New here Post by: Imagyx on October 12, 2011, 08:36:12 PM Hey again ^-^
The next step was to try the mandelbox first :D The calculation is faster than the mandelbulb and I really like this one. I wanted to post a video here, but it needs to fit into 256 KB :hmh: , so it doesn't look that nice and is far too short... how can I show the actual video ? (2.5 MB) At least I have a screenshot here... Title: Re: New here Post by: Imagyx on October 16, 2011, 10:51:29 PM Now with much more antialiasing !! That looks a bit better than the first box I think. I see much more potential in the box than in the bulb. There's lots of parameters that are easy to change and provide much more differences in shape. And the shadowing comes naturally ^-^ |