Book Image

Panda3D 1.7 Game Developer's Cookbook

Book Image

Panda3D 1.7 Game Developer's Cookbook

Overview of this book

Table of Contents (20 chapters)
Panda3D 1.7 Game Developer's Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Adding a depth of field effect


An effect you can very commonly see in photography is objects that are very close to or very far away from the point of view. Therefore, appearing fuzzy and blurred while the middle portion of the image appears focused and sharp, emphasizing an object of interest in the scene. This focused part of the scene is referred to as 'depth of field'.

In this recipe you will learn how to mimic this cinematic effect in a post-processing filter. This will help you to emphasize the visual depth of a scene and focus a point of interest while blurring the background and foreground.

Getting ready

Set up the project structure found in Setting up the game structure, add a directory called shaders inside the project directory, make sure it is in the engine's search path and you're ready to go!

How to do it...

This recipe requires you to write some Python and Cg code as presented in the following steps:

  1. Paste the following code into Application.py:

    from direct.showbase.ShowBase import...