Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

6. Designing Creative Effects > Implementing the depth-of-field effect

Implementing the depth-of-field effect

The classic depth-of-field (DOF) means that when camera lens is focused on an object, only the object and its nearby area will appear sharp in the final image, but subjects outside the area will appear blurred. It is a famous and common post-processing effect used in most 'next generation' computer games, especially the first-person ones, to enhance the reality.

We will use more than one pass to implement a basic DOF effect.

How to do it...

Let us start.

  1. Include necessary headers:
    #include <osg/Texture2D>
    #include <osg/Group>
    #include <osgDB/ReadFile>
    #include <osgViewer/Viewer>
    
  2. The post processing vertex shader is the same as the last one.
    static const char* vertSource = {
    "void main(void)\n"
    "{\n"
    "gl_Position = ftransform();\n"
    "gl_TexCoord[0] = gl_MultiTexCoord0;\n"
    "}\n"
    };
    

  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free 10-Day Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint