I am really lazy so I will just paste the text from my dev-blog here:
This is my second attempt to create a depth of field shader with bokeh. the first one is here:
And I am really glad that it got popular quite fast. It has been even used in Google Chrome's ROME "3 DREAMS OF BLACK" hehe.
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
• pentagonal bokeh shape (experimental)
yet to do
• add multi-shape bokeh (does anyone knows how to make procedural pentagon or hexagon?)
• bokeh vignetting at screen edges
The shader is made on 2006 iMac with Mobility Radeon card so it should work on any hardware supporting OpenGL.
Screenshots are captured with high sample count, but the point is to show the features and capabilities of the shader.
some of the main features explained with images:
threshold & gain:
brings out highlights by "threshold" value and enhances them with "gain"
as you can see this is the main part that makes the distinct look of the bokeh blur. Without bringing out highlights, the blur looks like just a regular circular blur.
adds chromatic aberration for the blur (small overlay image shows r,g,b color offset of the sample)
shifts the weights of the samples on the bokeh edges
pentagon shape of the bokeh (still needs some work)
and the GLSL 2D Filter is HERE
version 2.2 is HERE
version 2.4 is HERE (newest!)
I am trying to comment it as simple as I can so anyone can understand it.
and blend is HERE
new blend (2.4) is HERE
I will be glad if you guys will find this useful. I would also like to know how it works for you.