The present invention relates generally to environmental mapping in a computer graphics system and more particularly to environmental mapping and mip-mapping in a computer graphics system.
Cubic mapping is a form of reflection mapping in which a cubic environmental map is used, as illustrated in
of the texture coordinates (u, v) with respect to the screen coordinates (x, y). For example, according to Williams1, the LOD is calculated as
Although the derivatives can be obtained through the slope function of attributes and perspective division, for multipass texture rendering, these slope functions are too expensive to compute. Thus, an approximation of the derivative is used instead, by taking the delta difference of neighboring pixels' texture coordinates, where the screen coordinates differ by one. For example, if pixels p0 and p1 are adjacent in the x-direction, and p0 and p2 are adjacent in the y-direction, then
where u0 is the u-coordinate for pixel p0, u1 is the u-coordinate for pixel p1 and u2 is the u-coordinate for pixel p2. A problem occurs, however, in cubic mapping. There is no guarantee that the neighboring coordinates are mathematically continuous, which is required if the delta differences are to be a reasonable approximation of the derivative. This is true because u and v have been mapped according to certain rules to determine which face of the cube applies to a particular view vector and because the cubic face of neighboring pixels may not be the same.
The mapping rules are illustrated by the code fragment in
The derivative is computed in accordance with the following approximation:
u=U/Major
Therefore, after cross-multiplying and simplifying:
where dU/dx=U1−U0 and dMajor/dx=Major1−Major0.
The above computation, however, has the problem that, in using the normalized delta, the continuity of normals of the pixels at different faces is assumed, but may not be true. Also, for each pixel, the computation requires three multiplications, two additions, and one division, all in floating point. The cost of this kind of computation is high and the precision is subject to the approximation of the normal delta. Thus, an improved computation, that avoids the continuity problem at the faces is desired.
A method in accordance with the present invention is a method of performing cubic mapping with texturing. The method includes selecting neighboring pixels to be mapped, computing normals of the neighboring pixels, and mapping the normals of the pixels to faces of a cube, where neighboring pixels are mapped to adjacent faces of the cube and each face has an identifying number, and a LOD and a pair of texture coordinates for defining a mip-map for the face. The method further includes computing a level of detail (LOD) parameter for the texture coordinates of the neighboring pixels based on continuity-adjusted derivatives of the texture coordinates.
One advantage of the present invention is that the same LOD can be maintained for texture maps used on different faces of the cube.
Another advantage is that fewer computations are required to determine the LOD.
These and other features, aspects and advantages of the present invention will become better understood with regard to the following description, appended claims, and accompanying drawings where:
Because cubic mapping is topologically similar to spherical mapping, shown in
In making the continuity adjustments, there are three cases to consider. In the first case, neighboring pixels have different u values, but these values differ only in sign. For example, u1=Nx/Nz but u0=−Nx/Nz. Therefore, du/dx=u1−(−u0) is a good approximation. Alternatively, there can be a jump in the value between the faces. In this case, du/dx=1+u1−(−u0).
In the second case, neighboring pixels have u and v swapped; the value of u1=Nx/Nz is changed to Ny/Nz. In this case, du/dx=u1−v0 is a good approximation.
In the third case, neighboring pixels have v and Major swapped; the value of u1=Nx/Nz is changed to Nx/Ny. Because at the boundary of the faces, Nz=Ny, du=u1−u0 is a good approximation.
All other cases involving face changes are combinations of the above cases. Therefore, the texture coordinate adjustment across face boundaries involve combinations of a negation and a u/v swap. In practice, the u/v values are first computed, then normalized to the [0,1]range, and then the delta is computed. A texture coordinate adjustment may also have a third operation, add/subtract, to compensate for the normalization process.
To simplify a hardware implementation of the present invention, the operations needed for texture delta coordinate adjustment across face boundaries are tabulated. If two adjacent pixels have different faces, the table has an operation code for the delta adjustment.
The table is shown in
Reference to
The table in
The code fragment, shown in
Although the present invention has been described in considerable detail with reference to certain preferred versions thereof, other versions are possible. Therefore, the spirit and scope of the appended claims should not be limited to the description of the preferred versions contained herein.
This application claims priority to U.S. Provisional Application Ser. No. 60/449,123, filed Feb. 20, 2003, and entitled “APPROXIMATION OF LEVEL OF DETAIL CALCULATION IN CUBIC MAPPING WITHOUT ATTRIBUTE DELTA FUNCTION,” which application is incorporated herein by reference.
Number | Name | Date | Kind |
---|---|---|---|
5912670 | Lipscomb et al. | Jun 1999 | A |
5923334 | Luken | Jul 1999 | A |
6034691 | Aono et al. | Mar 2000 | A |
6236405 | Schilling et al. | May 2001 | B1 |
6246422 | Emberling et al. | Jun 2001 | B1 |
6424351 | Bishop et al. | Jul 2002 | B1 |
6664963 | Zatz | Dec 2003 | B1 |
6744430 | Shimizu | Jun 2004 | B1 |
6765584 | Wloka et al. | Jul 2004 | B1 |
6768492 | Dorbie et al. | Jul 2004 | B2 |
6850242 | Saito | Feb 2005 | B1 |
6975319 | Donovan et al. | Dec 2005 | B1 |
Number | Date | Country | |
---|---|---|---|
20050017983 A1 | Jan 2005 | US |
Number | Date | Country | |
---|---|---|---|
60449123 | Feb 2003 | US |