Page 1 of 4 123 ... LastLast
Results 1 to 20 of 72
  1. #1
    Member martinsh's Avatar
    Join Date
    Oct 2006
    Location
    riga, latvia
    Posts
    772

    GLSL depth of field with bokeh v2.4 (update)

    Hi,
    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:
    http://artmartinsh.blogspot.com/2010...ith-bokeh.html
    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.






    fringe:
    adds chromatic aberration for the blur (small overlay image shows r,g,b color offset of the sample)



    bias:
    shifts the weights of the samples on the bokeh edges




    pentagon:
    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.
    Last edited by martinsh; 19-Dec-11 at 18:31.



  2. #2



  3. #3
    Member JohnnyBlack's Avatar
    Join Date
    Nov 2009
    Location
    Earth>Romania
    Posts
    1,781
    Great!
    One question : Is there any way to achieve Distance Blur?



  4. #4
    Member martinsh's Avatar
    Join Date
    Oct 2006
    Location
    riga, latvia
    Posts
    772
    Thanks, SolarLune!

    BlendingBGE - distance blur? like a blur that blurs the scene only in specified distance?



  5. #5
    Member mataii's Avatar
    Join Date
    Jul 2002
    Location
    Mexico
    Posts
    444
    Thanks Martinsh, screenshots looks great!



  6. #6
    Member
    Join Date
    Sep 2007
    Location
    Viña del Mar, Chile
    Posts
    1,033
    Wow, those bokeh blur look beautiful!



  7. #7
    Ooh, pretty!
    Life is like an analogy.



  8. #8
    That is just fantastic! Typical of Martinsh work.
    My Blender Tutorials:
    http://www.youtube.com/d123s404



  9. #9
    Member JohnnyBlack's Avatar
    Join Date
    Nov 2009
    Location
    Earth>Romania
    Posts
    1,781
    Originally Posted by martinsh View Post
    Thanks, SolarLune!

    BlendingBGE - distance blur? like a blur that blurs the scene only in specified distance?
    Yes.
    The blur should appear on a specified distance.



  10. #10
    Member Karakasimov's Avatar
    Join Date
    Jun 2010
    Location
    India
    Posts
    1,156
    Excellent work indeed!
    BGZ - Blog



  11. #11
    Member martinsh's Avatar
    Join Date
    Oct 2006
    Location
    riga, latvia
    Posts
    772
    Thank you for the nice replies.
    Originally Posted by BlendingBGE View Post
    Yes.
    The blur should appear on a specified distance.
    here you go. it should be really easy to use. You have to specify the distance where the blur starts and the distance how far it fades in. All the distances are in Blender Units.
    http://dl.dropbox.com/u/11542084/distance_blur



  12. #12
    Member JohnnyBlack's Avatar
    Join Date
    Nov 2009
    Location
    Earth>Romania
    Posts
    1,781
    Originally Posted by martinsh View Post
    Thank you for the nice replies.

    here you go. it should be really easy to use. You have to specify the distance where the blur starts and the distance how far it fades in. All the distances are in Blender Units.
    http://dl.dropbox.com/u/11542084/distance_blur
    amazing Martinsh! Thank you. Very nice!



  13. #13
    Member MrPutuLips's Avatar
    Join Date
    Oct 2010
    Location
    South Africa
    Posts
    1,211
    This is awesome. When you make the blend, please make a version that works the same as your old DoF ( just centring to the screen so it can be used for a moving camera). Also, is it possible to make the chromatic aberration affect the objects?

    Thanks for sharing this script

    I forgot to add: it seems pretty noisy even at 512 samples
    Last edited by MrPutuLips; 23-Nov-11 at 09:51.



  14. #14
    Member leonnn's Avatar
    Join Date
    Dec 2008
    Location
    Brazil - PR - Maringá
    Posts
    2,554
    Amazing as usual thanks for share this!
    Intel 486
    64 mb RAM/128 mg HD
    Graphic card Voodoo 122



  15. #15
    Member leonnn's Avatar
    Join Date
    Dec 2008
    Location
    Brazil - PR - Maringá
    Posts
    2,554
    Martinsh I was playing with the DOf with the bokeh effects and its amazing what we can do here is a little presentation with your filter, thanks!

    Intel 486
    64 mb RAM/128 mg HD
    Graphic card Voodoo 122



  16. #16



  17. #17
    I don't know why... but if I add a filter as a 2d filter actuator, it never works for me, unless I download the pre-made .blend sample.

    What am I doing wrong?



  18. #18
    Member leonnn's Avatar
    Join Date
    Dec 2008
    Location
    Brazil - PR - Maringá
    Posts
    2,554
    Some filters have properties that are floating values and those need to be replicated in order to them to work, for example, the vignette need the vigneting size or something like that and a valuefrom -1, to 1 ( at least on the one that Im using, but it was modificated) so you need to set it up. Other filters may need a auxiliar python script in order to make them work, like the HDR that need the get light script or the DOF that needs an auxiliar like autofocus or manual focus for example.

    And there are other things that may differ from scene to scene, the size for example every scene needs an Z-far and a Z-near for the SSAO to work properly, but all the filters have specific configurations that need to be changed in order to make them work, the templates that martinsh share with us are the best for the scene that cames with the blender but they need to be changed if you want better results for your scene.

    I hope that it helps!
    Intel 486
    64 mb RAM/128 mg HD
    Graphic card Voodoo 122



  19. #19
    Member martinsh's Avatar
    Join Date
    Oct 2006
    Location
    riga, latvia
    Posts
    772
    leonnn is right,
    My shaders are lacking a detailed documentation how to properly set them up, but I try to fix that with the new shaders.
    Shaders that uses depth texture input as SSAO and DoF are very dependent to camera range so also for scene scaling . I usually use 1 BlenderUnit = 1meter and camera depth range from 0.1 --> 100.0. Well 100meters is not much, especially for outdoors scenes, but the values can be cleverly tweaked to work for large scale areas. The reason is the depth texture precision on older ATI/AMD cards with large scene sizes, they tend to produce artifacts that looks like stripes.
    Thankfully the shaders are very customizable , it is a matter of tweaking to acquire the best results for your needs.



  20. #20
    Member martinsh's Avatar
    Join Date
    Oct 2006
    Location
    riga, latvia
    Posts
    772
    Here is a blend file and with that - a major shader update.
    blend: http://dl.dropbox.com/u/11542084/DoF_playground.blend
    the new shader v2.2: http://dl.dropbox.com/u/11542084/DoF_bokeh_2.2

    controls:
    •WASD+mouse = move&look
    •1 - enable depth of field shader
    •left mouse button = set focal target
    •spacebar toggles a debug visualization of focus point and focal range (red line = focal point, green area = focal range)


    debug focus visualization enabled:



Page 1 of 4 123 ... LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •