Panda3D Manual: Texture Filter TypesIt's rare that the pixels of a texture image match one-to-one with actual screen pixels when a texture is visible onscreen. Usually, it is the case that either a single pixel of the texture is stretched over multiple screen pixels (texture magnification--the texture image is stretched bigger), or the opposite, that multiple pixels of a texture contribute to the color of a single screen pixel (texture minification--the texture image is squished smaller). Often, a single polygon will have some texture pixels that need to be magnified, and some pixels that need to be minified (the graphics card can handle both cases on a single polygon). You can control how the texture looks when it is magnified or minified by setting its filter type. texture.setMagfilter(filterType) There is a separate filterType setting for magnification and for minification. For both magnification and minification, the filterType may be one of:
For minification only, in addition to the above two choices, you can also choose from:
The default filter type for both magnification and minification is
Consider the visual effects of the various filter types on magnification and minification of the following texture:
FTNearesttexture.setMagfilter(Texture.FTNearest) Usually, FTLineartexture.setMagfilter(Texture.FTLinear)
MipmapsMany graphics tutorials will go on for pages and pages about exactly what mipmapping means and how it all works inside. We'll spare you those details here; but you should understand the following things about mipmapping: (1) It requires 33% more texture memory (per mipmapped texture), but it renders quickly. (2) It helps the texture look much smoother than filtering alone when it is minified. (3) Mipmapping doesn't have anything at all to do with magnification. (4) It has a tendency to blur minified textures out a little too much, especially when the texture is applied to a polygon that is very nearly edge-on to the camera. There are four different filter types that involve mipmapping, but you
almost always want to use just the last one,
texture.setMinfilter(Texture.FTLinearMipmapLinear) Anisotropic FilteringThere is one final addition to the texture filtering equation: you can enable anisotropic filtering on top of any of the above filter modes, which enables a more expensive, slightly slower rendering mode that generally produces superior effects. In particular, anisotropic filtering is usually better at handling texture minification than mipmapping, and doesn't tend to blur out the texture so much. To enable anisotropic filtering, you specify the degree: texture.setAnisotropicDegree(degree) The degree should be an integer number. The default value is 1, which indicates no anisotropic filtering; set it to a higher number to indicate the amount of filtering you require. Larger numbers are more expensive but produce a better result, up to the capability of your graphics card. Many graphics cards don't support any degree other than 2, which is usually sufficient anyway. texture.setAnisotropicDegree(2) Some older graphics cards cannot perform anisotropic filtering. © Carnegie Mellon University 2010 |