Method of operating a computer graphics display system

Abstract: A method of operating a graphics display system to develop parameters to produce realistic shading of three-dimensional objects. Computationally efficient Gouraud shading is practised in the rendering of images which routinely require Phong shading to obtain suitable realism. Gouraud shading is adaptively applied to polygon regions of preferably triangular shape at a granularity defined by heuristically derived relationships using surface normal vectors, incident light vectors and relative pixel separation information. When division of the base triangle is dictated, the methodology produces a mesh of polygons sized to be individually rendered with Gouraud shading yet provide Phong-like realism for the whole of the original polygon region.

Description: The present invention relates in general to a method of operating a computer graphics display system to determine the intensity and color parameters used to render shaded patterns on a video display. Static and dynamic three dimensional images are routinely generated by conventional workstation grade computers. The effects of light impinging on and reflected from the three dimensional surfaces being rendered requires that the color parameter calculations account for object surface contour and light source location characteristics. Fundamentally, the fewer the discontinuities in the rendered shading the greater the realism of the image being portrayed. The ideal method of shading a simulated object subject to display involves the individualized calculation of intensity and hue for each pixel depicted on the screen. Unfortunately, workstation video display screens routinely have well in excess of one million pixels. The computational burden associated with such idealized methods of shading is very significant, resulting in slow real time image regeneration. The delays in rendering shaded patterns would obviously become quite pronounced and unacceptable for images of dynamic objects. Intensity interpolation shading, generally referred to as Gouraud shading, and normal vector interpolation shading, generally referred to as Phong shading, are described in the text books "Fundamentals of Interactive Computer Graphics" by Foley et al, an Addison-Wesley publication of copyright 1982, and "Computer Graphics" by Hearn et al, a Prentice-Hall publication of copyright 1986. Refinements in the interpolation of intensity magnitudes are described in U.S. Patent 4,805,116. A refined use of a raster scan display to render polygon objects is described in U.S. patent No. 4,725,831. In general, Gouraud shading involves the calculation of intensity values at the vertices of defined polygons followed by linear interpolations of intensity for the remaining surface of the polygon from such vertex values. Though computationally efficient, the Gouraud method of shading ignores the non-linear relationships between the incident light vectors, the surface normal vectors, and the intensity of the reflected light. The Phong shading method linearly interpolates the surface normal vectors between polygon vertices, rather than the intensity itself. Thereafter, such interpolated vectors are used to calculate the intensity at each pixel position within the polygon to account for incident light location and surface normal orientation effects on the derived intensity for each pixel. The computational burden of such custom rendering by pixel is significant. Experience with the shaded rendering of numerous images has confirmed that Gouraud shading is quite adequate and realistic for image surfaces having certain types of illumination and surface normal characteristics, yet woefully inadequate for adjacent image areas with somewhat different sets of such characteristics. Consequently, if Gouraud shading is implemented to ease the computational burden, image realism degrades significantly for some, but not all, objects. On the other hand, if Phong shading is utilized for rendering serious technical problems arise in terms of generation speed and image dynamic capability. While such problems can be met to some extent by providing substantially increased computing capacity, the cost of doing so is high, and in the workstation environment can be prohibitive. It is accordingly an object of the present invention to provide a method of operating a computer graphics display system which permits the realism of Phong-type shading to be approached without adding substantially to the processing demands on the system. European Patent Application 0 366 463 discloses a recursive approach for shading a polygon wherein the polygon is divided into triangles and triangles that are determined to be too large to be realistically shaded using intensity interpolation are further subdivided into four triangles. The determination is made by calculating whether the vertices are coplanar (or near coplanar) and subdividing if they are not. According to claim 1, the invention provides an adaptive method for shading patterns in a graphics rendering system, comprising the steps of selecting a polygon within a graphic pattern to be shaded, said selected polygon having a plurality of vertices, eacn vertex having an associated surface normal vector and each vertex having an incident light vector corresponding to each of one or more light sources; and using intensity interpolation to perform shading of the polygons; characterised in that the method further comprises the steps, prior to performing shading, of for each of the one or more light sources: calculating cross products of surface normal vectors and related incident light vectors for selected vertices; calculating a dot product (EDGE_CROSSDOT) of two of said cross products to determine the orientation of the related incident light vector relative to the edge joining the vertices associated with said two cross products; calculating first (DOT1) and second (DOT2) dot products of the selected surface normal vectors and the related incident light vector; relating the first and second dot products and the orientation of the incident light vector to the distance between the selected surface normal vectors; responsive to said relating step, determining heuristically whether to divide the selected polygon into further polygons; and responsive to said determining step, dividing the selected polygon into further polygons thereby defining at least one new vertex, and computing the corresponding vector characteristics of the at least one new vertex. In a preferred embodiment of the invention, the surface normal vectors at the polygon vertices are first related to the incident light vectors and then compared as to relative location. The results are evaluated to derive a heuristical measure of the division needed for realistic rendering. The invention then practices a systematic partitioning of the polygon in keeping with the heuristically defined division for individualized Gouraud shading. A particular implementation of the invention involves the use of triangular polygon regions. According to such practice, the incident light and surface normal vector dot products at the triangle corners are calculated and compared. If found to exhibit values above established thresholds, the related edges are heuristically divided. The granularity of the divided triangles is consistent with that required to render objects in near Phong grade realism. The triangles in the mesh defined by such division are individually rendered by Gouraud shading. These and other features of the present process will be more clearly understood and fully appreciated upon considering the detailed description set forth hereinafter. Brief Description of the Drawings Fig. 1 is a schematic depiction of a region within an image on a video display. Fig. 2 is a schematic depiction of a triangular region subject to division according to one aspect of the present method, at an intermediate stage. Fig. 3 is a schematic depiction of the triangular region in Fig. 2 following division into a triangular mesh suitable for Gouraud method shading. Fig. 4 is a schematic of functional blocks by which surface shading can be accomplished. Fig. 5 is a schematic having a flow diagram for practising adaptive near Phong shading. Description of the Preferred Embodiment The present invention as preferably practised uses heuristic information to adaptively reconfigure polygon regions which would conventionally require Phong shading for realism to regions of a size and shape suitable for rendering with Gouraud shading hardware. For many surface and lighting situations three dimensional objects rendered by unrefined Gouraud shading suffer from numerous visually detracting deficiencies, the prevailing examples being an absence of specular highlights and the presence of mach banding. Consequently, the developers of a 3-D video graphics systems with shading are placed in the dilemma of providing hardware which performs pure Gouraud shading at a suitable rate but with inherent deficiencies as to realism, or providing significantly more complex hardware to perform pure Phong shading but at a materially slower pattern rendering rate, or possibly providing both forms of hardware, at a significantly greater system cost, with selective use depending on the demands of the application. Implementation of the two shading techniques through software is not practical given that such rendering is multiple orders of magnitude slower. The present invention avoids the duplication of shading hardware while providing the requisite degree of realism by utilizing an implementation of Gouraud shading which is adaptively compensated in the direction of Phong shading. In such selectively implemented practice, the classic deficiencies of Gouraud shading are eliminated without the hardware cost, computational complexity, and speed deficiencies characterizing pure Phong shading. The three objectives of realism, speed and hardware simplicity were satisfied upon appreciating that Gouraud shading could be practised at heuristically defined finer levels of granularity without reaching the ultimate level of pure Phong shading. In the context of such an approach, the method involves the practice of conventional Gouraud shading when the surface subject to shading would not benefit meaning-fully from a refinement, yet provides an adaptive division and rendering of the polygon region to attain near Phong grade shading when the lighting conditions and surface contours so require. The present method is derived from an appreciation of the relationships which affect rendering realism, being based upon the general premise that a typical graphics image requires Phong grade shading only in regions where the surface normals and incident light vectors are changing rapidly. Thus, the slow rendering speed and hardware costs of pure Phong shading provide no material returns in regions where the surface normals and incident light vectors are relatively stable. The presently implemented adaptive method differentiates and adjusts the shading operation depending on the rates of change of the surface normals and incident light vectors by combining the fundamental Gouraud shading method with heuristically defined decision and partitioning operations to practice refined Gouraud shading. The shading method of the present invention shall be described in the context of providing adaptive shading for a polygon shaped region as might appear on a graphics video display. The particular, the method will involve the analysis and refinement of a triangle shaped 3-D polygon region subject to rendering on high resolution raster scan color video display. However, the method is not limited to that application, in that it may be practised in the context of other display technologies as well as those technologies which create hard copies of the images subject to shaded rendering. Fig. 1 schematically illustrates a triangular region 1 defined to be a part of 3-D object 2 and subject to shaded rendering on video display 3. Object 2 is illuminated by collimated incident light vector I. Analysis with multiple non-collimated light sources merely increases the number of calculation and evaluation operations. Object 2 is considered to be 3-dimensional and non-planar, with surface normals S N1 , S N2 and S N3 at the three vertices of triangular region 1. A scan line 4 of the video display 3 is shown crossing triangle 1. The practice of pure Phong shading would first entail an interpolation of the surface normal vectors so as define a vector for each pixel position between pixels 6 and 7, 6 and 7 being located on the perimeters of triangle 1. The calculation of the reflected light at each such pixel position would then be accomplished using each interpolated polated surface normal vector and the incident light vectors impinging each of such pixel positions. The calculations would be repeated for each and every pixel within triangular region 1. Shading of triangle 1 according to the Gouraud convention, on the other hand, would involve three calculations of reflected light, one at each of the triangle vertices. Thereafter, the reflected light intensities at positions such as triangle boundary pixels 6 and 7 would be determined from an interpolation of the vertex values. The intensity characteristics of the pixels along scan line 4, between triangle boundary pixels 6 and 7, would involve further linear interpolations using the values previously derived for perimeter pixels 6 and 7. Since interpolations are significantly easier and faster to compute than the reflected light characteristics for each pixel, Gouraud shading is the norm for rendering 3-D objects in graphics display systems. The present method provides near Phong grade shading, yet is implemented with the method and hardware of Gouraud shading. It involves an analysis of the polygon, a triangle, and the light characteristics followed by a heuristically derived adaptive division of the triangle into a mesh of triangles whose granularity is suitable for individualized Gouraud shading. The preferred practice of the present invention will be described in the context of triangular region 8, depicted in Fig. 2 and 3 at different stages of triangle mesh generation. Fig. 4 depicts by functional block diagram the operations associated with surface shading, also showing the relation of practising adaptive near Phong shading to that of Gouraud shading alone. Fig. 5 presents a flow diagram of the adaptive near Phong shading method to which the invention pertains. As a first step, the present method involves a determination of whether triangle 8 with vertices A, B, C would benefit meaningfully from Phong shading. If not, the triangle can be rendered directly using the Gouraud method with Gouraud shading hardware. In the context of a high resolution color graphics video display application, the first step heuristics of the present process leads one to compute the average of the X axis and Y axis pixel excursions for each edge of the triangle ((X excursion + Y excursion )/2 by edge). Each average excursion is identified as an edge variable. If any one of the three edge variables is greater than 12, the method initiates division of the triangle into a mesh of triangles. Upon concluding that division may be necessary, the preferred process involves a calculation of cross products of values relating to each vertex A, B and C of the triangle. Each cross product involves the surface normal vector at the vertex and a vertex related incident light vector, for each individual light source. The dot products of the cross products for pairs of vertices are computed in the next incremental step. The three dot products, identified as edge_crossdot in Fig. 5, are related to edges, the edges which join the respective triangle vertices. If a dot product is negative in value, the light source is situated between the vertices of the related edge. A positive value, on the other hand, denotes that the light source lies to one side of both vertices, with reference to the edge joining such vertices. Next, a dot product of the two surface normal vectors and related incident light vectors is calculated for the specified vertices which make up each edge. The values so derived are identified as edge_dot in Fig. 5. If the light source was found to lie between the vertices the angular orientations as represented by the dot products are summed to establish the relative disparity of surface normal and light vector interactions at the two vertices. This evaluation is represented in Fig. 5 by the subtraction of both dot products from the constant value of 2.0. For a light source situated to one side of both vertices the relative effect is based upon the difference of the angular orientations, as represented by the difference in dot products. The concluding values by triangle edge are positively valued or truncated as necessary before use with Table I as the edge dot values. Examples of edge dot values and surface normal/lighting interactions illustrate the information conveyed by such numerical values. As a first example, take the situation where the vertex normal vectors are relatively aligned and the light source is situated at a significant distance from the triangular region being illuminated. For such a situation, the edge dot values for the three edges are approximately identical and of a magnitude near zero. Therefore, Gouraud shading can be applied directly to the triangular region, given that finer granularity would provide negligible improvement in shading realism. A different situation exists when the vertex normal vectors vary significantly, even though the light source remains located at a distance from the triangular region being illuminated. In this situation the dot products and related edge dot values differ significantly because the surface normal vectors are not consistent from vertex to vertex. The three edge dot values will be materially greater than zero but not fully approaching 1.0. Therefore, the heuristic rules mandate that the base triangle be divided somewhat to ensure shading realism. A third combination of vertex normal and incident light vectors is represented by the situation where the vertex normal vectors are relatively consistent but the light source is relatively close to the triangular surface. With the incident light vector differing at each of the vertex locations, the dot products and related edge dot values again differ materially. The three edge dot values are therefore materially greater than zero but not fully approaching 1.0. The base triangle should again be divided for shading realism, here as a consequence of the light position rather than any surface normal vector diversity. As a final example of the interaction between the surface normal vectors and the incident light vectors, consider the situation where the vertex normal vectors differ significantly and the light source is fairly close to the triangular region on the illuminated object. In this case, one immediately recognizes that the edge dot values will be approaching 1.0 and as such mandate an accentuated level of division for realistic shading. Heuristic evaluations have established that Phong-like realism can be attained when the degree of division defined in Table I is combined with Gouraud shading for each triangular region in the mesh. The inputs to Table I are the edge dot values for selected pairs of base triangle vertices and the corresponding maximum of the X or Y direction excursions between such pair of vertices by pixel. The table output represents the heuristically defined number of division segments for the base triangle edge lying between the selected vertices. Using the base triangle in Fig. 2 as an example, if the edge dot value of the A and B vertices is .70, and (X + Y)/2 = 20, Table I establishes that the triangle edge defined by the line between A and B should be divided into three segments, such as with pixels K and L. Average Excursion (( X + Y)/2) Edge Variable Edge Dot 10 15 20 25 30 35 40 >45 .60< 1 2 2 3 3 4 4 5 .65 2 2 3 3 4 4 5 5 .70 2 3 3 4 4 5 5 6 .75 3 3 4 4 5 5 6 6 .80 3 4 4 5 5 6 6 7 .85 4 4 5 5 6 6 7 7 .90 4 5 5 6 6 7 7 8 .95 5 5 6 6 7 7 8 8 Use closest fit edge dot value The operations which culminated with the use of Table I provide heuristically derived quantitative and information suitable to divide the base triangle and provide Phong-like realism by using Gouraud shading practices and hardware. One now only needs to divide the base triangle interior according to a methodology which comports with the edge division requirements to create a mesh of individual triangles suitable for individualized Gouraud shading. These objectives are satisfied by judiciously applying the division information acquired from Table I. As a first step in dividing the base triangle into a mesh of triangles, the Table I division numbers are compared to determine the edge having the greatest division requirement. In the case of a tie, a random selection is performed. The vertex opposite the edge having the greatest division count is identified as the mesh origin. In the example base triangle of Fig. 2, presume that Table I has defined that base triangle edge AB must be divided into three segments, base triangle edge BC must be divided into four segments, and base triangle edge CA must be divided into two segments. This establishes that the mesh origin coincides with vertex A has BC as the edge opposite the origin. As a next step, the number of divisions for the two edges projecting from the mesh origin are compared in magnitude. The greater of the two is identified as the edge defining the number of meshes. In the event of a tie, one is selected at random. For the illustrative base triangle in Fig. 2, edge AB is the edge defining the number of meshes. The division information for the two edges AB and BC is then used to generate the mesh internal to the base triangle 8. First, the edge opposite the origin is divided according to the count obtained from Table I to define the locations of pixels M, N and P. A simple table driven algorithm for accomplishing this division of a triangle edge involves the use of the relationship: x = x0 + t(x1 - x0) where 0 <= t <= 1 The values for t are read from a table which is easily generated for each numerical count of the divisions. For example, for eight divisions t = .125, .25, .375, .5, .625, .75, .875 and 1. As illustrated in Fig. 2, such divided pixel locations of M and P thereafter establish the end points for the mesh lines radiating from mesh origin A, such as the dashed line AM and the dashed line emanating from mesh origin pixel A to edge situated pixel N. With the lines emanating from mesh origin A established, the algorithm noted earlier is applied to define the locations of pixels K and L along base triangle edge AB. A similar operation is then performed along line AM, so as to define division pixels at locations AM1 and AM2. Thereafter, triangle mesh lines are defined between pixels AM1 and K, pixels AM1 and L L, pixels AM2 and and pixels AM2 and B. The procedure is then repeated for the line defined between mesh origin pixel A and pixel N, for the line defined between pixels A and P, and finally for the edge CA. In each case, the lines projecting from mesh origin A are divided by the number value established for edge AB, which for the illustration in Fig. 2 requires that each line, and the concluding edge CA, be divided into three segments. The final shape of the mesh is depicted in Fig. 3. Other triangle mesh generating techniques may be used as long as the number of divisions defined for each edge of the base triangle is no less than that prescribed by Table I. In the event a different mesh generating technique is practised, care should be exercised to ensure that the mesh is not backfacing. Preferably, the triangles in the mesh of Fig. 3 are as a concluding step further subdivided by two, if necessary to have one horizontally disposed edge. The triangles are then individually rendered by Gouraud shading hardware, which shading now utilizes vector normal information of significantly greater granularity, but not to the ultimate level of pure Phong shading. The images so rendered exhibit realism approaching that of Phong shading yet at a computational and hardware cost more closely approaching the practice of conventional Gouraud shading. The adaptive shading method of the present invention is particularly beneficial in that it can be implemented with the lower complexity rendering graphics hardware used for Gouraud shading, is selectively applied to base triangles only when division of base triangle is necessary to attain further shading realism, is further selective in that the base triangle is divided only to the extent reasonably necessary to attain realistic shading as defined by the interaction of the surface normal vectors and incident light vectors, utilizes a structured methodology for dividing the base triangle, and produces concluding shapes which are amenable to the triangle pattern Gouraud shading hardware. Though the invention has been described illustrated by way of specific embodiment, the method of the invention should be understood to encompass the full scope of practices defined by the claims set forth hereinafter.

Claims: An adaptive method for shading patterns in a graphics rendering system, comprising the steps of: selecting a polygon within a graphic pattern to be shaded, said selected polygon having a plurality of vertices, each vertex having an associated surface normal vector and each vertex having an incident light vector corresponding to each of one or more light sources; and using intensity interpolation to perform shading of the polygons; characterised in that the method further comprises the steps, prior to performing shading, of: for each of the one or more light sources: calculating cross products of surface normal vectors and related incident light vectors for selected vertices; calculating a dot product (EDGE_CROSSDOT) of two of said cross products to determine the orientation of the related incident light vector relative to the edge joining the vertices associated with said two cross products; calculating first (DOT1) and second (DOT2) dot products of the selected surface normal vectors and the related incident light vector; relating the first and second dot products and the orientation of the incident light vector to the distance between the selected surface normal vectors, responsive to said relating step, determining heuristically whether to divide the selected polygon into further polygons; and responsive to said determining step, dividing the selected polygon into further polygons thereby defining at least one new vertex, and computing the corresponding vector characteristics of the at least one new vertex. A method as claimed in Claim 1, wherein the selected polygon is a triangle. A method as claimed in any of Claims 1 to 2 wherein the interpolation includes the application of Gouraud shading to the divided polygons. A method as claimed in any preceding claim wherein the selected polygon is a triangle and the step of dividing includes partitioning the selected triangle into two or more triangles. A method recited in any preceding claim, wherein the step of dividing is comprised of: selecting the triangle edge subject to the greatest segmentation; projecting triangle division lines from the selected edge to the vertex opposite that edge; and further partitioning the regions defined by the partitioning in relation to the segmentation ascribed to a second side of the triangle.

Inventors: EINKAUF MARK ALAN, KLOCK MICHAEL MARTIN, LE NGOCHA THI, EINKAUF, MARK ALAN, KLOCK, MICHAEL MARTIN
Applicants: IBM, INTERNATIONAL BUSINESS MACHINES CORPORATION
Application year: 1991
Main classification: G06T15
IPC codes: G06T15