Day before Christmas Eve 1997 I decided to make Java program which would calculate Mandelbrot fractal and write it to povray source file. And after that Povray could render it to picture. I wanted to get some HTML training also, so I wrote this page about this "work".
If you don't know what Mandelbrot fractal is, click here (png image, 640x480x256, 23 kB).
Or visit on my Java applet page and test Mandeli or Mandeli+ -applets.
First version: I drew every calculated point as a simple square-shaped column. When point was close Mandelbrot-set, column was short and vice versa. To make picture more clear, also colors changes with same logic.
Mandel-1 (93 kB)
Result is far too rough (but idea worked anyway!) I tried to use triangles instead columns. I divided picture to small triangles. Then I calculated height of all three corners of triangle and then drew flat triangle between corners and then this same is done to all triangles.
My not-so-fast computer generated "mandel.pov"-file for a long time (and Java really wasn't best language to use in this purpose). Finally "mandel.pov"-file was ready and size of file was a bit over 6 MB. As I guessed, Povray didn't start rendering because my computer ran out of memory.
So I had to use larger triangles than what I first thought to use.
Mandel-3 (52 kB)
Picture looks much more better already but still it's too rough. I had to make triangles smaller, so I decided to not draw those large red areas on outer edge and dark blue Mandelbrot set. Those areas are also generated from those small triangles and so they were real waste of memory.
I wanted to make Mandelbrot set to dark blue, so I created dark blue plane (z=0). Disadvantage of this was that now dark blue color is visible also outside this shape. But that was good enough for me. I also reduced height.
Mandel-4 (57 kB)
Now it began to look good already. Now I got weird idea to put light source inside this shape (near origo, a bit above level z=0).
Mandel-5 (56 kB)
Nice! Now I added another (red) light source. Picture became really mystical:
Mandel-6 (62 kB)
Rendering this two light sources picture took so much time that I started to get bored. I was already used about 6 hours to do Mandelbrot-thing. About 5 hours of this was waiting for computer to finish calculations or rendering. Well, at least I had time to make last-minute Christmas preparations meanwhile.
There's lots of things that could be done better. Camera angle and lights should be adjusted, height differences should be more balanced and triangles should be smaller. However, I should have newer Povray and/or computer to make that last and most important modification come true. (Or then some "hacking" to elude some limitations.) Let it be like that for now.
|www.tiikoni.net/povray/mandelbrot/||Full page map||Copyright © Pasi Laaksonen|