Papervision 3D Programming Tutorial – Fog

Google+ Pinterest LinkedIn Tumblr +


There was an old PC game that I used to love called Magic Carpet. It was one of the first 3D games that featured an outdoor world. Its biggest drawback was the limited distance that you could see: the game made heavy use of fog to limit how much of the world was actually drawn, and therefore maintain the frame rate. It’s a simple and effective trick.

Papervision also supports a fog through the FogFilter class. Despite the advances in performance made by the Flash runtime, performance is still a big consideration. For this reason you can use the FogFilter to limit the drawing distance of the Papervision renderer, which will increase the performance.

To implement the FogFilter you simply need to assign it to the BasicRenderEngine.filter property. You can see how this is done in the ApplicationManager class.

One of the properties in the FogFilter is segments, which defines how many discreet depths there are to the fog. The sample application allows you to play with the segments property dynamically using the slider at the top of the screen. One thing I found interesting was that on my PC having 23 segments produced a reasonable frame rate, while the jump up to 24 drops the frame rate significantly. Try it for yourself and see if you get the same results.

Go back to Papervision Tutorials



About Author

Leave A Reply