Public Group

# OpenGL Mipmapping

## Recommended Posts

*** Beginner question ***

To my current understanding of mipmapping, If you have a 512x512 texture downsized to 256x256, then only 1 pixel can be rendered on the downsized version for every 4 pixels on the full sized texture.

If the nearest neighbour method is used, then the colour of each pixel on the downsized version will be determined by which pixel has its centre closest to the relevant texture coordinate, as demonstrated below:

Whereas if the linear method is used, then the colour of each pixel on the downsized version will be determined by a weighted average of the four full size pixels:

But if mipmapping is not used, then how is the colour of each pixel determined?

##### Share on other sites

Sorry if I misunderstand your question. Texture sampling modes are irrespective of mipmapping, so point vs linear sampling functions as you described.

##### Share on other sites

As @Steve_Segreto said, they way sampling works is mostly the same whether mip-mapping is used or not. "Mostly", because with mip-maps we get an additional axis for interpolation. When computing the optimal mip-level for a given fragment, the value can be some floating-point number. Thus, we want to interpolate between the two mip-levels closest to that optimal level. E.g. your optimal level is 4.6 then use levels 4 and 5.

And just to make it clear why exactly we use mip-mapping: Imagine a surface patch very far away from your camera so that it covers exactly one pixel. Now, this surface might have a texture that is 512x512 pixels big applied to it. Thus, all of that texture information must fit into that one pixel, which is obviously not possible with nearest-neighbor or bilinear filtering. This is why we get ugly shimmering when moving the camera, because with e.g. bilinear filtering differnt 2x2 neighborhoods are choosen frame by frame, resulting in differnt colors. You would have to average all 512x512 pixels for the correct result. And that is exactly what we do with mip-mapping, we prefilter some sizes of that texture so that we can just use e.g. bilinear filtering since we can now choose the correct size of the texture. In this case the GPU would choose the smallest mip-level which is 1x1 pixel and is basically the whole image averaged into one pixel.

##### Share on other sites

Thanks Steve_Segreto and Batzer.

• ### Game Developer Survey

We are looking for qualified game developers to participate in a 10-minute online survey. Qualified participants will be offered a \$15 incentive for your time and insights. Click here to start!

• 15
• 12
• 9
• 11
• 15