This is one of the things that made Crysis so good looking. This was originally a school assignment to be done in OpenGL using CG-shaders, but I have decided to do it in DirectX because I could use PIX debugging. To improve this shader I could add some blur and/or noise to make it better looking, but I'm happy with this result as is.
Your graphics card should support HLSL shaders 2.0a for it to work.
- Download SSAO_HLSL.zip