This one has been lying around for some time, but I never got the time to finish it, so instead I thought I'd release what I have in case anyone can find a use for it.
Basically it's a plug'n'play depth of field effect that can be applied to a viewport. You can set the focal plane, near and far blur distances etc. The technique is based on Advanced Depth of Field.
Code: Select all
// Add depth of field effect to the viewport
mDepthOfFieldEffect = new DepthOfFieldEffect(mViewport);
// Adjust focus
mDepthOfFieldEffect->setFocalDepths(
nearDepth, focalDepth, farDepth);
There may be problems with hardware skinning etc., though, because the effect uses the same vertex program on everything, so this will need some work, if it's going to be used with other vertex programs.
For now there's only support for OpenGL, but adding Direct3D support should be very easy.
Some pictures (not very eye-candy-ish, unfortunately):
You can get a binary demo for Windows: dof-0.1.0-bin-win32.zip
And a source release for Linux and Windows (VS.NET 7.1): dof-0.1.0-src.tar.bz2
To compile the source you'll need Dagon from CVS from today (Mar 04, 2006) or newer.
I wish I had had the time to complete my initial idea of making a camera auto-focus like demo, where you could point the camera at any object in the scene, and the auto-focus would slowly put it into focus. That'd be a little cooler than this manual focus...
Thanks sinbad for helping on this one.