Previously I showed you how to use the FogFilter to implement a fog effect in Papervision. While it does the job, personally I think it’s a bit rough. Objects seem to pop out of the fog in jarring intervals, and for some reason there is a big performance drop when you set the segments over a certain amount.
This sample demonstrates the use of the standard Flash BlurFilter and ColorMatrixFilter to achieve the same fog look. If you compare the two samples side by side I think you’ll agree that the Enhanced Fog is a lot more subtle, and a lot cleaner. Using the Flash filters doesn’t seem to incur any noticeable performance hit either.
The code responsible for the fog is now in the Block class. Take a look at the setupFilters function, which is called every frame. It alters the colour and blur of the object depending on how close to the camera it is. The distances that are used to calculate the effects can be modified using the sliders in the top right hand of the screen.
The only real downside to this method is that it does not cull any objects that are totally obscured by the fog. The FogFilter does give some performance increase by not rendering objects behind the fog “veil” so to speak. However it would be a fairly trivial task to simply remove the object from the scene if it was beyond a certain distance from the camera manually.