Jump to content
  • Advertisement
Sign in to follow this  
Oogst

A new technique: Area based depth of field blur

This topic is 1343 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Edited by Oogst

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!