News:

Function Finder  Find all the functions within source code files

Main Menu

Mip Mapped Image Zoomer

Started by kevin, March 08, 2011, 11:38:33 PM

Previous topic - Next topic

kevin

  Mip Mapped Image Zoomer

    This example loads an image (in this case a page of sheet music), it then down samples the image 5 levels.   Each level is half of the size of the previous one.  The down sampled images are created by first blurring the source image pixels, then performing a filtered scale.  What this does is smooths (well smudges) quads of pixels into each other,  so when it's scaled down detail is not completely lost as it would be in linear scale, or even bi-linear filter on it's own.    So what we end up with is the sequence of images, each 1/2 the size of the previous, each image is created from the previous image.  

    The actual demo here perspectively scales the image in & out.  So the z depth (distance from viewer) determines it's size on screen,  which we then use to find a the closest mip map (image side) for this screen size.   So when the image is zoomed out (far into the distance),  we're using the smallest mip map version of it, rather than scaling the original full size edition.  Same as when it's up close to the viewer, here we'd be using highest detail version of the image (the original) it.  Making the process a lot more pleasant to the eye than straight linear/bi-linear filter is.   In both cases when you scale an image down, you start losing pixels from the source the further you go the more loss, so the pixels tend to flicker.  You can get away with a linear scale sometimes, but It's most noticeable in images that have grid patterns, like brick work for example.  
 
    There's a few benefits to using this type of effect apart from the visual,  the main one is that smaller images are easier to scale than bigger ones.  This is because the pixels fit better with the cpu data cache, so they can be randomly accessed at much higher speed.  The bigger the image is (the more memory it eats) the slower random pixel access becomes, since the cpu is having to constantly read/write chunks of memory outside of it's local data cache.

   

Related To:

  Z Depth Perspective For Sprites
  Manual Projection/Scene Perspective
  2.5D Rugby Source