A new technique: Area based depth of field blur

Started by
6 comments, last by Oogst 9 years, 6 months ago

For Cello Fortress I came up with a new technique for Depth of Field blur: area based. (Or at least: as far as I know it is a new technique...) The idea is quite simple so I have written a blogpost explaining how it works:

Area based depth of field blur

Here's a short summary of the idea (more the details and high-res images at the link):

Area-based%20DoF%20-%20Pure%20depth%20ba

Area-based%20DoF%20-%20Wanted%20sharp%20

Area-based%20DoF%20-%20Area-based.jpg

This concept can also be applied to other shapes than boxes. For example, you can also have a sphere within which everything is sharp, while everything outside that sphere is blurred. One can even have several such spheres. How about a visual style where everything is blurred except for the areas around the characters? I think some other interesting visual styles can be made this way, especially in combination with very strong blur.

Feel free to use this idea in your own projects. Let me know if you give it a try! smile.png Also, if this turns out to already be an existing technique, let me know so that I can update my blogpost accordingly.

My dev blog
Ronimo Games (my game dev company)
Awesomenauts (2D MOBA for Steam/PS4/PS3/360)
Swords & Soldiers (2D RTS for Wii/PS3/Steam/mobile)

Swords & Soldiers 2 (WiiU)
Proun (abstract racing game for PC/iOS/3DS)
Cello Fortress (live performance game controlled by cello)

Advertisement

There is something wrong with your depth values from depth buffer. OK it is perfectly clear why you see circular dark shape because each pixel is some distance away from camera. And when the pixel is further away from camera/screen center you will see a disk shape. Are you doing depth of field calculation in postprocess stage or do you calculate depth values when you render objects in scene?

From my experience I always see COC/depth of field values or when calculating fog values as straight line. When reading depth buffer I actually see near plane gradient going in straight line.

You can mask each object if it is blurred or not, With deferred rendering this is easy, just render some values in one of MRTs channels and read that RT in postprocess stage and blur accordingly.

Yeah, I wondered about that: is standard realistic DoF supposed to be at a fixed distance to the camera, or at a fixed distance to the camera plane? The first would result in a curved focal plane (is in my top image), while the second would result in a flat focal plane.

My dev blog
Ronimo Games (my game dev company)
Awesomenauts (2D MOBA for Steam/PS4/PS3/360)
Swords & Soldiers (2D RTS for Wii/PS3/Steam/mobile)

Swords & Soldiers 2 (WiiU)
Proun (abstract racing game for PC/iOS/3DS)
Cello Fortress (live performance game controlled by cello)

I just gave it a try with a real lens (I have a special portrait lens for my camera that has really strong DoF). I am pretty sure I see a curved focal plane, so the focal plane should indeed be based on the distance to the camera.

My dev blog
Ronimo Games (my game dev company)
Awesomenauts (2D MOBA for Steam/PS4/PS3/360)
Swords & Soldiers (2D RTS for Wii/PS3/Steam/mobile)

Swords & Soldiers 2 (WiiU)
Proun (abstract racing game for PC/iOS/3DS)
Cello Fortress (live performance game controlled by cello)

Ok you got me there. I have no clue how real photography works :) but i am sure many engines use near and far planes for dof value calculations.

Yeah, I know, that is why I was also confused and had to try with a real camera to see how it really works. :)

My dev blog
Ronimo Games (my game dev company)
Awesomenauts (2D MOBA for Steam/PS4/PS3/360)
Swords & Soldiers (2D RTS for Wii/PS3/Steam/mobile)

Swords & Soldiers 2 (WiiU)
Proun (abstract racing game for PC/iOS/3DS)
Cello Fortress (live performance game controlled by cello)

Yeah, this obviously should not be called depth of field because it bares almost no resemblance to the real thing. Maybe it should be called pseudo-DoF.

Technically I guess you areright this isn't DoF, but the post effect shader used is exactly DoF. This is not simply a blend between a blurred and a non-blurred image (the fastest and most common form of DoF): my implementation takes into account the depth of the pixels around and thus makes sure sharp objects not bleed over a blurred background. What I have made is DoF with simply a modified depth buffer. Whether it is still called DoF then, I don't know.

My dev blog
Ronimo Games (my game dev company)
Awesomenauts (2D MOBA for Steam/PS4/PS3/360)
Swords & Soldiers (2D RTS for Wii/PS3/Steam/mobile)

Swords & Soldiers 2 (WiiU)
Proun (abstract racing game for PC/iOS/3DS)
Cello Fortress (live performance game controlled by cello)

This topic is closed to new replies.

Advertisement