PV3D Depth of Field v2

This movie requires Flash Player 9

In the example above, use the controls to set the depth that the DOF starts and ends at and the strength of the blur. Setting the focus depth to greater than the blur depth will cause the distance to be in focus with the foreground out of focus. Click and drag to reposition the camera.

The biggest issue with my past DOF experiments in Papervision was the lack of depth buffer precision. Depth information was limited to per triangle and so even with high tessellation and generous blurring the effect was not that great and displayed a lot of artifacts.

With my latest PV3D depth buffer implementation providing 11bit precision at the pixel level the past DOF limitations are no longer an issue. Since the effect no longer requires high tessellation there is also a decent performance boost!

To achieve this new version of DOF a simple Pixel Bender kernel reads the depth buffer and sets the targets alpha channel based on the depth, with a blur filter applied to the target we have blur based on depth, depth of field.

  • Facebook
  • Twitter
  • Netvibes Share
  • Delicious
  • Share/Bookmark

6 Responses Subscribe to comments


  1. samBrown

    bad-ass! nice work.

    Sep 29, 2009 @ 3:13 pm


  2. Mark Barcinski

    You are on fire!

    This is totally awesome!

    Sep 29, 2009 @ 3:32 pm


  3. Ben

    @sam, @mark - thanks!!

    Sep 29, 2009 @ 3:36 pm


  4. Jon

    This is very impressive. Good job!

    Sep 29, 2009 @ 4:48 pm


  5. malte

    @Ben, could you post the source for that example? I got the fog demo running but i dont understand how you did the depth lur in this demo…

    Nov 06, 2009 @ 8:20 pm


  6. Ben

    @malte you can recreate the DOF experiment using the fog source pretty easily. Simply replace the fog container with a copy of the scenes render, with this blurred and filtered using the depth-to-alpha PB filter you will achieve DOF. Let me know if you have further difficulties. :)

    Nov 19, 2009 @ 12:13 pm

Reply