Download the code from this user contribution by fogman:
Postprocessing FX Viewer forum post
Project Zip file

After playing around with it, open up the code and see how it works. He coded it very nicely.