Welcome to Fractal Forums

Fractal Art => Images Showcase (Rate My Fractal) => Topic started by: Buddhi on April 10, 2010, 07:38:15 PM




Title: Depth Of Field test
Post by: Buddhi on April 10, 2010, 07:38:15 PM
I'm playing a little with z-Buffer effects. I have successfully implemented to my program "Depth of Field" effect and "Screen Space Ambient Occlusion". Z-Buffer is really cool :) Bellow there are some examples

Edit: Deep -> Depth
(sorry for mistake)

(http://www.fractalforums.com/gallery/2/640_10_04_10_7_32_07.jpeg)

(http://www.fractalforums.com/gallery/2/640_10_04_10_7_32_48.jpeg)




Title: Re: Deep Of Field test
Post by: knighty on April 10, 2010, 08:48:33 PM
Do you mean "depth of field" or is it the name you've given to it?
Anyway it's awesome! How are you doing it?


Title: Re: Deep Of Field test
Post by: cbuchner1 on April 10, 2010, 08:55:31 PM
Pure awesomeness. Thanks for sharing.

Now all we need is have these algorithms running in real time on GPUs.



Title: Re: Depth Of Field test
Post by: subblue on April 10, 2010, 09:13:06 PM
Very nice. I simulated a crude DOF with a depth buffer pass which worked ok until you have an in focus edge in front of a much further back surface. Yours looks much smoother.


Title: Re: Depth Of Field test
Post by: reesej2 on April 11, 2010, 07:56:21 AM
Wow, looks as though it were taken by an actual camera...


Title: Re: Depth Of Field test
Post by: subblue on April 11, 2010, 09:35:52 AM
Buddhi: I'm interested to know what rules you are using for colouring the surface of the fractal?


Title: Re: Depth Of Field test
Post by: Saquedon on April 11, 2010, 01:29:28 PM
Great this really adds another level... :alien:


Title: Re: Depth Of Field test
Post by: Buddhi on April 11, 2010, 02:50:37 PM
Buddhi: I'm interested to know what rules you are using for colouring the surface of the fractal?

For coloring the surface of Mandelbox fractal I use absolute value from last iteration. For Mandelbulbs the best for me is to use value of minimum distance to the point orbit trap located in {0,0,0} (exactly the same like for fake ambient occlusion).

Below there is the next image with DOF effect

(http://www.fractalforums.com/gallery/2/640_11_04_10_2_44_05.jpeg)


Title: Re: Depth Of Field test
Post by: Buddhi on April 11, 2010, 08:15:18 PM
Next two images:

(http://www.fractalforums.com/gallery/2/640_11_04_10_8_11_32.jpeg)
http://www.fractalforums.com/index.php?action=gallery;sa=view;id=2059

(http://www.fractalforums.com/gallery/2/640_11_04_10_8_12_49.jpeg)
http://www.fractalforums.com/index.php?action=gallery;sa=view;id=2060


Title: Re: Depth Of Field test
Post by: gaston3d on April 11, 2010, 08:23:28 PM

great!

is it z-buffer based gaussian blur?


Title: Re: Depth Of Field test
Post by: Buddhi on April 11, 2010, 08:56:47 PM
is it z-buffer based gaussian blur?

My algorithm is based on z-buffer but this is not typical blur. With normal blurring methods it is nearly impossible to render DOF effect on first image plane. On the edges of near objects it have to blur only nearest object without blurring background. I used something like "reverse blur". In normal blur method we can use for example convolution matrix. Actual point is computed as a weighted sum of adjacent pixels.
In my method z-buffer is sorted form the farthest pixels to the nearest. Next starting form the farthest pixels, each actual pixel is spread to adjacent pixels with proper opacity, according to blur strength and distance form centre pixel. Final effect is nice and rendering is not so slow but now I don't have idea how to use multiple CPUs for rendering this effect. Pixels has to be rendered in proper order and in this case it is difficult to divide operations for many threads.


Title: Re: Depth Of Field test
Post by: knighty on April 11, 2010, 09:09:02 PM
Great effect! These pictures look like they were tooken using a macro lens :)
Thanks for the explanation. I'm eager to see it in the next version of mandelbulber. ;D


Title: Re: Depth Of Field test
Post by: bib on April 11, 2010, 09:29:14 PM
The last two images are particularly striking. Congrats for this feature that really brings a new dimension.


Title: Re: Depth Of Field test
Post by: cbuchner1 on April 11, 2010, 09:32:32 PM
Next two images:

I could imagine playing a 3D space shooter in the innards of this fractal (the second one). Place a few cannons and blasters here and there and bring on the alien ships.


Title: Re: Depth Of Field test
Post by: Buddhi on April 11, 2010, 10:16:17 PM
Links for full resolution images:
http://fc08.deviantart.net/fs71/f/2010/101/4/e/Mandelbox_DOF_by_KrzysztofMarczak.jpg
http://fc05.deviantart.net/fs70/f/2010/101/6/0/Mandelbox_DOF_2_by_KrzysztofMarczak.jpg
http://fc05.deviantart.net/fs70/f/2010/101/5/d/DOF_Test_3_by_KrzysztofMarczak.jpg


Title: Re: Depth Of Field test
Post by: Tglad on April 12, 2010, 04:43:47 AM
The effect is awesome Buddhi!


Title: Re: Depth Of Field test
Post by: aluminumstudios on April 12, 2010, 05:01:10 AM
Very nice.

In photography, as a lens focuses on a further and further object, typically the depth of field increases.  So a shallow depth of field can often imply a close-up or even a macro image of a small object.  You could use this technique very effectively to  create illusions of small scale or very close-up examination.


Title: Re: Depth Of Field test
Post by: cKleinhuis on April 12, 2010, 08:21:39 AM
depth of field is one of my favorite effects for creating realism ( beside global illumination )
it leads the eye through a scene, especially in animations

@buddhi those images have really great impact on me and look amazing !


Title: Re: Depth Of Field test
Post by: David Makin on April 12, 2010, 11:42:20 PM
I was just wondering how to apply depth of field (style) effects without a z-buffer and realised that it should be possible by modifying the dynamic DE threshold adjustment code - will try it......


Title: Re: Depth Of Field test
Post by: Dinkydau on April 13, 2010, 04:25:14 PM
As I said on DeviantART, that's very cool!


Title: Re: Depth Of Field test
Post by: David Makin on April 14, 2010, 01:34:00 AM
An attempt to get results similar to z-buffer based depth of field without a z-buffer by modifying the distance estimator threshold distance based on the distance of the surface from a specified focal distance.
The effect is nice but needs more work to look like true depth of field and will always suffer from the issue of most colouring methods causing the colour to deviate from the "correct" value.
It prompts the idea that using more sophisticated positional variation of the distance threshold could be used to produce nice animation effects - which also prompts the idea that positional variation of other parameters such as the power may also produce interesting results ;)

http://www.youtube.com/watch?v=-uJosDRUcsI (http://www.youtube.com/watch?v=-uJosDRUcsI)


Title: Re: Depth Of Field test
Post by: Buddhi on April 14, 2010, 06:12:16 PM
An attempt to get results similar to z-buffer based depth of field without a z-buffer by modifying the distance estimator threshold distance based on the distance of the surface from a specified focal distance.
The effect is nice but needs more work to look like true depth of field and will always suffer from the issue of most colouring methods causing the colour to deviate from the "correct" value.
It prompts the idea that using more sophisticated positional variation of the distance threshold could be used to produce nice animation effects - which also prompts the idea that positional variation of other parameters such as the power may also produce interesting results ;)

I think it will be difficult to get DOF effect using DE but of course it is possible. You have made first good step with adaptation of distance threshold according to focal distance. But now is bigger problem. Edge of detail which is out of focus should be transparent. It means that when program find edge which should be blur, must remember colour of this element and calculate proper transparency (according to distance to the fractal surface). Next program should still trace ray to find deeper edges (and also remember these) until find solid fractal surface. I hope my explanation is understandable - I still has some problems with my English  :sad1:


Title: Re: Depth Of Field test
Post by: David Makin on April 14, 2010, 07:19:32 PM
An attempt to get results similar to z-buffer based depth of field without a z-buffer by modifying the distance estimator threshold distance based on the distance of the surface from a specified focal distance.
The effect is nice but needs more work to look like true depth of field and will always suffer from the issue of most colouring methods causing the colour to deviate from the "correct" value.
It prompts the idea that using more sophisticated positional variation of the distance threshold could be used to produce nice animation effects - which also prompts the idea that positional variation of other parameters such as the power may also produce interesting results ;)

I think it will be difficult to get DOF effect using DE but of course it is possible. You have made first good step with adaptation of distance threshold according to focal distance. But now is bigger problem. Edge of detail which is out of focus should be transparent. It means that when program find edge which should be blur, must remember colour of this element and calculate proper transparency (according to distance to the fractal surface). Next program should still trace ray to find deeper edges (and also remember these) until find solid fractal surface. I hope my explanation is understandable - I still has some problems with my English  :sad1:

Ideally you'd find "solid" at an extra distance (or distances) on each ray (distance/s based on the focal distance) and compute the colour/lighting for each as well as the original surface point and then merge the values together with weighting based on the distances between them.


Title: Re: Depth Of Field test
Post by: cbuchner1 on April 18, 2010, 10:08:15 PM
My algorithm is based on z-buffer but this is not typical blur. With normal blurring methods it is nearly impossible to render DOF effect on first image plane. On the edges of near objects it have to blur only nearest object without blurring background. I used something like "reverse blur".

I've looked at the source code of your Depth of Field post rendering and I have a few ideas / comments.

I think parallelization is possible by binning the resulting Z buffer values into a limited number of groups, each bin containing only the pixels that have a very similar blur radius.

Then for each group run a separable convolution kernel (e.g. a gaussian blur) on an image containing only the pixels belonging to that group (set all other pixels to black). Separable convolution is reasonably fast, also there is CUDA code available to do it quickly. Instead of a gaussian blur one could also use a disk shaped blur (but that is not separable and requires a more complicated 2D convolution).

The final image would be the simple arithmetic sum of the images for all groups (radius bins). EDIT: I just realized that it is not that easy. For each layer you definitely need an alpha mask as well, and one needs to add them up *in order* (with alpha weighting) from the far to the near plane. So memory requirement is definitely going up.

This could be done nearly in realtime in CUDA, I think. Also on the CPU could be doing this in parallel by computing these pixel groups in different threads. For the final summation the CPU could form tiles that are being processed in parallel.

UPDATE: I came across this article which suggests to use disk shaped convolution kernels instead of gaussian blurs for more realism. The reason being optics:

http://beautifulpixels.blogspot.com/2008/03/higher-fidelity-depth-of-field-effects.html



Title: Re: Depth Of Field test
Post by: Softology on July 02, 2010, 04:25:53 AM
My algorithm is based on z-buffer but this is not typical blur. With normal blurring methods it is nearly impossible to render DOF effect on first image plane. On the edges of near objects it have to blur only nearest object without blurring background. I used something like "reverse blur". In normal blur method we can use for example convolution matrix. Actual point is computed as a weighted sum of adjacent pixels.
In my method z-buffer is sorted form the farthest pixels to the nearest. Next starting form the farthest pixels, each actual pixel is spread to adjacent pixels with proper opacity, according to blur strength and distance form centre pixel. Final effect is nice and rendering is not so slow but now I don't have idea how to use multiple CPUs for rendering this effect. Pixels has to be rendered in proper order and in this case it is difficult to divide operations for many threads.

Nice effect.  I had a go with using the z-buffer for DOF (and Fog).  For the DOF I used a similar method, but without the alpha blended spreading.

1. Sort all pixels by z-buffer depth.
2. Go from farthest to nearest pixels.
3. The new pixel value is taken by averaging the pixel with pixels in front of it in the z-buffer depth.  The radius of the blur grows as it gets further away from the focal point.

This method seems to work fine (and fast) without needing to spread to adjacent pixels and use opacity.

A few samples (right-click View Image to see full resolution)...

(http://farm5.static.flickr.com/4119/4753842054_33a41d9224_o.jpg)

(http://farm5.static.flickr.com/4081/4753859362_7a95bc2135_o.jpg)

(http://farm5.static.flickr.com/4079/4753841894_206fa07de3_o.jpg)

Jason.


Title: Re: Depth Of Field test
Post by: Pauldelbrot on July 02, 2010, 04:47:04 PM
Whoa! What fractal is that last image?


Title: Re: Depth Of Field test
Post by: kram1032 on July 02, 2010, 05:02:27 PM
Those looks great, especially the last one :D

It's one of the 3D Kaleidoscopic IFS, right? :)


Title: Re: Depth Of Field test
Post by: Softology on July 03, 2010, 05:49:11 AM
Yes, the last one is a kaleidoscopic (octo sierpinski) ifs.

Jason.


Title: Re: Depth Of Field test
Post by: Pauldelbrot on July 04, 2010, 12:32:56 AM
Someone ought to try making a "mandelbrot" version of it, so, with the transforms varying from point to point according to some rule.


Title: Re: Depth Of Field test
Post by: Buddhi on July 04, 2010, 08:42:44 AM
Nice effect.  I had a go with using the z-buffer for DOF (and Fog).  For the DOF I used a similar method, but without the alpha blended spreading.

1. Sort all pixels by z-buffer depth.
2. Go from farthest to nearest pixels.
3. The new pixel value is taken by averaging the pixel with pixels in front of it in the z-buffer depth.  The radius of the blur grows as it gets further away from the focal point.

This method seems to work fine (and fast) without needing to spread to adjacent pixels and use opacity.

Jason.

Your DOF effect looks nice. But I'm wondering how it will looks when there will be also foreground out of focus. Like on my images in first post: http://www.fractalforums.com/images-showcase-%28rate-my-fractal%29/deep-of-field-test/msg15608/#msg15608


Title: Re: Depth Of Field test
Post by: eiffie on November 10, 2013, 04:48:04 PM
I think it will be difficult to get DOF effect using DE but of course it is possible. You have made first good step with adaptation of distance threshold according to focal distance. But now is bigger problem. Edge of detail which is out of focus should be transparent. It means that when program find edge which should be blur, must remember colour of this element and calculate proper transparency (according to distance to the fractal surface). Next program should still trace ray to find deeper edges (and also remember these) until find solid fractal surface. I hope my explanation is understandable - I still has some problems with my English  :sad1:

This is exactly what needed to be done! I have been making some attempts at it here:
http://www.fractalforums.com/programming/fast-fake-montecarlo-for-raymarching-(not-sure-what-to-call-it-yet)/ (http://www.fractalforums.com/programming/fast-fake-montecarlo-for-raymarching-(not-sure-what-to-call-it-yet)/)

Wish I had paid more attention to this thread at the time. :)