The invention relates to a system and a method of computer graphics processing.
An important element in rendering 3D graphics is texture mapping. Mapping textures onto surfaces of computer-generated objects is a technique which greatly improves the realism of their appearance. The texture is typically a 2D picture, such as a photograph or computer generated image. For example, (part of) a 2D image of a wall may be projected on a 3D representation of a wall in a computer game. Most 3D objects cover only a small part of the screen, often resulting in minification of the texture map (which is of sufficient resolution to also provide a reasonable appearance when viewed up close). Often, during texture mapping the 2D picture has to be minified considerably, for example if the wall is far removed. In principle, texture mapping could then be performed by significantly downscaling the original image. To reduce the bandwidth required for reading the high resolution 2D picture, a pre-processing step is often performed in which several downscaled versions of the 2D picture are created. During texture mapping, the part of only the smaller downscaled picture which matches best in resolution with the screen image is read and mapped to the screen. The original 2D picture along with its downscaled versions is called a mipmap. Texture mapping as well as mipmaps are particularly described in “Survey of Texture Mapping Paul S. Heckbert, IEEE Computer Graphics and Applications, November 1986, pp. 56-67 and in U.S. Pat. No. 6,236,405 B1. In a mipmap, the original image is denoted as level 0. In level 1, each entry holds an averaged value of, for example, 2×2 texels. As used herein the term “texel” (texture element) refers to a picture element (pixel) of the texture. This can be continued until the top-level is reached, which has only one entry holding the average color of the entire texture. Thus, in a square mipmap, level n has one fourth the size of level n-1. In the present specification, the term “texture” is used as a synonym for any image or structure to be mapped onto an object.
Several types of mipmaps are known, varying in which downscaled images are stored. In a 3D mipmap, both directions are downscaled by the same factors, while in a 4D mipmap the original image is downscaled independently in both dimensions. Compared to the 3D mipmap, the 4D mipmap arrangement requires a lot of memory to store. Computer graphics programs, such as games, therefore, often use the 3D mipmap structure. The non-prepublished European patent application with attorney docket number PHNL010924EPP filed as IB02/05468 describes a method for generating a 4D mipmap on the fly from a 3D mipmap. This enables high quality rendering also in combination with programs that do not supply a 4D mipmap to the graphics system.
In general, there are several methods known for mapping the (mipmapped) image onto the screen grid. Most conventional computer graphics systems use a so-called inverse texture mapping approach. In this approach, pixels of the screen are processed sequentially and for each pixel, during a rasterization process, a projection of the screen pixel on the texture (resulting in a pixel's “footprint”) is determined and an average value which best approximates the correct pixel color is computed, usually in the form of a weighted average. An alternative approach is the so-called forward texture mapping method. This method works by traversing texels in the coordinate system defined by the texture map. The texel colors are then splatted to the screen pixels, using resamplers commonly used for video scaling.
A 2D or 3D object to be rendered is typically modeled using primitives (usually triangles). A vertex shader of the graphics system receives the vertices of a primitive as input and uses a vertex shading program to change or add attributes for each of these vertices. In a forward mapping system, a rasterizer then traverses the primitive in texture space while interpolating these attributes. The rasterizer accepts vertex coordinates which define vertices of triangles. The rasterizer computes texture coordinates (u, v) for each texel to be projected to the triangle. For each grid position (u, v) of the texture visited, the texel shader calculates from these attributes the local color of the surface of the primitive. These surface colors are then resampled to screen pixel locations by the screen space resampler. In a two-pass forward mapping approach, mapping of a 2D image is decomposed in two 1D mappings. First, the image is mapped in one direction, typically the scan line direction, i.e. in horizontal direction, then in the other direction. The first pass then processes complete scan lines and therefore the vertical mipmap level in the texture space rasterizer is fixed for the whole primitive (triangle) that is being rendered. The rasterizer indicates for a triangle the maximum amount of detail required, based on information for the vertices. To be able to still vary the horizontal mipmap level, the 4D mipmap arrangement is used. It is also possible to use a one-pass 2D filter and vary both the horizontal and vertical mipmap level. The supplied information includes a horizontal mipmap level mmlu and a vertical mipmap level mmlv. The rasterizer processes the texels along the grid determined by these two 4D mipmap level values. A texture space resampler resamples data from the identified 4D mipmap to the texel position.
It is desired to make a well-considered choice of the mipmap to use. Choosing a too detailed mipmap generates too much memory bandwidth. Choosing a too coarse mipmap generates an image of too low quality. In particular, for a 2-pass forward texture mapping graphics system where the vertical mipmap level is fixed for the entire triangle on the basis of the maximum amount of detail required anywhere in the triangle, the risk of choosing a too detailed level is high.
It is an object of the invention to provide a method and system for choosing a mipmap level.
To meet the object of the invention, a system for rendering an image for display includes:
a texture memory for storing texture maps in a mipmap structure; texels in a texture map being specified by a pair of u and v coordinates;
a rasterizer operative to, for a texel (u, v),
a texture space resampler for obtaining texture data from a texture map identified by the pair of final 4D mipmap levels;
a texture mapper for mapping the obtained texture data to corresponding pixel data defining the display image.
The inventor has realized that, although the rasterizer operates on a grid determined by the initial 4D mipmap levels (mmlu, mmlv) (in a way that corresponds to the maximum amount of detail needed somewhere in the triangle), these values (as conventionally delivered by the rasterizer to the texture space resampler) may not be the ideal measure for choosing the texture from the mipmap structure: it may indicate a much more detailed level than is actually needed at a particular point within the triangle. This is particularly the case if the triangle is viewed under a high perspective. This causes a magnification to occur in one or both of the orthogonal directions of the grid. For example, a vertical magnification factor (the vertical direction is usually indicated by v) indicates for the current rasterization grid position how far apart on the screen two texels are that differ one in v value in the vertical rasterization mipmap level mmlv. The magnification factor then influences the choice of mipmap level used for the texture space resampling. The system according to the invention may be used for inverse texture mapping systems as well as forward texture mapping systems.
According to the measure of the dependent claim 2, the vertical 4D mipmap level is adjusted depending on the vertical magnification. This combines well with a 2-pass graphics system where the rasterizer itself during the first pass operates with a fixed vertical 4D mipmap level for the entire triangle on the basis of the maximum amount of detail required anywhere in the triangle and a variable horizontal mipmap level. Such a conventional rasterizer already uses a horizontal 4D mipmap level that varies per texel. According to the invention, the rasterizer also determines per texel a final vertical 4D mipmap level for use by the texture space resampler by adjusting its initial vertical 4D mipmap level in dependence on the vertical magnification. All other operations of the rasterizer are not affected and can still operate with a fixed vertical 4D mipmap level.
According to the measure of the dependent claim 3, the mipmap level mmlv is lowered if the magnification factor is small. In this case, a lower vertical resolution can be used. Conventionally, the vertical 4D mipmap levels supplied by the rasterizer represent the highest level of detail required for a texel within a primitive. In particular if the magnification factor is small (high perspective in that direction) a relatively large minification occurs in that direction, enabling the use of a 4D mipmap with less detail in that direction.
According the measures of the dependent claim 4, the texture memory stores a 4D mipmap structure. The texture space resampler operates on the 4D mipmap indicated by the finally determined levels (possibly with a lower resolution). The rasterizer still operates on the initial 4D mipmap (with possibly unnecessary high detail). The resampler provides the data to the rasterizer by reconstructing it from the finally identified 4D mipmap (e.g. through interpolation). In this way, bandwidth to the texture memory can be reduced at those texels where the quality does not suffer.
According the measures of the dependent claims 5, the texture memory stores a 3D mipmap structure, as is usually the case for computer graphics applications such as games. The texture space resampler generates the finally identified 4D mipmap on-the-fly from one of the 3D mipmaps. The non-prepublished European patent application IB02/05468 describes a method for generating a 4D mipmap on the fly from a 3D mipmap. This enables efficient high quality rendering also in combination with programs that do not supply a 4D mipmap to the graphics system.
According the measures of the dependent claims 6 and 7, respectively, the 3D mipmap level can be chosen as the maximum of both 4D mipmap levels, if priority is given to high quality rendering, or as the minimum, if priority is given to reducing memory bandwidth.
According to the measure of the dependent claim 8, also a maximum anisotropy level is taken into consideration when choosing the 3D mipmap level. The dependent claim 9 shows a preferred way of doing so.
To meet an object of the invention, a method of rendering an image for display, includes:
storing texture maps in a mipmap structure; texels in a texture map being specified by a pair of u and v coordinates;
in a rasterization operation determining, for a texel (u, v):
in a texture space resampling operation, obtaining texture data for a texture map identified by the final 4D mipmap levels; and
mapping the obtained texture data to corresponding pixel data defining the display image.
These and other aspects of the invention are apparent from and will be elucidated with reference to the embodiments described hereinafter.
In the drawings:
Overview of the System
The vertex shader 110 of
The rasterizer 220 of
In a preferred embodiment shown in
In the system according to the invention, the texture space rasterizer traverses the texture map on a grid corresponding to 4D mipmapping, as illustrated in
The texel shader 130 computes for each texel the local surface color. The pixel shader 230 of
In a preferred embodiment, the texture memory 134 (and 234 of
The screen space resampler 140 splats mapped texels to integer screen positions, providing the image of the primitive on the screen. The screen space resampling includes the following operations:
Reconstructing the color information in the texel grid to a continuous signal,
Mapping the continuous signal from the texture space to the screen space,
Pre-filtering the mapped continuous signal in screen space, and
Sampling the pre-filtered signal in screen space.
It will be appreciated that also first the mapping from the texture space to the screen space may be performed, followed by reconstructing the mapped signal.
As illustrated in
The pixel fragments coming from the screen space resampler are then combined in the Edge Anti-Aliasing and Hidden Surface Removal (EAA & HSR) unit 150 of
Adjusting the 4D mipmap Level
For any texture map which provided the rasterization grid, the rasterizer maintains separate horizontal and vertical mipmap levels, which together form a 4D mipmap level index. In the 4D mipmap texel reconstruction process, the rasterizer provides for each rasterization grid position the u and v coordinates for the texel that needs to be fetched, along with the 4D mipmap level (mmlu, mmlv) for that texel.
Using mipmaps where successive levels are scaled in each direction by a factor of two, typically a mipmap level is chosen that provides a magnification factor between 0.5 and 1. A magnification factor in a direction is the difference in pixels if the texel is changed by one in that direction (e.g. increased by one). A magnification factor of 1 in both directions for a texel area, roughly corresponds to the situation wherein the texel area has the same number as texels as there are pixels in the area to which it is projected. A magnification factor of 0.5 in both directions, then roughly corresponds to the situation of a texel area with four times the number of texels as there are pixels in the area to which it is projected. A lower magnification than 0.5 makes it better to use a 3D mipmap of a higher level, i.e. with lower resolution (giving sufficient resolution and requiring less bandwidth). For 4D mipmaps, both direction-specific levels can, in principle, be chosen independently.
Using a scaling factor of two (as is normally the case) between mipmap levels, the mipmap level in a direction with a magnification factor s is given by −2log(s). Persons skilled in the art will be able to perform a similar mipmap choice for other scaling factors and other numbering of the mipmap levels.
The rasterizer determines for each texel (u, v) corresponding initial 4D mipmap levels (mmlu, mmlv). In a system wherein the rasterizer uses a fixed mipmap level for the vertical direction (and/or horizontal direction if so desired), the rasterizer determines this initial 4D mipmap level in this direction by determining the magnification factor in this direction in the triangle vertices and choosing the largest magnification factor. So, if for a given direction, in one vertex the magnification factor is 1 and in the other two vertices it is 0.5, it chooses 1 and calculates the mipmap level in that direction as −2log(1)=0. If the three vertices have twice 0.25 and once 0.5 as magnification factors, this gives −2log(0.5)=1. The initial 4D mipmap levels determine the grid on which the rasterizer operates. These levels are not necessary the most optimal values for the texture space resampling for each texel within the triangle. Thus if the vertical mipmap level is fixed for operations of the rasterizer and the horizontal mipmap level is variable, the rasterizer once per triangle determines the vertical 4D mipmap level and per texel determines the corresponding horizontal 4D mipmap level. According to the invention, the rasterizer also determines for each texel (u, v) a corresponding magnification factor representing a magnification that occurs when the texel is mapped to a corresponding pixel position on the display. According to the invention, final 4D mipmap levels are determined in dependence on the initial 4D mipmap levels and the magnification factor. The final 4D mipmap levels are used by the texture space resampler. Preferably, the magnification factor is only in the vertical direction, where the rasterizer itself uses a fixed vertical mipmap level per triangle. This is particular advantageous when processing occurs in two 1D scans. The first scan is then, preferably, in the display scan line direction (‘horizontal’) giving an intermediate image. The second scan then operates on the intermediate image in the other direction. For the first scan, in texture space per scan line the horizontal coordinate u is variable and the vertical coordinate v is fixed per line. The rasterizer provides a value for mmlv that is kept constant across the whole triangle. The value for mmlu is determined per texel. In this way, the rasterizer per texel determines the initial value mmlu that also acts as the final value fmmlu. The initial 4D level mmlv that is kept constant for operations of the rasterizer is then adjusted per texel to the final value fmmlv for the texture space resampling as described below.
The final vertical mipmap level fmmlv is determined by adjusting mmlv to identify a lower resolution mipmap level if the magnification factor is less than a predetermined threshold and maintaining the determined mmlv mipmap level otherwise. To determine the modification, the rasterizer calculates ∂y/∂v, which indicates the magnification factor for the second pass (which maps v values to y values). This value indicates based on the currently selected rasterization grid position how far apart on the screen two texels are that differ one in v value in the vertical rasterization mipmap level mmlv. Because of the choice of mmlv, this is at most 1 pixel spacing, but it can be considerably less because of the variation in minification across the triangle, and because shear reduction might have refined the rasterization grid vertically. Using scaling by a factor of two, the threshold is preferably ½. Persons skilled in the art will be able to determine optimal thresholds for other scaling factors. Thus, if ∂y/∂v is smaller than ½, a coarser 4D mipmap level mmlv may be chosen than one would assume on the initial mmlv (and still have an effective screen pixel spacing between ½ and 1 for subsequent rows in the fetched 4D mipmap level mmlv). More precisely, ∂y/∂v determines a mipmap level difference
which can be added to mmlv to arrive at the vertical 4D mipmap level which is really needed to supply the proper amount of detail for a particular rasterization grid location. This gives the final mipmap level fmmlv=mmlv+Δmmlv. Preferably, the rasterizer in addition to the initial 4D mipmap levels provides the vertical magnification factor per texel. The calculation shown above to determine the final vertical 4D mipmap level may then be done by the texture space resampler, but it may also be done by another unit of the system. It will be appreciated that above description for a preferred embodiment is for a vertical magnification. Other systems may use the same principle in the horizontal direction or in both directions. Using the technique described above, optimal 4D mipmap levels are chosen for resampling despite rasterizing over a finer grid at some locations in the triangle. So although this finer rasterization costs more processing power, memory bandwidth required for fetching texture maps is not affected.
The final 4D mipmap levels can be used by the texture space resampler to fetch texture data from the specified 4D mipmap, if the texture memory stores a full 4D mipmap structure. The final 4D mipmap may be of lower resolution than the initial 4D mipmap used by the rasterizer. To save bandwidth, the higher resolution 4D mipmap may on-the-fly be reconstructed from the lower resolution 4D mipmap, using interpolation.
Selecting the 3D Mipmap Level for 4D Mipmap Reconstruction
Since applications usually deliver textures only in standard 3D mipmap representation, in a preferred embodiment for any texture map which provided the rasterization grid on-the-fly 4D mipmap reconstruction from a 3D mipmap is applied. The texel shader acts then as a 4D mipmap reconstructor. As described above, the rasterizer maintains separate horizontal and vertical mipmap levels, which together form a 4D mipmap level index. In the 4D mipmap texel reconstruction process, the rasterizer according to the invention provides for each rasterization grid position the u and v coordinates for the texel that needs to be fetched, along with the vertical magnification factor (or even the final 4D mipmap levels (mmlu,fmmlv)) for that texel. The 4D reconstruction unit needs to determine a 3D mipmap level mml from which to fetch texels which can be filtered to provide a sample at the requested coordinates (u,v). A 3D mipmap level mml corresponds to 4D mipmap level (mml, mml), and these are drawn as the shaded squares in
In a low quality setting, as illustrated in
mml=MAX(mmlu,fmmlv).
In a high quality setting, as illustrated in
mml=MIN(mmlu, fmmlv).
In a medium quality setting, as illustrated in
mml=MAX(MAX(mmlu, fmmlv)−a, MIN(mmlu,fmmlv)).
The lower quality settings (allowing only very limited anisotropy level) may result in artefacts, as is shown in
Note that the value assigned to mml by the calculations described above, has to be clipped to the range of values for which mipmap levels are available (to exclude for example negative values of mml) and transformed to the integer levels used to indicate the mipmap level in memory. This may be done in any suitable way, e.g. by rounding or truncating. The remaining fraction is preferably used for trilinear filtering. The moment of rounding may be chosen. Preferably, the final value of mml is rounded, where mml is for example determined in one of the three approaches described above. If so desired also Δmml, may be rounded immediately when it is determined, e.g by rounding down
Δmmlv=└2log(∂y/∂v)┘.
It should be noted that the above-mentioned embodiments illustrate rather than limit the invention, and that those skilled in the art will be able to design many alternative embodiments without departing from the scope of the appended claims. In the claims, any reference signs placed between parentheses shall not be construed as limiting the claim. Use of the verb “comprise” and its conjugations does not exclude the presence of elements or steps other than those stated in a claim. The article “a” or “an” preceding an element does not exclude the presence of a plurality of such elements. The invention may be implemented by means of hardware comprising several distinct elements, and by means of a suitably programmed computer. In the device claim enumerating several means, several of these means may be embodied by one and the same item of hardware. The mere fact that certain measures are recited in mutually different dependent claims does not indicate that a combination of these measures cannot be used to advantage.
Number | Date | Country | Kind |
---|---|---|---|
031019615 | Jul 2003 | EP | regional |
Filing Document | Filing Date | Country | Kind | 371c Date |
---|---|---|---|---|
PCT/IB04/51054 | 6/30/2004 | WO | 12/29/2005 |