Labels

October 26, 2011

GLSL depth of field with bokeh v2

This is my second attempt to create a depth of field shader with bokeh. the first one is here:
http://artmartinsh.blogspot.com/2010/02/glsl-lens-blur-filter-with-bokeh.html
And I am really glad that it got popular quite fast.

This one is much more flexible and I have added few new features.

• variable sample count to increase quality/performance
• option to blur depth buffer to reduce hard edges
• option to dither the samples with noise or pattern
• bokeh chromatic aberration/fringing
• bokeh bias to bring out bokeh edges
• image thresholding to bring out highlights when image is out of focus

yet to do

• add multi-shape bokeh (does anyone knows how to make procedural pentagon or hexagon?)
• bokeh vignetting at screen edges
• some minor fixes

screenshots:






fragment shader HERE

7 comments:

  1. Looking great, I'd love to hear what you had to change to accomplish this! What kind of hw do you run this on and what kind of framerate do you get?

    Keep up the great work, like your posts!
    /Tobias

    ReplyDelete
  2. Hello Tobias,
    I am glad you like it.
    I will publish the code soon.. I just have to deal with other stuff first.
    Basically what does the trick is the texture sampling and sampling weight distribution. Right now I am on an old 2006 iMac with Mobility Radeon and the framerate is dependant on the sample count and texture size.

    ReplyDelete
  3. Awesome, looking forward to reading the code and trying it out myself. Nice to hear that you are able to run it on that kind of hardware while still looking that good!

    ReplyDelete
  4. Hey, I published the code. It should be really easy to implement yourself. It only requires a depth buffer as input. Have fun :)

    ReplyDelete
  5. Oh awesome! Thanks will have a play with it soon! Lots of fun in your blog, have bookmarked it now so I can come back to it more often!

    Thanks for the awesome code snippets!

    ReplyDelete
  6. are these blender shaders portable to apps out side of the blender game engine? Awesome work by the way.

    ReplyDelete
  7. Jeremy - there shaders are application and platform independent. So any app supporting OpenGL should run them nicely without any modification.

    ReplyDelete