ON THE RENDERING OF SURFACES

ON THE RENDERING OF SURFACES A.R. Forrest University of Utah* Salt Lake City, UT84112 ABSTRACT of analytic models for surfaces. Here the pioneer wor...
Author: Shanna Dennis
2 downloads 0 Views 2MB Size
ON THE RENDERING OF SURFACES A.R. Forrest University of Utah* Salt Lake City, UT84112

ABSTRACT

of analytic models for surfaces. Here the pioneer work of Coons and others is well-known. It is now cormnon practice to represent a surface in terms of a mathematical model (usually analytic equations), and to use the model to derive drawings of various forms. The ability rapidly to generate complex drawings from a computer model and to display these drawings on a c.r.t, or plotter has proved of great use in practice. Nevertheless, it is the contention of the author that the methods used to display arbitrary surfaces are still ambiguous, uninformative, and imprecise. In this paper we survey some of the methods conmnonly used, highlighting their drawbacks, and suggest more meaningful methods which exploit recent advances in raster graphics technology. In particular we concentrate on the presentation of surfaces for engineering design and manufacture, rather than for animation, simulation, etc.

Despite the relative sophistication of modern surface design systems, many graphical renderings of surfaces are rather crude. The paper discusses several possible renderings, including various line drawings methods, realistic and functional shading, and combinations of line drawings and smooth shading. It concludes that a good choice is the superposition of contours or sections on either realistic or Gaussian curvature shading. KEY WORDS AND PHRASES: Computer

graphics, raster graphics, computational geometry, computer-aided geometric design, visualisation, sculptured surfaces, hidden-surface removal, smooth shading.

CR CATEGORIES: 3.26, 5.13, 8.2

1. INTRODUCTION

2. CONVENTIONAL TECHNIQUES - LINE DRAWINGS

One of the classic problems in computer graphics (4,5) is the modelling and rendering of surfaces in three-dimensional space the so-called sculptured surfaces. A fundamental reason for the considerable amount of research carried out in the 1960's was the ambiguity of conventional engineering drawings when applied to arbitrary surfaces. It is impossible, in general, to define doubly-curved surfaces in terms of a finite number of planar line drawings (although particular doubly-curved surfaces such as ellipsoids, surfaces of revolution, etc. can be defined uniquely in terms of planar line drawings); the problem may be overcome by the use

We shall consider rendering of surfaces in the context of c.r.t, displays, calligraphic or raster, since most of the techniques are applicable to other devices (such as plotters) in some form or another. Before doing so, two methods of display must be mentioned: dynamic display and solid model generation. With the availability of high-performance displays with transformation hardware, it is relatively simple to cause a three-dimensional line-drawing image to rotate, etc. in real time. Leaving aside consideration of what kind of line drawing we should display, there is no doubt that dynamic display considerably enhances our understanding of the shape of a three-dimensional object. We obtain a "vivid impression of the three-dimensional shape, but the very nature of the image - dynamic - makes it difficult to obtain precise knowledge of that shape. We cannot measure a dynamic image, so the insight we gain into the shape is transient and somewhat subjective. This is not to decry the utility of dynamic display, but to point out that it is of limited scope in the precise delineation of shape.

* Current address: University of East Anglia, Norwich NR4 7TJ, England. This research sponsored by NSF Grant MCS 78 01966: Computer Aided Geometric Design, Principal Investigator R.F. Riesenfeld, University of Utah, Computer Science.

The author and others (],6,8) have pointed out on several occasions the benefits of solid model generation. Figure ] shows a B-spline surface cut by the author on a computer-controlled model-making machine at the University of Cambridge. It is sometimes useful to consider numerically-controlled machine tools as

©1979 ACM 0-89791-004--4/79/0800--253 $00.75 See Copyright Pg

253

three-dimensional plotters which have 'pens' of finite thickness and geometry, but a relatively slow drawing speed. At Cambridge and the University of East Anglia, model-making machines are regarded as graphical devices and are programmed as such: code-generators for the GINO-F device-independent graphics package (13) have been written. The main benefits of solid output - three-dimensional hard copy - are: lack of ambiguity, precise depiction of shape, automatic generation of all possible hidden-surface removed images, with or without shadows, and the ability to handle the model (the sense of touch reveals aspects of a shape which are, at first, invisible to the eye). The disadvantages of such output are the speed of generation (approximately |0 minutes for Fig. ! on the current Cambridge machine), and the inability to interact with the model.

to the shape of the surface. Contour lines have an exact, unambiguous, geometric interpretation: they relate directly to the shape of the surface. Figure 4 could have been made clearer either by colour coding the contour or otherwise identifying the levels. It is arguable that of all the line drawings possible, a set of surface sections is the most useful in determining shape. The main drawback is that, compared to lines of constant parameter, sections are difficult to compute; nevertheless, the additional computational effort appears well worthwhile.

Turning now to static c.r.t, images, consider Fig. 2. Here we display a single parametric bicubic surface patch as a 9x9 mesh of lines of constant parameter. Parametric lines are the easiest lines to compute, and the parametric wire-frame mesh is probably the most con~nonly used method for displaying such a patch. Unfortunately, parametric lines are generally of limited use since they convey little geometric information. It is possible to draw many parametric families on a surface, but unless we can attach some geometric meaning to them, they remain simply tracks on the surface, aid in the sense that a street plan gives little indication of topography, so parametric meshes give little indication of surface shape. This is particularly true of the surface in Fig. 2.

3. CONVENTIONAL TECHNIQUES - SMOOTH SHADING

Figure 5 is a blend of Figs. 2 and 4, demonstrating that the parametric lines give no indication of the 'cliff' running top to bottom across the middle of the surface, or of the saddle region at the bottom centre of the patch.

With the reduction in cost of raster displays, there has been a renewed interest in efficient algorithms for generating realistic smooth shaded images (2,7,12). In contrast to earlier methods where the surface first had to be approximated, rather crudely, by a somewhat random collection of planar polygons and the discontinuities in the planar approximation were 'ironed outut' by smooth shading, the recent algorithms approximate the surface in a geometrically sensible manner and the smooth shading is a close approximation to the true shading. Figure 6 is a smooth shaded image which involves no approximations except those inherent in pixel resolution, with highlights computed according to the method suggested by Phong (10). The surface is yellow on one side and cyan on the reverse. Figure 6 is certainly realistic, and gives a good notion of shape. On the other hand, it is subject to more than one interpretation, with hollows sometimes being seen as hilltops and vice versa. As with all other smooth shaded images which attempt to give a realistic image, what we obtain is an impression of the shape rather than a precise, quantifiable image - we cannot measure the image and hence we cannot obtain accurate information regarding the surface shape: that is to say, we cannot pass Fig. 6 to a machine shop and expect it to be manufactured. We can overcome the ambiguity of interpretation by more sophisticated shading techniques. In Fig. 6 the light source is coincident with the eye point; in Fig. 7, the eye point is the same, but the light source is above the surface and to the left and below the image. (The shading in Fig. 7 is rather crude due to the quick-and-dirty algorithm employed.) Despite recent advances, it is probably too expensive to contemplate generating multiple shaded images of a single surface merely to remove some latent ambiguities.

Hidden line elimination serves to reduce the clutter and increase our understanding of an image, but it will not materially aid our perception of a mesh of parametric lines. Similarly, perspective is of little use, since unless we can relate a perspective image of the surface to a perspective image of an object of known sbape, we cannot tell whether we are viewing in perspective or merely viewing an orthogonal projection of some distorted shape. Stereo images, like dynamic images, yield a vivid impression of shape, but are non-metric in the sense that the images cannot readily be used to convey precise information regarding shape. Since parametric lines can wander meaninglessly over a surface, one technique used to overcome the lack of geometric information is to plot surface normals, Fig. 3. In many circumstances, surface normals, which have a precise geometric interpretation, substantially aid visualisation, particularly where the surfaces are not highly contorted. In such cases, subtle variations in shape are amplified (see Newman and Sproull (9) for a good example). For our sample surface, normals merely add to visual clutter since the surface is highly contorted.

4. LINE DRAWINGS AND SHADED IMAGES The great merit of smooth shading is that we display information relating to the surface at every visible point on the surface, to device resolution, rather than at discrete intervals. Line drawings, on the other hand, provide metric information, but are open to variou~ interpretations between the lines. It seems logical, therefore, to explore the combination of

A more useful type of line drawing to generate is a set of sections or contours, as in Fig. 4. Here we draw plane sections parallel to the screen and at equal intervals in depth. The surface patch is rendered with boundary curves and silhouette lines in white and contours in pink. We can now begin to gain some precise information as

254

line drawings and smooth shaded images. Figure 8 demonstrates the effect of overlaying a parametric mesh on a shaded image. We see, as we might have predicted, that parameter lines add little, if anything, to our comprehension. In Fig. 9, however, the combination of smooth shading and contours does aid our understanding. The smooth shading interpolates the contour lines in a sensible manner, with the two methods of rendering conbining synergically.

E=P

.P

F=P

.P

Similarly, let

and G=P

.P --V

--V

Let N denote the surface normal vector: N = P xP

One of the motivations for the research behind this paper was the observation, made by many others, that it is possible to generate line drawings of surprisingly high quality on a raster display. Time did not permit the development of anti-aliasing or anti-rastering techniques for the lines, silhouettes and outlines in the Figures here; the problem is complicated by the continuous tones of the background on which the lines are to be drawn, and a more sophisticated approach is necessary. Despite these current limitations in image quality, the author is encouraged to continue the approach of combining shaded and line images.

then: L = P M = P

N = P

.N

The mean and Gaussian curvatures are then: H=

EN + GL - 2FM 2 (EG - F 2) LN - M 2 ( E G - F 2)

In Fig. 1 I, a shading function based on mean curvature is used. Blue regions are regions where the mean curvature is positive, with a shading towards white for high values of curvature. Red regions are regions where the curvature is negative, again with high mean curvature shading towards white. Green regions are regions where the mean curvature is approximately zero. Mean curvature, to some extent, measures how highly curved the surface is, but regions of high curvature where the principal curvatures are of opposite sign will have a mean curvature effectively of zero. It is instructive to a mathematician to examine mean curvature plots, and possibly they provide a useful way of highlighting subtle variations of shape which might be of interest to those concerned with surface smoothness or fairness. In Fig. 12, Gaussian curvature is plotted as a colour function. The sign convention and shading law of Fig. 11 is used but the interpretation of the colour plot is easier. In blue regions, both principal curvatures are of the same sign: the surface is locally ellipsoidal in nature, and blue regions are therefore hilltops or hollows. Red regions depict areas where the principal curvatures are of opposite sign: the surface is hyperboloidal in form and red regions are saddle areas. In green regions, one or more of the principal curvatures is effectively zero. Green regions are ridges or valleys, or, if both principal curvatures are effectively zero, planes. Gaussian curvature, therefore, is a good indication of surface shape, being somewhat more precise than realistic shading in terms of conveying geometric information. We can tell, for example, that the hollow to the left centre of the patch is much less highly curved than the peak at right centre, and that the saddle at bottom centre is highly contorted. Figures |I and 12 also demonstrate once more the combination of line drawings with shaded images.

A standard result in differential geometry shows that the normal curvature of a surface (the curvature measured in a plane containing the normal to the surface) has a minimum value k. m l . • and a maximum value k (the prlnclpa~ max curvatures). The mean curvature of the surface, H, is given by: H = 2(kmi n + kma x) and the Gaussian or total curvature K is given by: K = k . .k mln max

be

--

--vv--

In Fig. I0, we add to the shaded image with parameter lines and contour lines, highlighting of a non-realistic kind. The bright red spots indicate regions on the surface where the use of a spherical cutter of specified radius would interfere with the surface and cause goudging - we depict such regions by 'drawing blood'. (The model in Fig. 1 has some goudged regions which may be visible in the photograph.) We can think of other modifications of shading to highlight similar regions of importance to the user. On the other hand, we might consider employing other shading rules which aid our comprehension of shape or display other information regarding the properties of our design. Here one must cite the pioneering work of Christiansen at Brigham Young University who used colour shading to display variations in the stress and strain of engineering structures (3). Figures II and 12 show the sample surface painted with shading which is related to the curvature of the surface, and which therefore has a strictly geometric interpretation.

E

.N

and

5. NON-REALISTIC SHADED IMAGES

Let vectors:

--

--UV

K=

If the surface patch has the equation ~(u,v), then we can curvatures as follows.

.N

--BU

vector-valued compute the

the dot product of the u tangent

255

6. PRODUCING THE FIGURES

7. CONCLUSIONS

We have already discussed how Fig. I was generated. The remaining Figures were produced by an experimental hidden surface program written by the author for the Grinnell frame buffer at the University of Utah. This frame buffer has 512x512 resolution with 27 bits per pixel (24 bits for colour and 3 overlay bits). The algorithm employed is crude but effective, and is based on a technique proposed by the author in 1970 for hidden surface elimination using a silicon target storage tube as a Z-buffer. Since the author never had access to such a device, the algorithm was never published. Briefly, a surface patch P(u,v) is scanned in raster fashion in the u-v plane. A z value is stored at the corresponding x-y pixel if it represents a point nearer to the viewer than the current z value stored in that pixel. If a new value of z is written, a bit is set in one of the overlay planes at the corresponding u-v pixel. After one pass through the surface, the overlay plane contains a u-v map of points on the surface which are visible or which will be overwritten if the surface is scanned out in the same u-v order. If desired, a second scanning pass will eliminate points which will be overwritten, leaving a u-v map of visible regions of the surface. One advantage of the algorithm is that apart from the overlay bits the entire pixel storage can be used for z comparisons rather than devoting half of the pixel storage to z and half to shading information. Shading is then generated using the u-v map to look up visible points. Just as the Weiler and Atherton hidden line algorithm (]I) generates as output a marked data structure which can be scanned subsequently to produce a picture, so the author's algorithm outputs a marked surface data structure rather than a picture. Other u-v maps may be constructed to represent shadow information.

The pros and cons of various methods for curved surface rendering have been discussed. It is suggested that the best form of line drawing is a set of planar sections through a surface rather than a mesh of parameter lines. Realistic smooth shading gives a good impression of shape, but there are advantages in using Gaussian curvature shading if a more exact presentation of shape is required. The main conclusion, however, is that there is a lot to be gained by combining the positionally precise but discrete information of a line drawing with continuous information provided by shading. In the past, engineers have tended to employ line drawings because they can be constructed precisely in a constrained manner using drafting instruments. Smooth shading previously has been the prerogative of the artist, free-form in nature. Raster displays allied to computers open up possibilities for the use of constructive, constrained, functional shading which, apart from the examples of Christiansen (3), are little exploited. 8. ACKNOWLEDGEMENTS The author is grateful to the Computer Science Department, University of Utah, f o r support and the use of facilities in preparing this paper, and to Brian Barsky and Spencer Thomas for frame buffer software and advice. Photographs were the responsibility of Mike Milochik. The research was partially sponsored by the U.K. Science Research Council Grant GR/A 845]6: Investigations in Computational Geometry and Computer-Aided Geometric Design. 9. REFERENCES

The u-v map is subsequently used in scanning out the surface, again in u-v order, to determine which pixels to paint. Smooth shaded images • are generated on the first pass, if required, and line drawings are generated by a second pass. The resolution of the u-v map is chosen to be similar to that of the eventual image in terms of pixels. Occasionally a miss-match occurs, leaving one-pixel holes in the image, but these holes are filled most effectively by a simple averaging technique. The algorithm was selected for its ease of implementation, and is not as fast as recent algorithms for shaded rendering. However, output of the u-v map is essential for generating combinations of shaded and line images. On a PDP 11/34, the u-v map takes approximately 4 minutes to compute for the sample surface. Given the u-v map, the time to generate a Figure varies from 20 seconds for a line drawing to 2 minutes for a curvature plot which involves a fair amount of numerical computation. For the purposes of this paper, the algorithm suffices; a more sophisticated algorithm would be selected for a production system.

256

(])

B~zier, P.E. Numerical Control - Mathematics and Applications. Wiley I, London, 1972.

(2)

Blinn, J.F. A scan line algorithm for displaying parametrically defined surfaces. Proc. ACM SIGGRAPH Conference, 1978.

(3)

Christiansen, H. Applications of continuous tone computer generated images in structural mechanics. In Structural Mechanics Computer Prosrams - Surveys, Assessments and Availability, Eds.Pilkey, Saczalski and Schaeffer, University Press of Virginia, 1974.

(4)

Coons, S.A. Surfaces design of space forms. TR-41, June 1967.

(5)

Forrest, A.R. Curves and surfaces for computer-aided design. Ph.D. Thesis, University of Cambridge, July 1968.

(6)

Forrest, A.R. A computer peripheral for making three-dimensional models. Automatisme 19, 6/7 (June/July 1976).

(7)

Lane, J.M. and Carpenter, L. A scan-line algorithm for the computer display of parametrically defined surfaces. Boeing Commercial Airplan Company, 1978, submitted for publication.

for computer aided M.I.T. Project MAC,

(8)

Lang, C.A. A three-dimensional model making machine. Cambridge University Computer-Aided Design Group Doc. 74, September 1972.

(9)

Newman, W.M. and Sproull, R.F. Principles of Interactive Compute F Graphics (2nd Edition). McGraw-Hill, New York, 1979.

(io)

Phong, B.T. Illumination for generated images. C o m . ACM 18, ]975).

(11)

Weiler, K. and Atherton, P. Hidden surface removal using polygon area sorting. Proc. ACM SlGGRAPH Conference, 1977.

(12)

Whitted, T. A scan-line algorithm for computer display of curved surfaces. Proc. ACM SIGGRAPH Conference, 1978.

computer 6 (June

(13) ...... GINO-F User's Manual. Computer-Aided Design Centre, Cambridge, England, ]975.

257

Figure ]

Figure 2

Figure 3

Figure 4

Figure 5

Figure 6

258

Figure 7

Figure 8

Figure 9

Figure I0

Figure 11

Figure ]2

259