Why you really should be using mipmapping in your graphics applications

Share on linkedin
Share on twitter
Share on facebook
Share on reddit
Share on digg
Share on email

The new PowerVR developer documentation website has been up and running for a few weeks now. We’re really pleased to see how it’s been helping people get the most out of their applications, as well as learn new things about graphics programming and PowerVR.

If you still haven’t taken the time to check it out (you really should!) and you need to be convinced, here’s a quick preview of a topic you will find in our PowerVR Performance Recommendations.

Along with our documentation for advanced graphics developers, we’ve recently been taking more time to help those new to graphics programming, as evidenced by our new “Getting Started” guides to both Vulkan® and OpenGL® ES. So the topic today is all about mipmapping – you’ll get a very quick introduction, and also some top tips including some specific to PowerVR.

Introduction to mipmapping

In a nutshell, for almost all graphics applications, mipmapping is incredibly useful as it increases cache efficiency and reduces bandwidth usage, all for only a modest increase in texture file size.

However, for the uninitiated…

What is mipmapping?

Mipmaps are smaller, pre-filtered versions of a texture image, representing different levels of detail (LOD) of the texture. They are often stored in sequences of progressively smaller textures called mipmap chains with each level half as small as the previous one.

They are used for situations where the distance between an object and the camera can change. As the object gets further from the camera, the object’s texture will eventually appear smaller on-screen than its actual resolution, in other words, there will be more than one texel (pixels of a texture map) per screen pixel. The texture will have to be scaled down in a process called minification filtering, which often requires the application to sample multiple texels to decide on the colour of a pixel. This becomes a problem when you need to sample the entire texture at runtime for an object that could only be a single pixel wide.

This is where mipmaps come in. Instead of sampling a single texture, the application can be set up to switch between any of the lower resolution mipmaps in the chain depending on the distance from the camera.

Can you explain the benefits in a bit more detail?

I’m glad you asked, as there are two main advantages:

  1. Improved image quality – Using mipmapping can help to eliminate aliasing effects caused by oversampling textures. These effects can potentially ruin the visual quality of the application.
  2. Increased performance Mipmapping increases cache efficiency as full-size textures will not be needed as often, and the lower resolution mipmaps will fit more easily in the texture cache. This means texture data doesn’t have to be fetched as often, reducing bandwidth usage and increasing application performance.

What’s the catch? Well, the only notable drawback for most applications is the increase in texture file size, as the full mipmap chain has to be stored alongside the full resolution texture. This increases file sizes by about 33%, but with the increase in rendering speeds and image quality, this really doesn’t matter much.

There are also some situations where mipmapping isn’t very useful, for example:

  • Objects which will never change their distance from the camera, for example many UI elements. The LOD of these elements is never going to change, so in this case, mipmapping is pointless.
  • Circumstances where filtering cannot be applied sensibly, such as for index and depth textures which contain non-image data.

Generating mipmaps

Mipmaps can either be created offline or during runtime. The decision comes down to a balance between the storage cost of offline generation and the increased workload of runtime generation. In most cases, however, offline is best.

Our very popular texture-processing utility PVRTexTool (included with the PowerVR SDK) can be used to generate a mipmap chain for a texture, with only a couple of clicks. The mipmapped image can then be saved using our proprietary compressed PVRTC texture format, or a wide range of other formats.

If you really want to generate mipmaps at runtime (and lose the benefit of PVRTC or other compressed formats), OpenGL ES provides the function glGenerateMipmap. Unfortunately, Vulkan doesn’t have any built-in function for this, so you’ll need to implement it yourself.

Want to hear more about mipmapping?

For more about mipmapping, you might like to take a look at some of our following articles:

And finally…

For more PowerVR performance recommendations and other useful developer information, please visit our new, regularly-updated website at docs.imgtec.com.

Do feel free to leave feedback through our usual forums or ticketing systems.

You can also follow @tom_devtech on Twitter for Developer Technology-related news, or @powervrinsider for the latest on PowerVR!

Tom Lewis

Tom Lewis

Tom Lewis is a graduate technical author in the PowerVR Developer Technology team at Imagination. He is responsible for producing documentation to support the PowerVR SDK and Tools, including user manuals and guides. Outside of this, you will probably find him cycling up a hill that is far too steep or catching up on the latest PC game releases.

Please leave a comment below

Comment policy: We love comments and appreciate the time that readers spend to share ideas and give feedback. However, all comments are manually moderated and those deemed to be spam or solely promotional will be deleted. We respect your privacy and will not publish your personal details.

Blog Contact

If you have any enquiries regarding any of our blog posts, please contact:

United Kingdom

benny.har-even@imgtec.com
Tel: +44 (0)1923 260 511

Search by Tag

Search by Author

Related blog articles

ParticleSystem screenshot 1

Improving Particle Systems on PowerVR

This article is part of our ongoing series about the PowerVR Performance Recommendations. Today we’ll be focusing on what particle systems are and how they can affect performance, so if you’re interested, why not take a look?

Read More »

Connect

Sign up to receive the latest news and product updates from Imagination straight to your inbox.

  • This field is for validation purposes and should be left unchanged.

Subscribe to our newsletter

  • This field is for validation purposes and should be left unchanged.