Wednesday, October 15, 2008

Papervision Optimization Techniques (aka taming the Beast)

I've been working with Papervision very intensively for the last 5 months or so, and I've learned quite a bit about what is under the hood.

Also, I've been using it mainly in Flash (due to me designing everything in Flash as well, as developing). So, that being said, I primarily use MovieMaterials for all of my Primitives. With using MovieMaterials that opens up a whole other can of worms. CPU issues

Here's some ideas to get you going:

  1. Set animated to false as much as possible. If you need it to animate occasionally, use some checks to turn the value on and off. Because when the material is set to animated = true, that material is being redrawn every frame.
  2. Toggle the smooth and precise values on only when needed as well. This is especially true with smooth, because that is a major CPU killer.
  3. When using objects that extend off of the screen make sure that you divide the segments appropriately. If you just instantiate something like: var ground:Plane = new Plane(groundMaterial) it's using it's default values (segmentsW:1, and segmentsH:1). That will cause the ground to be clipped by the Frustrum (basically it will disappear out of view when it should still be in view), because there aren't enough segments to subdivide. Usually (I say that loosely), a setting of segmentsW:5 and segmentsH:5 will do (unless you are dealing with something huge. . . then you would have to go higher).
  4. Use flash 10, and turn on the Hardware Acceleration (direct not GPU, because GPU has toasted some of my test computers video drivers), which will not help with the rendering of the triangles, but it'll at least help with redrawing the screen. I've seen it decrease CPU load by over 30% in some cases, with smoother performance.
Oh, and lastly, do a reality check. Not everything has to be in 3d, try mixing 2d and 3d elements wherever you can.

2 comments:

Trent Sterling said...

Good tips. Using every one of them

Zach Zurn said...

Nice info. Where does the animation setting reside, is it for individual textures?