Logo by blob - 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: Visit the official fractalforums.com Youtube Channel
 
*
Welcome, Guest. Please login or register. April 19, 2024, 04:50:48 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]   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: Help required for a mandelbulb  (Read 2093 times)
Description: trying to render the mandelbulb but not quite there yet
0 Members and 1 Guest are viewing this topic.
pierre
Guest
« on: April 27, 2011, 07:49:59 PM »

Hello everyone,

I'm trying to render the mandelbulb (and other 3d fractals), and I've decided to write a mini ray-casting program from scratch (I figured I'd learn more this way). I haven't got the intention/time/skills to obtain perfect results, but at least I would like my pictures to be a little better than they are at the moment. I thought I'd ask you for help!

Long story short : pictures are okay from a distance, but as you zoom in the details are not quite right. Below I will explain in some detail how I produce the images, but let me show some pictures first. I'm sure the experts on this forum will diagnose the problem at once! (they are 800x800 originally, I'm using links to 400x400 versions from picasa)














So it's not too bad for a start, but it's far from the amazing pictures of the mandelbulb to be found on the forum.

Questions :

(1) Can anyone see straightaway whether the problem is with the way the iterations are computed, with the way the normals are computed, or anything else?

(2) I'm not computing shadows, but the light source is placed at the same position as the camera, so any visible pixel is in the light smiley (Putting the light source anywhere else gives crappy results.) This means I'm only using normals to decide the colour of a given pixel. Other people have done that and obtained better pictures than me... how come? Do you think adding shadows would make a *massive* difference?

(3) I'm not using "subpixel information", again, do you think this would make a real difference?

(4) Also note that on these pictures, I have blurred/smoothed the image by replacing each pixel by the average of its neighbours. If I don't do that, the image is kind of noisy, as on the following example (using different colors just for a change):



Why is that?

I'll reply to this post and give you all the details of the computations, in case that's useful.

Thanks for your help!
Pierre
Logged
pierre
Guest
« Reply #1 on: April 27, 2011, 08:02:20 PM »

So here are some details:

(1) The iterations are performed until we get a point with norm> 2, or until we have iterated 50 times. I've tried other values and nothing much changes.

(2) So for each pixel of the image, I consider a ray through the camera and the pixel. I iterate at two very close points on the ray, and obtain the "distance estimate" (DE) using a formula found on this forum (I think its the one due to David Mankin). I jump along the ray for 0.8*DE (I've tried 0.5 or 0.3, unsurprisingly it improves the picture a bit and slows down the computation). Then I start again. All this until a point (among the two close ones I pick) gives me 50 iterations; I consider this point as "belonging" to the fractal and save its coordinates.

(3) Then I compute normals, using for each pixel the vectors joining the corresponding point to its neighbours (I pick 4, top-left-bottom-right). This gives approximate tangents, I compute cross-products and make an average. That's the normal, and then I compute the (cos of) the angle between this and the vector light-point.
Logged
Syntopia
Fractal Molossus
**
Posts: 681



syntopiadk
WWW
« Reply #2 on: April 27, 2011, 11:48:18 PM »

Here is a few suggestions:
- Search the forums for an analytic DE for the mandelbulb. There are several good ones, and they will be faster then the two-point approximation.
- The DE gives you a distance estimate to the closest part of the object. Just stop when you are closer than a treshold (no need to test if you are less than x iterations)
- Hard shadows will not improve image quality much in my opinion
- Ambient Occlusion approximations (soft shadows) can greatly improve image quality - a quick way is to darken colors based on how many steps was traversed along the ray. Alternatively, sample the DE a number of points along the direction of the normal and use this to estimate how occluded the point is.
- Instead of calculating the normal based on screen space information, calculate the gradient of the DE by sampling it in different directions (e.g. plus/minus x,y,z) and base the normal on this value.
- Anti-alias is very important for high quality images: shoot more rays per pixel and average the results (notice there many sampling and filtering strategies). Or render a hires image and downscale it.
- Consider using another positional light besides the camera light. Use Phong-blinn shading or something similar.

You will also need to color the object somehow. Typically the escape length, or orbit traps (minimum distance to e.g. origo inside the loop) are used to calculate or look-up a color.

Also take a look at Hart's classic paper: http://illinois.academia.edu/JohnCHart/Papers/35145/Ray_tracing_deterministic_3-D_fractals
Logged
pierre
Guest
« Reply #3 on: April 28, 2011, 05:49:16 AM »

hey, thanks! i'll try some of these.

I'm not sure what you mean by 'occluded'. Do you mean that the DE along the normal does not decrease rapidly? (that would be the case if the point is at the end of a long, narrow hole).

I'm surprised that 'hard shadows' are not expected to change things much, but I'll take your word for it.

by the way, i've realized something very simple, by browsing the forum: stopping at 50 iterations is way too much. Stopping at 10 gives much better results! (I've tried the mandelbox, too, and finally got a half-decent picture, stopping around 15 iterations, when 50 or more gives a fuzzy cloud of points).

thanks again!
Logged
Syntopia
Fractal Molossus
**
Posts: 681



syntopiadk
WWW
« Reply #4 on: April 28, 2011, 06:01:16 PM »

I'm not sure what you mean by 'occluded'. Do you mean that the DE along the normal does not decrease rapidly? (that would be the case if the point is at the end of a long, narrow hole).
Yes, if there is no nearby geometry the DE will should be equal to the distance travelled along the normal. Inigo Quilez has a nice description in: http://www.iquilezles.org/www/material/nvscene2008/rwwtt.pdf (near the end)

I'm surprised that 'hard shadows' are not expected to change things much, but I'll take your word for it.

Well, try toggling them in a program such as Mandelbulb3D - I just prefer softer shadings.

by the way, i've realized something very simple, by browsing the forum: stopping at 50 iterations is way too much. Stopping at 10 gives much better results! (I've tried the mandelbox, too, and finally got a half-decent picture, stopping around 15 iterations, when 50 or more gives a fuzzy cloud of points).

Hmm.... For the Mandelbulb 10 iterations is fine, but going up to 50 iterations should not degrade the output. The Mandelbox generally requires more iterations (esp. when zooming in).
Logged
pierre
Guest
« Reply #5 on: April 29, 2011, 09:00:45 PM »


Hmm.... For the Mandelbulb 10 iterations is fine, but going up to 50 iterations should not degrade the output. The Mandelbox generally requires more iterations (esp. when zooming in).


For the mandelbulb, 50 iterations gives me a noisy aspect, as you can see on my last picture, and things are considerably nicer with 10. Down at 5 the mandelbulb appears very smooth indeed (but not detailed enough to be interesting of course...).

For the mandelbox, have a look at http://images.math.cnrs.fr/Mandelbox.html. I'm sorry it's in french, but you'll see from the pictures what happens at least to this one guy when he increases to 25 or 50 iterations: the cube sort of "disappears". I had exactly that same problem. Now down at 10 or 15, at least I can see a cube...

I will work on the soft shadows when I have time (don't know when that will be), I may post a picture of the result.
Logged
Syntopia
Fractal Molossus
**
Posts: 681



syntopiadk
WWW
« Reply #6 on: April 30, 2011, 12:48:50 AM »

Going from 50 to 200 or 300 as max iteration count does not change my images. I tried in Mandelbulb3D and the images are also unaffected there?
Logged
pierre
Guest
« Reply #7 on: May 01, 2011, 08:12:21 AM »

I don't know what going on. The guy on the french site says he's using Ultrafractal (mind you, his examples showing the cube "disappearing" are 2d, so he may have done them differently).

Also, what "escape radius" do you use, for the mandelbox? (i mean the radius that is supposed to be exceeded in less than the max number of iterations). I need to use very large numbers to get a decent picture (like 200), when for the mandelbulb i can use 2 or 4. And the quality of the picture depends on that a lot apparently.

thanks for all your help!
Logged
pierre
Guest
« Reply #8 on: May 02, 2011, 02:51:31 AM »

I did observe one thing. If I detect the object by waiting for the maximal number of iterations to be reached, then what I get depends a lot on the choice of that maximal number (too low is bad, too high is bad).

 If however, I proceed as you suggested and detect the object by the distance estimate being less than something, then I get more or less always the same thing as long as the number is not too low. That's useful, but still the very best pictures I've had were obtained by the first method, choosing the maximal number very finely (lots of tries and errors!)
Logged
Pages: [1]   Go Down
  Print  
 
Jump to:  


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 26 queries. (Pretty URLs adds 0.007s, 2q)