Tue, Sep 29, 2009

PV3D Depth of Field v2

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.