LOD bias’ raison d’etre

Mipmap LOD bias is usually used for two things: one, by smartass developers, to artificially boost apparent texture sharpness, simultaneously producing hideous aliasing and thrashing the texture caches. Two, by smartass driver writers who use it as a cheap way to improve performance. I’ve seen our games’ textures reduced to 16×16 smudges on a laptop’s 9600 switching to “performance mode” when running on batteries, presumably to conserve power - it was a disaster, and cost me a good chunk of debugging time until I figured it out.

Today I’ve found a legitimate use of the mipmap LOD bias. I’m implementing very-high-resolution screenshots (as in “print quality resolution”, or in “fscking too much for the GPU resolution”) using the method outlined by Steve Rabin in Game Programming Gems 4: I render and store NxN resolution screenshots, offset by M/N of the screen pixel resolution in each dimension by tweaking the matrices, then interleave them, taking one pixel of each input image in every NxN block of the output image. So if you have an object which is 5 pixels tall in the original resolution, you’ll have it 5xN pixels tall in the output image.

The problem is that the GPU has picked mipmaps for the object as if it was 5 pixels tall, which become too blurry when the object suddenly becomes 5xN pixels; hence, a -log2(N) bias is required to restore its normal look. Direct3D seems to allow negative bias up to -3.0, so you can effectively use this technique up to 8×8 the screen resolution; if you use a reasonable 1600×1200 as your screen resolution and assume a print quality of 300 dpi, this means you can get reasonable prints up to 40″x30″ (100 cm x 75 cm for metrophiles). Of course, even if you upsample 16×16, and give a negative LOD bias of “only” 3.0, I doubt anyone will be able to tell the “wrong” minimaps on a 300 dpi print :-)

At these resolutions, a 32-bit OS starts to show its limits: the 1600×1200 image, upsampled 8×8 is 350 MB; if you need 16×16, this becomes 1.4 GB, and might be somewhat problematic to fit in the 2 GB address space provided to a 32-bit application by Windows.

Comments are closed.