Mipmapping in Flash Player, Unbeknownst Until Now!

October 15th, 2008 | by Matt |

The other day I was messing around with Papervision3D for a prototype at work. I'm no Papervision expert by any means so I was doing all sorts of Google searches to try and find any information relating to what I was trying to achieve. At one point I stumbled across Tinic Uro's post on how the Flash Player uses mipmaps. I didn't even read the whole post and at the time I thought to myself, "What the hell is this? I don't need to know this." I honestly thought it was just some nerding out about how to use mipmapping to achieve a nicely scaled down image.

That was until today! My co-worker, Faisal, at ROKKAN was having a hard time getting a relatively large PNG image to scale down smoothly with nice aliasing. The image was of a product that has a relatively fine texture on it in certain areas. So when the image was scaled down relatively small, the bitmap data was appearing to be very sharpened. No big deal really, in my opinion, but the client was going crazy about how the image should scale smoothly like it does in Photoshop.

At this point I remembered Tinic's blog post, so I quickly went back to it and read the entire thing. To my surprise there was no programming needed! All we had to do was change the dimensions of the PNG to friendly mipmapping dimensions. That meant either n^2 or n^8. If you do this the Flash Player will automatically use mipmapping when scaling it down. Totally bad ass. Here's an example that shows the difference in aliasing of two images that only differ in dimension by 1 pixel.

  1. 4 Responses to “Mipmapping in Flash Player, Unbeknownst Until Now!”

  2. Awesome, glad it worked for you, and I hope the client is now real scared of your abilities…. ;-)

    (Thanks for providing that clear comparison, by the way… I think you’ll turn more people on to the technique when they can see it like that, thanks.)

    jd/adobe

    John Dowdell on Oct 15, 2008 | Reply

  3. My pleasure John. It was quite a pleasure to learn this and to learn its so easy to implement.

    Matt on Oct 15, 2008 | Reply

  4. Nice one Matt. One of my favorite underused features too!

    You mentioned Papervision3D – you can turn on automatic mipmapping on BitmapMaterials which can be useful.

    BitmapMaterial.AUTO_MIP_MAPPING = true;

    You’ll also get a little more performance using this method.

    Justin on Jun 28, 2009 | Reply

  1. 1 Trackback(s)

  2. Oct 17, 2008: localToGlobal » Blog Archive » news review -> 42th week of 2008

Post a Comment