Re: [Algorithms] mipmapping technicalities
Brought to you by:
vexxed72
From: Stephen J B. <sj...@li...> - 2002-02-27 14:38:33
|
On Wed, 27 Feb 2002, Paul Firth wrote: > Just out of interest, does anyone know how mip mapping works on > graphics hardware? It's described in some detail in the OpenGL specification (not the usual Red/Blue books - I mean the actual formal specification on www.opengl.org). > More specifically, how does the hardware > factor in the angle of the triangle into the LOD selection equation (is > this done in the driver, or is it actually a hardware feature)? What is done (down in the hardware) for each pixel that's rendered is something more or less functionally equivelent to this algorithm: * Compute the texture coordinates of the four corners of each pixel. * You can use those coordinates to imagine the pixel as a little quadrilateral drawn on top of your texture map. * Look at the maximum width and height of the pixel in texture-space. * Take the largest of those two numbers. * Take log-to-base-2 of that. * Some OpenGL implementations allow you to bias that number up or down using an OpenGL extension. OpenGL 1.2 allows you to clamp that number to a smaller range. * This number is the MIPmap level you need. * Since the number is not (in general) an integer, you either pick the nearest integer and use that to select a MIPmap to use for this pixel - or you can do a linear blend between the next larger and next smaller MIPmap. The result of that is that the orientation, range and size of the textured polygon are all taken into account. On some *very* ancient hardware, the MIPmap level for the entire polygon was estimated once for each triangle in software - but those systems are not common anymore because they look like *CRAP*. There are better ways to do this (but they aren't cheap in hardware terms) - and some modern cards have Anisotropic MIPmapping which tends to stop polygons from getting so fuzzy as they go edge-on. > Also, when specifying UV's and using bilinear filtering we all know > its important to start a half pixel inwards to avoid the filtering picking > up the wrong texel edges. However, mipmapping can change the map > resolution (and thus the size of half a pixel in UVs) per pixel, > so how on earth do you factor this into the equation? You don't. :-( Read my FAQ: http://www.sjbaker.org/steve/omniv/tiling_textures.html ---- Steve Baker (817)619-2657 (Vox/Vox-Mail) L3Com/Link Simulation & Training (817)619-2466 (Fax) Work: sj...@li... http://www.link.com Home: sjb...@ai... http://www.sjbaker.org |