1. Field of the Invention
Embodiments of the present invention relate generally to computer graphics and more specifically to anisotropic optimization for texture filtering.
2. Description of the Related Art
Conventional graphics processors read and filter texture maps to add texture detail and increased realism to rendered objects. This process, commonly referred to as “texture filtering,” may be simplified by pre-filtering a given texture map to various resolution levels, where each pre-filtered resolution level forms a “mipmap.” The resolution level associated with a given mipmap is commonly referred to as a “level of detail” (LOD).
When texturing a pixel, the pixel is first mapped from screen space to texture space. In a case where mipmaps are used, the pixel is mapped to the appropriate mipmap. The region in texture space corresponding to a pixel is commonly called the pixel footprint. While a pixel is usually approximated by a circle in screen space, the corresponding footprint in texture space is oftentimes approximated by an ellipse, especially in view of texture stretching, oblique viewing and perspective. An example of an elliptical pixel footprint 115 within a mipmap 101 is shown in FIG. 1. In order to compute a texture value for the pixel, the values of the individual texels (i.e., texture pixels) and partial texels encompassed by the pixel footprint 115 need to be blended together. Anisotropic texture filtering is a technique for computing the texture value of a pixel having an elliptical footprint that attempts to match the shape of the elliptical footprint to achieve an accurate blending of the texels encompassed by the footprint.
As is well-known, the shape of the corresponding elliptical footprint may be approximated by two or more bilinear samples (also referred to as “bilerps”). Each bilerp has a circular footprint, and four texels usually form a 2×2 square about the center of the circular footprint. The texture value of a bilinear sample is equal to the interpolated values of these four texels, where a typical bilinear filter is used for the interpolation. The optimal number of bilerps used to approximate an elliptical pixel footprint (the “desired” bilerp count) may be determined in a variety of different ways known in the art. For example, the desired bilerp count may be set equal to the anisotropic ratio ((major-axis length)/(minor-axis length)) associated with the elliptical pixel footprint or, for course level mipmaps, may be set equal to the major-axis length.
In a graphics processing system, there are usually operational points that include discrete available bilerp counts. For example, in one graphics processing system, the available bilerp counts may be two, four, six and eight bilerps, but in another system, the available bilerp counts may be two, four, eight and sixteen bilerps. Generally, to calculate the texture value of a pixel having an elliptical footprint, the texture value corresponding to each bilerp used to approximate the pixel footprint is first computed, and then a weighted average of the texture values for all of the bilerps is computed. In cases where the desired bilerp count is equal to an available bilerp count, the texture value for each bilerp is given an equal weight. For example, if the desired bilerp count is two and two bilerps is one of the available bilerp counts, the texture value for each of the two bilerps is weighted by 0.5 and added together.
However, if the desired bilerp count is not coincident with an available bilerp count, then the desired bilerp count will fall between two available bilerp counts (hereinafter referred to as the “first available count” and the “second available count”). In such cases, the texture value for the pixel footprint is computed based on the number of bilerps associated with the second available count, where a first weight is given to the texture value for each bilerp in the first available bilerp count and a second weight is given to the texture value for each “additional” bilerp (the first available bilerp count plus the additional bilerps equals the second available bilerp count). The first and second weights are based on the distance between the desired bilerp count and the first available bilerp count relative to the total distance between the second available bilerp count and the first available bilerp count. In other words, the weights are based on what “fraction” of the total distance between the first and second available bilerp counts the distance between the desired bilerp count and the first available bilerp count represents (hereinafter referred to as the “fractional distance”).
In instances where the desired bilerp count (CD) falls between the first available bilerp count (Ci) and the second available bilerp count (Ci+1), the fractional distance (f) is given by the equation:f=(CD−Ci)/(Ci+1−Ci),  (1)
and a weighting factor (x) is defined by the equation:x=1/(Ci+(f)(Ci+1−Ci)).  (2)
The texture value for the pixel footprint is computed using the number of bilerps in the second available bilerp count (Ci+1). Specifically, the texture value for each of the bilerps in the first available bilerp count (Ci) is multiplied by a first weight, x, and the texture value for each of the additional bilerps (Ci+1−Ci) is multiplied by a second weight, (f*x). These products are then added together to produce the texture value for the pixel footprint. As persons skilled in the art will recognize, the additional bilerps are effectively “phased in” as the fractional distance approaches 1.0 and the desired bilerp count approaches the second available bilerp count. When the desired bilerp count is coincident with the second available bilerp count, the texture value for each bilerp in the second available bilerp count is given an equal weight.
FIG. 2 illustrates a graph of a function 205 setting forth the relationship between the desired bilerp count (CD) and the bilerp count used to calculate a texture value for a pixel (CC), according to the prior art. As shown, both axes of the graph include the bilerp counts available within a particular graphics system (C1, C2, C3 and C4). The desired bilerp count (CD) has an associated fractional distance (f), both of which are shown on the x-axis of the graph. The bilerp count used to compute the pixel texture value (CC) and its associated fractional distance (f) are shown on the y-axis of the graph. Importantly, the function 205 is a forty-five degree line, making the fractional distance (f) associated with the desired bilerp count (CD) identical to the fractional distance (f) associated with the bilerp count used to calculate the pixel texture value (CC) and creating a one-to-one relationship between the desired bilerp count (CD) and the count used to calculate the pixel texture value (CC). Thus, when the desired bilerp count (CD) falls between a first available bilerp count (depicted as C2) and a second available bilerp count (depicted as C3), the fractional distance (f) is computed according to equation (1) above, the weighting factor (x) is computed according to equation (2) above, and the texture value for the pixel is computed as set forth above. In effect, the desired bilerp count (CD) is used to compute the texture value for the pixel.
To illustrate a typical texture value computation, consider FIG. 3, which shows how six bilerps may be used to compute the texture value for a pixel when the desired bilerp count is 4.1, according to the prior art. Two of the bilerp counts available to the graphics processing system are assumed to be four bilerps and six bilerps. Since four bilerps is the lesser of the two available bilerp counts, four bilerps is designated as the first available bilerp count (Ci), and six bilerps is designated as the second available bilerp count (Ci+1). As shown in the figure, the four bilerps 325 represent the bilerps in the first available bilerp count (Ci), and the two bilerps 330 represent the additional bilerps (Ci+1−Ci) that are included with the four bilerps 325 to make the total number of bilerps equal to six, which is the number of bilerps in the second available bilerp count (Ci+1). Using the equations (1) and (2) set forth above, the fractional distance (f) is equal to 0.05, and the weighting factor (x) is equal to 0.476. The texture value of the pixel represented by pixel footprint 210 is computed by multiplying the texture value for each bilerp 325 by a first weight of 0.476 (=x), multiplying the texture value for each of the additional bilerps 330 by a second weight of 0.024 (=f*x), and then summing the products.
On drawback of calculating the texture value for the pixel footprint in this manner is that, when the fractional distance (f) is small, the texture values for the additional bilerps are heavily discounted and, therefore, may have relatively little influence on the final texture value. In effect, substantial computational effort may be wasted when the fractional portion (f) is small because the additional bilerps do not contribute much to overall image quality. In other words, when the texture values for the additional bilerps are heavily discounted, the decrease in performance attributable to including the additional bilerps when computing the final texture value may outweigh the marginal increase in overall image quality attributable to the additional bilerps.
As the foregoing illustrates, what is needed in the art is a more efficient approach to anisotropic texture filtering.