Methods and systems for providing texture tiling and mirroring

Systems and methods are disclosed for providing texture tiling. The disclosed systems and methods may include copying a source image into a texture of a size the same or larger than the source image. Furthermore, the disclosed systems and methods may include displacing texture coordinates corresponding to the texture into a desired range. A displacement map may be used in displacing the texture coordinates. Moreover, the disclosed systems and methods may include rendering, within the desired range, an output image corresponding to the texture coordinates associated with the texture.

BACKGROUND OF THE INVENTION

I. Field of the Invention

The present invention generally relates to methods and systems for providing texture tiling and mirroring. More particularly, the present invention relates to providing non-power-of-two texture tiling and mirroring using a displacement map.

II. Background Information

Tiling and mirroring are processes for displaying objects side by side on a computer display. For example, a “tile” command in a graphical interface may repeat a particular object, element, or image in a certain row and column order. In some situations, graphics cards within conventional computing devices support tiling or mirroring of textures that have power-of-two dimensions. Few of them, however, support texture tiling or mirroring with non-power-of-two dimensions. While, developers have traditionally chosen power-of-two textures because they have traditionally been the only type supported, this often causes problems because power-of-two textures are very limiting.

Other conventional tiling processes include retessellating an area being drawn. This often causes problems because retessellating is both complicated and central processing unit (CPU) intensive. While some developers may be content to use power-of-two textures, other hardware accelerated platforms may benefit from tiling non-power-of-two textures.

In view of the foregoing, there is a need for improved methods and systems for texture tiling and mirroring. Furthermore, there is a need for providing non-power-of-two texture tiling and mirroring using, for example, a displacement map.

SUMMARY OF THE INVENTION

Consistent with embodiments of the present invention, systems and methods are disclosed for providing texture tiling and mirroring.

In accordance with one embodiment, a method for providing texture tiling comprises copying a source image into a texture of a size the same or larger than the source image, displacing texture coordinates corresponding to the texture into a desired range, and rendering an output image corresponding to the texture coordinates associated with the texture.

According to another embodiment, a system for providing texture tiling comprises a memory storage for maintaining a database and a processing unit coupled to the memory storage, wherein the processing unit is operative to copy a source image into a texture of a size the same or larger than the source image, displace texture coordinates corresponding to the texture into a desired range, and render an output image corresponding to the texture coordinates associated with the texture.

In accordance with yet another embodiment, a computer-readable medium which stores a set of instructions which when executed performs a method for providing texture tiling, the method executed by the set of instructions comprising copying a source image into a texture of a size the same or larger than the source image; displacing texture coordinates corresponding to the texture into a desired range; and rendering, within the desired range, an output image corresponding to the texture coordinates associated with the texture.

It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only, and should not be considered restrictive of the scope of the invention, as described and claimed. Further, features and/or variations may be provided in addition to those set forth herein. For example, embodiments of the invention may be directed to various combinations and sub-combinations of the features described in the detailed description.

DETAILED DESCRIPTION

The following detailed description refers to the accompanying drawings. Wherever possible, the same reference numbers are used in the drawings and the following description to refer to the same or similar parts. While several exemplary embodiments and features of the invention are described herein, modifications, adaptations and other implementations are possible, without departing from the spirit and scope of the invention. For example, substitutions, additions or modifications may be made to the components illustrated in the drawings, and the exemplary methods described herein may be modified by substituting, reordering, or adding stages to the disclosed methods. Accordingly, the following detailed description does not limit the invention. Instead, the proper scope of the invention is defined by the appended claims.

Systems and methods consistent with embodiments of the present invention provide texture tiling and mirroring. For example, embodiments of the invention may tile any sized texture by applying a displacement map in a first stage of a two stage fixed function graphics pipeline. The displacement map may displace texture coordinates back into an acceptable range. In addition, a texture layout may be used that may mirror the texture as well as tile it.

Consistent with embodiments of the present invention, images of any dimension may be wrapped or mirrored without requiring, for example, retessellation. Many conventional graphics cards support wrapping and mirroring of power-of-two textures using one texture stage. Embodiments of the present invention may bypass the aforementioned graphics cards' limitation by: i) copying an image into a texture of the same or larger size; and then ii) using a second texture stage to displace texture coordinates back into a range within the same or larger texture where the copy of the image exists. Because embodiments of the present invention may handle wrapping the texture coordinates, embodiments of the present invention, for example, may then be free to use the clamp wrapping mode and non-power-of-two texture sizes.

An embodiment consistent with the invention may comprise a system for providing texture tiling and mirroring. The system may comprise a memory storage for maintaining a database and a processing unit coupled to the memory storage. The processing unit may be operative to copy a source image into a texture of the same or a size larger than the source image. In addition, the processing unit may be operative to displace texture coordinates corresponding to the texture into a desired range. Also, the processing unit may be operative to render, within the desired range, an output image corresponding to the texture coordinates associated with the texture.

Consistent with an embodiment of the present invention, the aforementioned memory, processing unit, and other components may be implemented in a computing device, such as an exemplary computing device100ofFIG. 1. Any suitable combination of hardware, software, and/or firmware may be used to implement the memory, processing unit, or other components. By way of example, the memory, processing unit, or other components may be implemented with any of computing device100or any of other computing devices118, in combination with computing device100. The aforementioned system, device, and processors are exemplary and other systems, devices, and processors may comprise the aforementioned memory, processing unit, or other components, consistent with embodiments of the present invention.

With reference toFIG. 1, one exemplary system consistent with an embodiment of the invention may include a computing device, such as computing device100. In a basic configuration, computing device100may include at least one processing unit102and a system memory104. Depending on the configuration and type of computing device, system memory104may be volatile (such as RAM), non-volatile (such as ROM, flash memory, etc.) or some combination. System memory104may include an operating system105, one or more applications106, and may include a program data107. In one embodiment, application106may include a tiling/mirroring application120. However, embodiments of the invention may be practiced in conjunction with a graphics library, an operating system, or any application program and is not limited to word processing. This basic configuration is illustrated inFIG. 1by those components within a dashed line108.

Computing device100may have additional features or functionality. For example, computing device100may also include additional data storage devices (removable and/or non-removable) such as, for example, magnetic disks, optical disks, or tape. Such additional storage is illustrated inFIG. 1by a removable storage109and a non-removable storage110. Computer storage media may include volatile and nonvolatile, removable and non-removable media implemented in any method or technology for storage of information, such as computer readable instructions, data structures, program modules, or other data. System memory104, removable storage109, and non-removable storage110are all examples of computer storage media. Computer storage media may include, but is not limited to, RAM, ROM, EEPROM, flash memory or other memory technology, CD-ROM, digital versatile disks (DVD) or other optical storage, magnetic cassettes, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other medium which can be used to store the desired information and which can be accessed by computing device100. Any such computer storage media may be part of device100. Computing device100may also have input device(s)112such as keyboard, mouse, pen, voice input device, touch input device, etc. Output device(s)114such as a display, speakers, printer, etc. may also be included. The aforementioned devices are exemplary and others may be used.

Computing device100may also contain a communication connection116that may allow device100to communicate with other computing devices118, such as over a network in a distributed computing environment, for example, an intranet or the Internet. Communication connection116is one example of communication media. Communication media may typically be embodied by computer readable instructions, data structures, program modules, or other data in a modulated data signal, such as a carrier wave or other transport mechanism, and includes any information delivery media. The term “modulated data signal” may mean a signal that has one or more of its characteristics set or changed in such a manner as to encode information in the signal. By way of example, and not limitation, communication media may include wired media such as a wired network or direct-wired connection, and wireless media such as acoustic, RF, infrared and other wireless media. The term computer readable media as used herein may include both storage media and communication media.

A number of program modules and data files may be stored in system memory104of computing device100, including an operating system105suitable for controlling the operation of a networked personal computer, such as the WINDOWS operating systems from MICROSOFT CORPORATION of Redmond, Wash. System memory104may also store one or more program modules, such as tiling/mirroring application120, and others described below. While executing on processing unit102, tiling/mirroring application120may perform processes including, for example, one or more of the stages of the methods described below. The aforementioned process is exemplary, and processing unit102may perform other processes. Other applications106that may be used in accordance with embodiments of the present invention may include electronic mail and contacts applications, word processing applications, spreadsheet applications, database applications, slide presentation applications, drawing or computer-aided application programs, etc.

FIG. 2is a flow chart setting forth the general stages involved in an exemplary method200consistent with the invention for providing texture tiling using computing device100ofFIG. 1. Exemplary ways to implement the stages of exemplary method200will be described in greater detail below. Exemplary method200may begin at starting block205and proceed to stage210where computing device100may copy a source image into a texture of a size the same or larger than the source image. For example, as described below with respect to Table 2 and Table 3 below, to support linear filtering for tiling a source image, the texture may be increased, for example, by one pixel width in all four directions. The edges may then be copied onto the opposite sides of the texture that were just newly created. For example, the source image shown in Table 2 may be copied into a texture of a size the same or larger than the source image as shown in Table 3. This is also illustrated by original source image405and texture420stored for tile fill shown inFIG. 4.

From stage210, where computing device100copies the source image into the texture of the size the same or larger than the source image, exemplary method200may advance to stage220where computing device100may displace texture coordinates corresponding to the texture into a desired range. For example, the texture coordinates of a mesh may wrap back into a desired range before the texture is sampled. The desired range may be from “Min” to “Max.” The following formula may be apply to the texture coordinates.
u′=Min+[u−floor(u)]*(Max−Min)

One possible way to achieve this formula is to use PIXEL SHADER (e.g. version 2.0 or higher) in DIRECTX from MICROSOFT CORPORATION. Furthermore, this formula may be produced using the fixed function pipeline. Letting w=Max−Min, then the formula becomes:
u′=Min+[u−floor(u)]*w;
and can be rewritten as:
u′=[Min+u*w]−floor(u)*w.

The first half of the formula, [Min+u*w], may be achieved by applying a linear transformation of the texture coordinates. The second half, −floor(u)*w, is non-linear however, and may not be solved using a matrix transformation. Instead, a “displacement map” (sometimes called a “bump map”) may be used to do the aforementioned scaled floor operation. An exemplary displacement map is shown below in Table 1.

Each of the entries in Table 1 is a component of a shift that may be applied to the U and V coordinates of the next texture stage in the fixed function graphics pipeline. The displacement map (Table 1) may be aligned onto a 2D mesh such that the texels of the displacement map may be equal to the negative floor of the texture coordinates. A 2×2 bump map matrix may be used to multiply by w. Note that w can be different for u and v, and thus can be referred to as wuand wv. For example, in DIRECTX, this can be accomplished by setting D3DTSS_BUMPENVMAT00 and D3DTSS_BUMPENVMAT11.

FIG. 3is a diagram illustrating a transformation from vertex texture coordinate space to sampled texture coordinates space consistent with an embodiment of the present invention. For example,FIG. 3visually demonstrates the effect of u′=Min+[u−floor(u)]*(Max−Min). The displacement map, for example, may be aligned such that the (0, 0) texel of the displacement map stretches across the piece of the tessellation that has U and V coordinates in the range of 0 to 1. Furthermore, the displacement map may be aligned such that the (−1, 0) cell acts on the piece of the tessellation that has U coordinates in the range of 1 to 2. Also, the displacement map may be aligned such that the (0, −1) cell acts on the piece of the tessellation that has V coordinates in the range of 1 to 2. Because the texture coordinates may be arranged linearly, the displacement map may work to subtract the floor of the texture coordinates in entire tessellation. For example, a scale may be applied such that a scaled floor may be achieved.

To support linear filtering for tiling an image, the texture may be increased, for example, by one pixel width in all four directions. The edges may then be copied onto the opposite sides of the texture that were just newly created. For example, the source image shown in Table 2 may be copied into a texture of a size the same or larger than the source image as shown in Table 3.

TABLE 3IGHIGCABCAFDEFDIGHIGCABCAMin UMax U

The resulting texture (e.g. Table 3) may then be sampled on the inner border of the outer pixels to provide the correct linear interpolation between one side of the original texture and the other at the seams of the tiles. Here the Min and Max values used in the algorithm may be placed on the corner of “IGCA.” The resulting Min and Max values may be:
MinU=1/TextureSizeU
MaxU=1−1/TextureSizeU
MinV=1/TextureSizeV
MaxV=1−1/TextureSizeV

To support mirroring, the width and/or height of the texture may be doubled placing a mirrored version in the expanded sections. Then the aforementioned tiling logic may be reused. For example, the above “ABCDEFGHI” (Table 2) image setup for mirroring in both U and V may be as shown in Table 4 below.

This storage format may not require the additional padding of one texel on each side as the tile setup for linear filter does because the additional texels may be the same as the edge texels and clamp wrap mode may give that result automatically, assuming the hardware supports conditional non-power-of-two. Here the Min and Max values used in the algorithm may be placed on the upper left and lower right corners, so their values may be 0 and 1.

To support hardware that can only render power-of-two textures, the texture may be rounded up to the next power-of-two. The mirror expanded portion may be stored in the upper-left portion of the texture and the margin may be filled with the right and lower edges of the mirror expansion.

Once computing device100displaces texture coordinates corresponding to the texture into the desired range in stage220, exemplary method200may continue to stage230where computing device100may render, an output image corresponding to the texture coordinates associated with the texture. For example,FIG. 4is a diagram illustrating content progression from source to rendering a result consistent with an embodiment of the present invention. Computing device100may render output image415onto one of output devices114. After computing device100renders the output image in stage230, exemplary method200may then end at stage240.

The present invention may be embodied as systems, methods, and/or computer program products. Accordingly, the present invention may be embodied in hardware and/or in software (including firmware, resident software, micro-code, etc.). Furthermore, embodiments of the present invention may take the form of a computer program product on a computer-usable or computer-readable storage medium having computer-usable or computer-readable program code embodied in the medium for use by or in connection with an instruction execution system. A computer-usable or computer-readable medium may be any medium that can contain, store, communicate, propagate, or transport the program for use by or in connection with the instruction execution system, apparatus, or device.

Embodiments of the present invention are described above with reference to block diagrams and/or operational illustrations of methods, systems, and computer program products according to embodiments of the invention. It is to be understood that the functions/acts noted in the blocks may occur out of the order noted in the operational illustrations. For example, two blocks shown in succession may in fact be executed substantially concurrently or the blocks may sometimes be executed in the reverse order, depending upon the functionality/acts involved.

While certain features and embodiments of the invention have been described, other embodiments of the invention may exist. Furthermore, although embodiments of the present invention have been described as being associated with data stored in memory and other storage mediums, aspects can also be stored on or read from other types of computer-readable media, such as secondary storage devices, like hard disks, floppy disks, or a CD-ROM, a carrier wave from the Internet, or other forms of RAM or ROM. Further, the steps of the disclosed methods may be modified in any manner, including by reordering steps and/or inserting or deleting steps, without departing from the principles of the invention.

It is intended, therefore, that the specification and examples be considered as exemplary only, with a true scope and spirit of the invention being indicated by the following claims and their full scope of equivalents.