Abstract:
A process, referred to as alpha discrimination, for processing a texture data value in a computer graphics display system. With a preferred embodiment, the process of alpha discrimination occurs during the rendering of a drawing primitive between the stages of texture memory fetch and texture filter in the traditional graphics pipeline. After an initial texture data value is fetched, or identified, a determination is made as to whether the discrimination procedure is enabled or not enabled. If that procedure is not enabled, then the initial texture data value is passed to a predetermined element of the graphics display system, such as the texture filter. But if the discrimination procedure is enabled, then a preset test is performed. The initial texture data value is processed on the basis of the result of the test to produce a processed texture data value, and that processed texture data value is then passed to the predetermined element of the graphics display system.

Description:
FIELD OF THE INVENTION 
     This invention generally relates to computer graphics systems; and more specifically, the invention relates to the techniques of real time rendering with texture mapping in the field of computer graphics systems. 
     BACKGROUND OF THE INVENTION 
     Texture Mapping 
     Texture mapping is a commonly employed technique for adding detail in computer graphics rendering to achieve a high degree of realism in the rendered image. Each drawing primitive (i.e. each polygon) is specified with texture coordinates at its vertices which describe corresponding locations within an array of memory locations in a memory storage device, referred to as a texture. As the primitive is rasterized pixel-by-pixel, the texture coordinates are interpolated to arrive at a corresponding texel address within the texture. 
     The contents of the texture at the interpolated address are fetched from the memory device and are used to affect the color of the pixel value stored in the frame buffer. There are a number of ways that a texel value can affect the color of the pixel stored in the frame buffer. In most cases, the texel value is used to either modulate or replace a luminance or color value interpolated between color or luminance values specified or computed at the vertices of the drawing primitive. 
     Alpha Blending 
     In computer graphics and image processing, it often is necessary to combine color values from separate sources into a composite color value. It is a standard practice in the field of computer graphics to represent an image as a set pixels each of which has four distinct values: Red, Green, Blue, and Alpha. Red, Green and Blue are additive primary components in the RGB color space. The alpha channel contains information used to weight the Red, Green, and Blue values when combining them with colors from other sources. Also, the alpha channel is often used to represent the opacity of a material or the amount of pixel area covered by a polygon. 
     When a translucent or partially covered pixel is to be written to a location in the frame buffer, the incoming value may be combined with the value already stored at the location and the resulting composite color may be stored in the location. The alpha values are used to weight the contribution of the source (incoming) value with the destination (current) value in proportion to each value&#39;s opacity or area. Various operating standards, such as Open GL and Direct 3D, allow applications to specify conditions based upon the alpha value of an incoming pixel where a pixel write can be avoided (for example, when Alpha is equal to or nearly zero and the incoming pixel would have little or no effect). 
     Computation of Alpha From Depth Texture Comparison 
     A procedure in which depth values are compared against a texture coordinate is disclosed in “Fast Shadows and Lighting Effects Using Texture Mapping”,  Computer Graphics  (SIGGRAPH 1992 Proceedings), Vol. 26, No. 2, July 1992, pages 249-252, by M. Segal, C. Korobkin, R. van WidenFelt, J. Foran, and P. Haeberli. More specifically, this paper details a technique where four depth values fetched from a texture map are compared against a third texture coordinate which is interpolated between values specified at the vertices of the drawing primitive. If the depth texel&#39;s value is equal to or greater than the value of the third texture coordinate, then the texels value is replaced with a value of 1.0 otherwise the value is replaced with a value of 0.0. The resulting four texel values are then bilinearly interpolated to arrive at a single value between 0.0 and 1.0 which replaces the incoming pixel fragment&#39;s alpha value. Thus the fragment color interpolated between values specified at the vertices is attenuated by the alpha value before it is stored in the frame buffer. 
     SUMMARY OF THE INVENTION 
     An object of this invention is to provide a process, referred to as alpha discrimination, that is a method of enhancement to the process of texture mapping and which allows a texture to be selectively applied to incoming pixel fragments. 
     Another object of this invention is to provide an apparatus, called the alpha discriminator design block, which can be inserted into computer graphics rendering hardware to achieve the effects of alpha discrimination. 
     Alpha Discrimination 
     With a preferred embodiment of this invention, the process of aldha discrimination occurs during the rendering of a drawing primitive between the stages of texture memory fetch and texture filter in the traditional graphics pipeline. To enable the process of alpha discrimination, the host application preferably sets a control state variable to a non-zero value. To disable alpha discrimination the host application sets this variable to zero. When the control state variable is set to zero, the process of alpha discrimination merely passes the texel data from the texture memory fetch process to the texture filter process unmodified. When the control state variable is set to a non zero value, the process of alpha discrimination compares the alpha value of each texel fetched from memory against a reference state variable according to criteria specified in the control state variable. 
     With the embodiment described herein in detail, both the reference and control variables are set by the host application prior to issuing commands to begin rendering the drawing primitives which will be affected by them. If the result of the comparison between the texel&#39;s alpha value and the value stored in the reference variable is true, then the bits of the texel specified in the control state variable either retain their original input values or are replaced with ones (depending on whether the control state variable indicates modulation or replacement). Otherwise the bits of the texel specified in the control state variable are cleared. Each modified texel is passed on to the texture filtering process and the alpha discrimination process is complete. 
     For example, the process of alpha discrimination may be controlled by the host application using two control commands: 
     SetTexAlphaDiscriminationCtrl (unsigned CtrlVal) and 
     SetTextureAlphaRef (unsigned RefVal). 
     SetTextureAlphaRef(unsigned RefVal) sets the reference state variable, which may be identified as TextureAlphaRef, to the value specified in the argument RefVal. TextureAlphaRef will retain this value until the next time SetTextureAlphaRef(unsigned RefVal) is issued by the host application. 
     SetTexAlphaDiscriminationCtrl (unsigned CtrlVal) sets the control state variable, which may be identified as TexAlphaDiscriminationCtrl, to the value specified by the argument CtrlVal. TexAlphaDiscriminationCtrl will retain this value until the next time SetTexAlphaDiscriminationCtrl (unsigned CtrlVal) is issued by the host application. The TexAlphaDiscriminationCtrl state variable describes the criteria of comparison, which bits of the fetched texel (if any) are to be modified with the results of the alpha channel&#39;s compare against the reference value, and how those bits are to be modified. 
     Alpha Discriminator Design Block 
     The alpha discriminator design block is an apparatus which may be inserted between the texture memory fetch design block and the texture filter design block of a hardware graphics accelerator. For each texel output provided by the texture memory fetch design block the alpha discriminator has a texel input and a texel output. The alpha discriminator design block has a control word register similar to the TexAlphaDiscriminationCtrl state variable described in the section above and an N-bit reference value register (where N is the number oL bits used to represent alpha in the texel output of the texture memory fetch design block) which is used to hold a reference value similar to the TextureAlphaRef described above. 
     The control word register conveys the criteria of the comparison, which bits (if any) of the incoming texels are to be modified with the results of the compare, and how those bits are to be modified. If the control word states that no bits are to be modified, then the texel data passes through the texture alpha discriminator design block unmodified. In addition, preferably, the control word includes a bit that, when set, specifies that all the alpha bits are to be set to a predetermined constant value such as one. 
     Further benefits and advantages of the invention will become apparent from a consideration of the following detailed description, given with reference to the accompanying drawings, which specify and show preferred embodiments of the invention. 
    
    
     BRIEF DESCRIPTION OF THE DRAWINGS 
     FIG. 1 depicts the location of a Texture Alpha Discriminator design block in a texture mapped graphics pipeline. 
     FIGS. 2A and 2B show the data flow within the process of Alpha Discrimination operating on a single texel. 
     FIG. 3 schematically shows a graphics adapter board having the alpha discriminator design block. 
     FIG. 4 illustrates a computer hardware system that may be used in the practice of this invention. 
     FIGS. 5A-5I shows the C++ source code that performs the process of Alpha Discrimination. 
    
    
     DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS 
     FIG. 1 generally illustrates a portion of a texture mapped graphics pipeline  10 , including a Texture Memory Fetch  12 , a Texture Alpha Discriminator  14 , and a Texture Filter  16 . Generally, in operation, the Texture Memory Fetch retrieves one or more texels from the memory containing texture data, and passes the data into the Texture Alpha Discriminator which may or may not alter the texel data. The Texture Alpha Discriminator passes the texel data to the Texture Filter which blends or selects texel red, green, blue and alpha values. 
     FIGS. 2A and 2B depict data flow within the process of Alpha Discrimination operating on a single texel. The texel data has been fetched from memory, as represented by block  32 . If TexAlphaDiscriminationCtrl states that none of the alpha bits or color bits in the texel are to be modified, as represented by block  33 , the texel data is passed on (unmodified) to the texture filter, as represented by block  35 . If, however, alpha discrimination is enabled, the process proceeds to block  34  where the alpha bits of the input texel data are compared against the TextureAlphaRef state variable using each criteria of comparison enabled in the TexAlphaDiscrimiantionCtrl state variable. 
     If the result of any of the enabled criteria of comparison test as TRUE, then the texture alpha discrimination test result is YES, as represented in block  40 , and the texture data is processed according to a TRUE test result. In contrast, if none of the enabled criteria of comparison test as TRUE, then the texture alpha discrimination test result is NO, as represented by block  42 , and the texture data is processed according to a FALSE test result. With the embodiment of the invention disclosed herein in detail, if any of the enabled criteria compare as TRUE then those bits of the texel which have been specified for modification in the TexAlphaDiscriminationCtrl state variable are modified in the manner specified by the TexAlphaDiscriminationCtrl state variable. 
     In particular, if any of the enabled criteria compare as TRUE, then the process proceeds to block  40  and then to blocks  44  and  46 . However, if none of the enabled criteria compare as TRUE, then the process moves on to blocks  42  and then to blocks  50  and  52 . At blocks  44 ,  46 ,  50  and  52 , the process checks the control word to determine whether the color bits, the alpha bits or both the color and alpha bits are to be modified according to the test results. 
     If, at block  44 , the color bits are to be modified according to the test results, the process proceeds to block  54 , where a check is made to determine whether the alpha discriminator is in the retain or replace mode. If the alpha discriminator is in the replace mode, then the color bits are set to a user specified predetermined value, represented as TrueValue, at block  56 , and then passed on to the texture filter. If the process is in the retain mode, the color bits are passed unmodified to the texture filter at block  60 . Also, if at block  44 , it is determined that the color bits are not to be modified according to the test results, then these bits are passed unmodified to the texture filter at block  62 . 
     If, at block  46 , the alpha bits are to be modified according to the test results, then the procedure moves on to block  64 , where a check is made to determine whether the control work specifies the retain or the replace mode. If the control word specifies the replace mode, then at block  66 , the color bits are replaced with the value TrueValue, and then passed on to the texture filter at block  66 . If the control word specifies the retain mode, the alpha bits are passed unmodified on to the texture filter, as represented by block  70 . 
     If, at block  46 , the alpha bits are not to be modified according to the test results, then the routine proceeds to block  72 , where a check is made to determine whether the control word specifies that the alpha bits are always to be set to 1.0. If this is to be done, those bits are set to 1.0 at block  74 , and this alpha value is passed to the texture filter at block  74 . If the alpha bits are not to be set to 1.0, then the alpha bits are passed unmodified to the texture filter, as represented by block  76 . 
     If, at block  50 , the control word specifies that the color bits are not to be modified according to the test results, then those bits are passed unmodified to the texture filter, as represented by block  80 . If those color bits are to be modified, then they are set to zero and passed on to the texture filter, as represented by block  82 . 
     At block  52 , if the control word specifies that the alpha bits are to be modified according to the test results, the routine proceeds to block  84 , where a check is made to determine whether the control word specifies that the alpha bits are to be set to 1.0. If these bits are to be set to 1.0, this is done at block  86  and the new alpha value is passed on to the texture filter. If the control word does not specify that the alpha bits are to be set to 1.0, then, at block  90 , the alpha bits are set to a user specified predetermined value, represented as FalseValue, and this new alpha value is passed on to the texture filter. 
     At block  52 , if the control word specifies that the alpha bits are not to be modified according to the test results, the routine moves on to block  92 , where, like at block  84 , a check is made to determine whether the control word specifies that the alpha bits are to be set to 1.0. If the alpha bits are to be so set, this is done at block  94  and the new alpha value is sent on to the texture filter. However, if the alpha bits are not to be set to 1.0, then, as represented by block  96 , the alpha bits are passed unmodified on to the texture filter. 
     In the preferred embodiment, as described above, the Texture Alpha Discriminator can be enabled to modify two groups of bits. These two sets are the color bits (those bits representing the Red, Green, and Blue color components in RGB color space) and the alpha bits (those bits used to weight the contribution of the texel color when it is combined or composited with other colors such as the color interpolated across the polygon or stored in the frame buffer) and modification can be enabled for one set, both sets, or no sets. If any bit groups are enabled for modification, then the texture alpha values are tested using the criteria of comparison specified in TexAlphaDiscriminationCtrl but how those bit groups are to the modified is unique for each bit group. 
     In the preferred embodiment there are four criteria of comparison which could be enabled. As discussed above, for the comparison to result in a value of TRUE one or more of the criteria of comparison enabled by the TexAlphaDiscriminationCtrl state variable have to be true. If none of the enabled criteria of comparison result in a value of true then the result of the compare is FALSE. The four criteria of comparison which can be enabled in the preferred embodiemnt are as follows: 
     1) if the alpha value fetched from the memory containing texture data is equal to the TextureAlphaRef value, then return TRUE. 
     2) if the alpha value fetched from memory containing texture data is less than the TextureAlphaRef value, then return TRUE. 
     3) if the alpha value fetched from memory containing texture data is greater than the TextureAlphaRef value, then return TRUE. 
     4) if the alpha value fetched from memory containing texture data is equal to zero, then return TRUE. 
     Graphics pipeline  10  may be included in one integrated chip. This chip, in turn, may be one of several components of a larger board, such as a graphics adapter board, and FIG. 3 schematically shows such a board  100 . This board includes memory fetch  12 , texture alpha discriminator  14 , texture filter  16 , and memory  102 , which contains the texture data values. As will be understood by those of ordinary skill in the art, board  100  may include additional elements. 
     Also, any suitable computer system may be used to practice the invention, and FIG. 4 shows, as an example, one such computer system  110 . System  110  includes a central processing unit  112 , a conventional input keyboard  114 , and a standard monitor  116 . The processing unit includes graphics pipeline  10 , which may be included in an otherwise standard or conventional graphics accelerator, modified as described above to incorporate the alpha discriminator unit. 
     FIGS. 5A-5H show the C++ source code as a detailed embodiment of the TextureAlpha Discriminator design block. This code simulates the function of objects of the alpha discriminator design block of FIG. 1, including memory fetch  12  and alpha discriminator  14 . This code is suitable for use in a C++ hardware graphics architecture simulation. This C++ code defines an object class called Texture Alpha Discriminator which performs the process of Alpha Discrimination on four streams of 32-bit texels and is controlled by a 16-bit command word. In a typical graphics acceleration architecture, a TextureAlpha Discriminator object would be instantiated for each bilinear texture pipeline in the system and placed between the texture memory fetch and the texture filter. The TexAlphaDicriminationCtrl class constructor takes pointer arguments as to where the command word and each of the four input texel data values can be read from and where each of the four output texel data values should be written to. The Go ( ) function should be called once for each clock cycle during the run of the simulation. 
     The data formats used by the detailed embodiment and C++ source code of the detailed embodiment are listed in FIG.  5 I. 
     As described above, a hardware component, the alpha discriminator, is used to perform the appropriate test, and to modify the initial texture values. As will be understood by those of ordinary skill in the art, a software program may be used to perform some or all of the functions of the alpha discriminator. Any suitable software program may be used for this purpose, and the design and implementation of such a software program is well within the ability of those of ordinary skill in the art. 
     While it is apparent that the invention herein disclosed is well calculated to fulfill the objects previously stated, it will be appreciated that numerous modifications and embodiments may be devised by those skilled in the art, and it is intended that the appended claims cover all such modifications and embodiments as fall within the true spirit and scope of the present invention.