create your own

Papervision 3D programming tutorial - Depth of Field

71
rate or flag this page

By phyxx


In photography depth of field refers to the area that is in focus. You’ll see this effect a lot in landscape photographs where an object in the foreground (say a tree) is in focus while the background (like some mountains) will be quite blurry. It’s not an effect that is naturally reproduced with 3D engines – typically the entire scene is rendered in focus with no regard for a depth of field. However it is a fairly easy effect to achieve with Papervision and the standard Flash effects. Before we begin though it is worthwhile to revisit this article to see how we can apply Flash effects to Papervision objects.

In order to achieve the DOF effect we create a call called DOFMeshObject. This class extends the MeshObject class, which in turns holds a Papervision DisplayObject3D that is rendered to the scene (a simple box in this case). The actual DOF effect code is contained in the enterFrame function, which applies a BlurFilter with increasing "fuzziness" to the DisplayObject3D depending on how far the object is away from the focal point of the camera.

In the demo you can modify the focal point of the camera using the slider on the left hand side. Notice that as you slide it up the objects in the background gradually come into focus. Likewise as you slide it down the objects in the foreground are focused upon.

Check out the live demo here, and download the source code for this example here.

Find more tutorials here.

Papervision 3D Depth Of Field


Comments

RSS for comments on this Hub

Research Analyst profile image

Research Analyst  says:
9 months ago

Papervision and standard flash effects is the best way to gain depth in field, especially for photography, thanks for the tutorial.

Alberon profile image

Alberon  says:
4 months ago

LIke the content here! Keep up the good work! Thanks!

Submit a Comment

Members and Guests

Sign in or sign up and post using a hubpages account.


optional


  • No HTML is allowed in comments, but URLs will be hyperlinked
  • Comments are not for promoting your hubs or other sites

working