6
Volume 11, (1992) 55- 60 Ray Tracing and Graphics Standards B. Urban and T. Haberstroh Zentrum fur Graphische Datenverarbeitung e.v., Aussenstelle an der Universität Rostock, Albert-Einstein-Strasse 21, 0-2500 Rostock 1, Germany Abstract Existing standards for three-dimensional graphic representations are unable to produce any realistically shaded images (except PHIGS PLUS, which provides discrete shading only). Ray Tracing or Radiosity are not taken into account up to this time. This article is intended to show one way to integrate the Ray Tracing technique into the pipeline of the graphics standards GKS-3D and PHIGS. No modifications of the viewing concepts are required by our implementation. 1. Introduction ceptually performed in world coordinates (WC). This is Two international standards for three-dimensional gra- phic representations - GKS-3D1 and PHIGS 2 - have existed since 1988. Both standards enable applications to produce pictures on the basis of straight-lined primitives and planar area primitives. They do not include light effects. The standard PHIGS PLUS 3 is under develop- ment as part 4 of standard PHIGS within the Inter- national Standards Organization (ISO) at present. PHIGS PLUS extends the functionality of standard PHIGS to Bezier, B-spline and NURB curves and surfaces on the one hand, and on the other to discrete and smooth shading techniques. Global effects (shadows, refraction, reflection) are not handled or are left to the user, respectively. Ray Tracing 4 represents a simple method to produce high-quality, realistically shaded pictures. In this study the possibilities and problems of integration of the Ray Tracing technique into graphics standards are discussed. Integration of Ray Tracing is efficient for PHIGS PLUS, because PHIGS PLUS offers the necess- ary functional preconditions (definition of light sources and surface properties). The concepts of integration into the output pipeline, however, are principally the same for GKS-3D, PHIGS and PHIGS PLUS. The integration of the Ray Tracing technique into the output pipeline is therefore described as generally as possible. For practical testing our own implementation of GKS-3D (GKS1800) was extended by adding the functions for defining light sources and surface attributes analogously to PHIGS PLUS. Lighting and shading in PHIGS PLUS are con- necessary because angles will be changed by the perspec- tive transformation. After lighting and shading, depth cueing and hidden surface removal are performed in NPC, and clipping is performed in DC. This viewing pipeline is computationally expensive, especially with regard to the smooth shading techniques of PHIGS PLUS (particularly for surfaces). Ray Tracing does not work in this way because lighting, shading and hidden surface removal are performed simultaneously. The workstation clip should not be performed after the shading calculations, but simultaneously by appropriate choice of rays (xy-clip) and limitation of the ray length (z-clip) to avoid the large-scale calculations for shading for objects which will subsequently be clipped. We will indicate an allocation in the output pipeline and the functionality of the graphics standards for the integration of Ray Tracing and present a test implemen- tation in a GKS-3D-environment. 2. Selection of a Coordinate System A principal demand for integration of Ray Tracing into graphic standards is the invariance of the transformation pipeline of GKS-3D or PHIGS. First one has to decide in which coordinate system of the standard pipeline a Ray Tracer may work. The GKS-3D output pipeline consists of the : - normalization transformation from WC3 to NDC3, - segment transformation within NDC3, - view orientation transformation from NDC3 to VRC3,

Ray Tracing and Graphics Standards

  • Upload
    b-urban

  • View
    213

  • Download
    1

Embed Size (px)

Citation preview

Volume 11, (1992) 55-60

Ray Tracing and Graphics Standards

B. Urban and T. Haberstroh

Zentrum fur Graphische Datenverarbeitung e.v., Aussenstelle an der Universität Rostock, Albert-Einstein-Strasse 21, 0-2500 Rostock 1, Germany

Abstract Existing standards for three-dimensional graphic representations are unable to produce any realistically shaded images (except PHIGS PLUS, which provides discrete shading only). Ray Tracing or Radiosity are not taken into account up to this time.

This article is intended to show one way to integrate the Ray Tracing technique into the pipeline of the graphics standards GKS-3D and PHIGS. No modifications of the viewing concepts are required by our implementation.

1. Introduction ceptually performed in world coordinates (WC). This is

Two international standards for three-dimensional gra- phic representations - GKS-3D1 and PHIGS2 -have existed since 1988. Both standards enable applications to produce pictures on the basis of straight-lined primitives and planar area primitives. They do not include light effects. The standard PHIGS PLUS3 is under develop- ment as part 4 of standard PHIGS within the Inter- national Standards Organization (ISO) at present. PHIGS PLUS extends the functionality of standard PHIGS to Bezier, B-spline and NURB curves and surfaces on the one hand, and on the other to discrete and smooth shading techniques. Global effects (shadows, refraction, reflection) are not handled or are left to the user, respectively.

Ray Tracing4 represents a simple method to produce high-quality, realistically shaded pictures. In this study the possibilities and problems of integration of the Ray Tracing technique into graphics standards are discussed. Integration of Ray Tracing is efficient for PHIGS PLUS, because PHIGS PLUS offers the necess- ary functional preconditions (definition of light sources and surface properties). The concepts of integration into the output pipeline, however, are principally the same for GKS-3D, PHIGS and PHIGS PLUS. The integration of the Ray Tracing technique into the output pipeline is therefore described as generally as possible. For practical testing our own implementation of GKS-3D (GKS1800) was extended by adding the functions for defining light sources and surface attributes analogously to PHIGS PLUS.

Lighting and shading in PHIGS PLUS are con-

necessary because angles will be changed by the perspec- tive transformation. After lighting and shading, depth cueing and hidden surface removal are performed in NPC, and clipping is performed in DC. This viewing pipeline is computationally expensive, especially with regard to the smooth shading techniques of PHIGS PLUS (particularly for surfaces). Ray Tracing does not work in this way because lighting, shading and hidden surface removal are performed simultaneously. The workstation clip should not be performed after the shading calculations, but simultaneously by appropriate choice of rays (xy-clip) and limitation of the ray length (z-clip) to avoid the large-scale calculations for shading for objects which will subsequently be clipped.

We will indicate an allocation in the output pipeline and the functionality of the graphics standards for the integration of Ray Tracing and present a test implemen- tation in a GKS-3D-environment.

2. Selection of a Coordinate System

A principal demand for integration of Ray Tracing into graphic standards is the invariance of the transformation pipeline of GKS-3D or PHIGS. First one has to decide in which coordinate system of the standard pipeline a Ray Tracer may work. The GKS-3D output pipeline consists of the :

- normalization transformation from WC3 to NDC3, - segment transformation within NDC3, - view orientation transformation from NDC3 to

VRC3,

56 B. Urban and T. Haberstroh / Ray Tracing and Graphics Standards

- view mapping transformation from VRC3 to

- workstation transformation from NPC3 to DC3.

The output pipeline of PHIGS covers :

- modelling transformation from MC3 to WC3 - view orientation transformation, view mapping

transformation and workstation transformation according to GKS-3D.

NPC3,

In NPC3 and DC3 the projection has already been performed. Primary rays proceeding from the eye point (as specified in VRC3) would be transformed into parallel rays in NPC3 or DC3, respectively. Since the view mapping transformation does not conserve angles, a correct calculation of secondary rays in these coordinate systems is impossible. For this reason, Ray Tracing below VRC3 can only solve the hidden surface problem (“Ray Casting”) but it is not possible to calculate reflection and refraction.

Now we examine the coordinate systems above VRC3. The scene to be visualized is created in PHIGS by applying the composite modelling transformation, re- sulting from global and local modelling transformations to graphic primitives. In GKS the scene is determined by applying normalization and segment transformations to the graphic primitives. For this, Ray Tracing above WC (in the case of PHIGS) or NDC3 (in the case of GKS-3D) is not possible. So we have to choose between WC and VRC3 (PHIGS) or NDC3 and VRC3 (GKS), respect- ively.

The viewing data defined in VRC3 specify quite well the geometry of the Ray Tracer. Inverse transformation of the viewing data in the coordinate systems above VRC3 i s possible. The expenditure for such an inverse transformation of the viewing data, by means of the inverse view orientation matrix, is not as much as that for the transformation of all objects to VRC3. In WC3 or NDC3, clipping planes (front/back) resulting from the view clip and workstation clip (see Section 3.1) are not parallel to the xy-planes so that clipping tests require more numeric expenditure than those performed in VRC3. Since these calculations have to be performed for every ray, we have chosen to perform Ray Tracing in VRC3.

3. Calculation of Viewing Parameters

Since we do not wish to change the viewing concept of the graphics standards, some problems arise in providing the viewing parameters in the form needed by Ray Tracing. The application specifies the transformation from NDC3 (GKS-3D) or WC3 (PHIGS), respectively, via VRC3 to NPC3 by two 4 by 4 matrices-the view orientation transformation matrix and the view mapping trans- formation matrix. The view mapping transformation

matrix contains information about the projection type (parallel or perspective) and the projection reference point. Two problems have to be solved for Ray Tracing:

1. Calculation of the projection reference point from the view mapping transformation matrix and definition of the clipping planes in VRC3.

2 . Calculation of the size and location of the raster in VRC3.

3.1. Calculation of Projection Reference Point and Clipping Planes

In GKS-3D and PHIGS the application determines the viewing parameters with the function SET VIEW REP- RESENTATION with its parameters view orientation matrix, view mapping matrix, view clip volume and view clip indicators (front, back, xy). There exist utility functions to calculate the view orientation transform- ation matrix from view reference point, view plane normal and view up-vector or view mapping transfor- mation matrix from view plane distance, frontplane distance, backplane distance, view window limits, pro- jection reference point, projection type and projection viewport. How can the projection reference point and the clipping planes in VRC3 be calculated?

Figure 1

B. Urban and T. Haberstroh / R a y

To calculate the projection reference point it is first necessary to calculate a “display volume” in NPC3 (fig. 1). This is the intersection of the effective view clip volume (which is defined by the view clip volume, taking into account the view clip indicators) and the current work- station window (clipping at the workstation window is mandatory). The eight corner points of this display volume are transformed by the inverse view mapping transformation to VRC3 and define the view volume there. The view mapping matrix must be invertible for this purpose which is the case with the essential per- spective and parallel projections (all matrices resulting from the GKS-EVALUATE functions are invertible). The transformed display volume forms a parallelepiped for a parallel projection or an oblique frustum of a pyramid for perspective projection. The areas of the transformed display volume are the real clipping planes. It is not necessary that they comply with the primary view volume because view clip and workstation clip have been included. The projection reference point is given by the top of pyramid in case of the perspective projection or as direction in case of the parallel projection.

3.2. Calculation of the Raster in VRC3

The raster of the current workstation viewport (with start point x, y and size dx, dy) is transferred to the zmax-plane of the current workstation window. The Workstation window and effective view clip volume are axially parallel cuboids in NPC3. The same applies consequently for the intersection of both - the display volume. Supposed that the workstation window is specified by (xminw, xmaxw, yminw, ymaxw, zminw, zmaxw) and the effective view clip volume is specified by (xminc, xmaxc, yminc, ymaxc, zminc, zmaxc), the raster in NPC3 significant for the Ray Tracer is received by (x’,y’,dx’,dy’) in the plane of z = min(zmaxw, zmaxc). It follows that:

x’ = max(xminw, xminc) y‘ = max(yminw, yminc)

d x ’ = (min(xmaxw, xmaxc) - max(xminw, xminc))*dx d y ’ = (min(ymaxw, ymaxc) - max(yminw, yminc))*dy

To determine the raster on the front plane of the view volume, 3 pixels

are subjected to the inverse view mapping trans- formation are the distances between neighbouring points).

4. Details of Integration in a Standard Environment

The calculation of the intersection points between the rays and objects is the largest-scale procedure of Ray Tracing. Significant accelerations can be achieved by means of hierarchically bounding volumes or by space partition6. In both cases storage of the objects in a separate data structure is necessary which reflects either

Tracing and Graphics Standards 51

the hierarchy or the references of the voxels relative to the objects contained in each case. This can be realized neither by means of the GKS segment storage nor by means of the PHIGS structure storage. Moreover, this indicates that Ray Tracing must work after the segment transformation or modelling transformation. The use of a separate data structure has the further advantage that a far-reaching independence of concrete implementations of the standards is achieved. Since Ray Tracing can be selected as a visualization method depending on the workstation, and is bound to a particular view in each case, the data structure must be controlled conceptually for every open workstation and every defined view (GKS- 3D and PHIGS permit the simultaneous use of several view transformations).

The decision about which of the two possibilities to use to accelerate ray tracing must be taken with consideration of the primitives to be handled. Zero- and one-dimen- sional primitives (POLYMARKER, POLYLINE) can- not be visualized by Ray Tracing. Ray Tracing is able to visualize the area primitives of the standards (FILL AREA, FILL AREA SET, CELL ARRAY and surfaces of PHIGS PLUS). We suggest, that the utilization of bounding volumes for planar areas becomes expensive, because the very large number of intersecting bounding volumes. We use the uniform space partition to accelerate Ray Tracing.

Treatment of clipping by the Ray Tracer presents an open problem. Is it possible that objects beyond the clipping volume affect objects which are within the clipping volume? That is, are secondary rays able to leave the clipping volume or not? Both possibilities can be regarded meaningful and realized (think about looking in a mirror). The standards do not include any guidance because global models of lighting are not included. Selection of one of the two possibilities could be controlled by the user via the ESCAPE function. Acti- vation of Ray Tracing for visualization can be controlled by the HLHSR-mode.

5. Test Implementation

For a test implementation we extended our own im- plementation of GKS-3D by adding the following functions in accordance with PHIGS PLUS :

- SET AREA PROPERTIES -- SET BACK AREA PROPERTIES - SET LIGHT SOURCE REPRESENTATION - SET LIGHT SOURCE STATE - SET INTERIOR REFLECTANCE EQUATION - SET BACK INTERIOR REFLECTANCE

EQUATION

Since Ray Tracing is able to model the refraction of light,

58 B. Urban and T. Haberstroh / Ray Tracing and Graphics Standards

Figure 2

Figure 3

B. Urban and T. Haberstroh / Ray Tracing and Graphics Standards 59

Figure 4

Figure 5

60 B. Urban and T. Haberstroh / Ray Tracing and Graphics Standards

the functions SET (BACK) AREA PROPERTIES have been extended to include a refraction coefficient.

Activation of the Ray Tracer is controlled via the HLHSR-mode. The application can thus define a picture and modify it interactively. Doing so, in the sense of previewing, view, size and position of the graphical objects on the output device can be determined. Our implementation of GKS-3D permits application of the following HLHSR-techniques :

- no HLHSR: dot, line and area primitives are represented without hidden line or hidden surface removal

- hidden line only : all area primitives are transformed into line primitives representing the shapes and subjected to a HLR-calculation together with other line and dot primitives. As result of this a wireframe representation with masking out of hidden lines is generated.

- z-buffer: for representation of dot, line and area primitives a z-buffer technique is applied.

- painter: dot, line and area primitives are sorted in a priority list and rendered in the respective sequence.

Via the HLHSR-mode it is also possible to chose Ray Tracing as the visualization technique after previewing. Doing this, all dot and line primitives are regarded as annotation elements and ignored. To visualize the area primitives, the additional area attributes and light sources ignored in the above techniques are taken into account. As a consequence of this Ray Tracing can be applied effectively as visualization technique only in cases where the application model uses only area primitives.

Ray Tracing itself is a process which needs a large amount of time for calculation. Because the workstation viewport can be selected freely, the time required for calculation (with poor quality, i.e. with less resolution) can be directly influenced by the application.

The quality of the Ray Tracing graphics is limited by the representable primitives and the lighting model used. Because of the limitation of GKS-3D to planar areas, our implementation has the character of demonstration only. Significantly more attractive is the shading of surfaces in PHIGS PLUS. By working with a separate data structure,

transfer of our implementation to PHIGS PLUS becomes particularly simply. If approximation of the surfaces into planar elements is performed above VRC3, the algo- rithms can be transferred directly. Otherwise, routines for the calculations of the ray/surface intersection and for determining of the voxel/surface incidence still require developing. The functions SET (BACK) AREA PROPERTIES define the properties corresponding to the lighting model of Phong. A significant increase in reality can be achieved by taking into account reflections depending on wavelength and angle of incidence (model according to Cook/Torance). For this purpose an ex- tension of these functions depending on the implemen- tation (beyond the refraction coefficient) would be necessary.

Examples of our implementation are shown in the colour plates. Figure 2 shows a conventional GKS- output of a checkerboard. The same scene visualized by our Ray Tracer is shown in Figure 3. Clipping of secondary rays is demonstrated in Figures 4 and 5. The upper part of the scene was clipped in NPC3 (view clip). Figure 4 shows the checkerboard influenced by the clipped ventilator (no clipping of secondary rays, in this case shadow detectors). Clipping of secondary rays is shown in Figure 5.

References

1. ISO, Information Processing Systems - Computer Graphics - Graphical Kernel System for Three Dimensions (GKS-3D), ISO DIS8805 (1988).

ISO, Information Processing Systems - Computer Graphics - Programmers Hierarchical Interactive Graphics System (PHIGS), ISO DIS9592/1-3,1987.

3. PHIGS + Functional Description Revision 3.0, 1988.

4. A. Glassner: “An Introduction to Ray Tracing”, Academic Press, 1989.

J.D. Foley, A. van Dam, S.K. Feiner, J.F. Hughes: “ Computer Graphics : Principles and Practice ”, second edition, Addison-Wesley, Reading, MA, 1990.

2.

5.