Depth of Field

A while since last time. I have been pretty busy with work and graphics programming. Trying to make a nice demo for The Gathering, in April.
 
Also, next week is my final week in Avanade. I’m pretty exited on moving to a new company, but also a bit sad for leaving Avanade. Been two really great years on cool projects with great colleagues, esp. on the Telenor Way of Work project.
 
During the past weeks I finished the implementation of dynamic cube mapping, and I also managed to implement a pretty nice Depth of Field( DoF) effect.
My approach to the DoF effect was to render a scene to three textures, one normal texture, one depth texture and one downsampled texture( 1:4 ). I used a 2xGouraud blur shader on the downscaled texture to blur it nicely.
 
The effect is done in one post-process pixel shader, that combines the textures mentioned above. I use the depth texture and two paramteres: focus distance and focus range to calculate whats in focus and whats blurred; the result stored in a variable. Once I know this, i can mix the scene and the blured scene texture based on the variable to get the final DoF effect.
 
In this screenshot I have put the focus on the head burried in the sand, and you can see the hand and the sky is blured out.
Im quite happy with this effect as I can add it to any scene I want without having to build the scene around the effect.
This entry was posted in Graphics. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.