Let me first state what I think I know and please correct me if I'm too inaccurate or plainly wrong.

When you use a function like texture, you're requesting a texel value given a pair (u,v) of texture parameters. However, depending on the pixel size / texel size ratio, there's a filtering and resampling prior to returning the texel value, which you can actually configure in the corresponding API (OpenGL, Vulkan, etc).

As I understand it, this filtering and resampling occurs because either:

a) Many texels affect a pixel. This happens because the texture resolution is too high for the area on screen to be covered (i.e. the pixel resolution). So in order to avoid artifacts, the texture needs to be downsampled, which consists of applying a minification filter and resampling at a lower rate.

b) The same texel can affect many pixels. The texture resolution is lower than the pixel resolution. In this case, a magnification filter is used and the texture is upsampled.

Assuming the above explanations are correct, my question is: how does the GPU know which of these two scenarios are happening.

I reckon that it does by projecting the pixel area in texture space, as it is done for selecting the mipmap level. But even if that's the answer, how is this projection achieved? I'm failing to visualize it.


Minification vs magnification is an extension of mipmap selection. When you calculate the desired mip level, it can come out to be less than 0 (or in general, less than the sampler's configured minimum LOD). In that case you're doing magnification of the lowest mip level. If the desired level comes out to a value greater than 0 then you're doing minification.

Mipmap selection works by calculating differences of the UV coordinates between adjacent pixels on screen (see shader derivative functions). Since the GPU is always shading pixels in 2×2 quads, it can look at the set of UVs input to the sampling operation across all those pixels. Those derivative vectors establish what the pixel footprint in texel space is, and their lengths are used to calculate which mip level to sample.

The details of how these calculations work exactly can be found in the OpenGL spec, section 8.14 "Texture Minification"


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.