Ray Tracing Deformed Surfaces ABSTRACT: 1. Introduction

Report 3 Downloads 141 Views
Dallas, August 18-22

Volume 20, Number 4, 1986 II

Ray Tracing D e f o r m e d Surfaces Alan H. Baxr California Institute of Technology Pasadena, CA 91125

ABSTRACT: A collection of new m e t h o d s for r a y t r a c i n g differe n t i a b l e surfaces is developed. T h e m e t h o d s axe general, a n d e x t e n d t h e set of ~ r a y - t r a c e a b l e ~ surfaces suitable for use in g e o m e t r i c m o d e l i n g . We intersect a r a y £ = a t + _b, t > 0 w i t h a p a r a m e t r i c surface z = _f(u, v}, a n d w i t h i m p l i c i t surfaces j r ( x , y , z ) = 0. A s m o o t h surface is t r e a t e d as a d e f o r m a t i o n of a flat sheet; the i n t e r s e c t i o n p r o b l e m is c o n v e r t e d to a new c o o r d i n a t e s y s t e m in w h i c h t h e surfaces axe fiat, a n d t h e r a y s axe b e n t . We d e v e l o p m e t h o d s for p r o v i d i n g g o o d initial e s t i m a t e s of t h e p a r a m e t r i c i n t e r s e c t i o n values, a n d a "closeness criterion, '~ to reduce c o m p u t a t i o n . T h e s e s a m e c r i t e r i a help us s u b s t i t u t e a set of s i m p l e r surfaces for t h e m o r e c o m p l e x surface. T h e p a r a m e t r i c m e t h o d p r o d u c e s t h e i n t e r s e c t i o n values of u, v, and t. These are s u i t a b l e for s h a d i n g c a l c u l a t i o n s a n d for m a p p i n g t e x t u r e s onto t h e surface; t h e y can also p r o d u c e the local c o o r d i n a t e frame values, s u i t a b l e for a n i s o t r o p i c lighting models. Keywords: Ray tracing, deformations, hierarchical sampling

1. Introduction R a y - t r a c e d i m a g e s are c r e a t e d by n u m e r i c a l l y simu l a t i n g t h e b e h a v i o r of p h o t o n s i m p i n g i n g on a m a t h e m a t i c a l film plane, t h r o u g h t h e principles of geometric optics. T h e r a y t r a c i n g a p p r o a c h has been one of the most successful techniques to d a t e in c r e a t i n g high fidelity c o m p u t e r g e n e r a t e d images, a n d is b e c o m i n g progressively m o r e p r a c t i c a l due to t h e increasing speed and d e c r e a s i n g cost of c o m p u t a t i o n .

Permission to copy without fee all or part of this material is granted provided that the copies are not made or dislribuled for direm commercial advantage, the ACM copyright notice and the title of the publication and its date appear, and notice is given that copying is by permission of the Association for Computing Machinery. To copy otherwise, or to republish, requires a fee and/or specific permission. © 1986

ACM0-89791-[96-2[86/008/0287

$00.75

A l m o s t all of the surfaces found in r a y t r a c e d images have b e e n m a t h e m a t i c a l l y simple, chiefly due to t h e c o m p l e x i t y of t h e i n t e r s e c t i o n a l g o r i t h m , a n d the n u m e r i c a l i n t e n s i t y of t h e c o m p u t a t i o n . P l a n e s a n d q u a d r i c surfaces are a m o n g s t t h e simplest of these surfaces, r e q u i r i n g t h e s o l u t i o n of linear a n d q u a d r a t i c e q u a t i o n s r e s p e c t i v e l y for t h e r a y intersections. Recently, b i q u a d r a t i c surfaces such as S t e i n e r patches, and bicubic surfaces have b e c o m e t r a c t a b l e (see [KAJIYA 82], [SEDERBERG 84], a n d [TOTH 85]). For t h e most p a r t , these surfaces have b e e n the t r a d i t i o n a l geometric m o d e l i n g p r i m i t i v e s used in r a y t r a c e d scenes. T h e m e t h o d s in this p a p e r are d e v e l o p e d for r a y t r a c i n g differentiable surfaces m o r e general t h a n the above. O b j e c t s which d o n o t have differentiable surfaces, however, such as t h r e e d i m e n s i o n a l d e n s i t y functions (clouds), and f r a c t a l surfaces ( m o u n t a i n s ) , are o u t s i d e t h e d o m a i n of this article. See [BOUVILLE 85], [KAJIYA and VON HERZEN 84], [KAJIYA 83]. T h e t r a d i t i o n a l g e o m e t r i c m o d e l i n g p r i m i t i v e s are well s u i t e d t o m o d e l i n g s t a t i c shapes, such as rigid machine p a r t s . T h e y are not so ideal, however, for comp a c t l y r e p r e s e n t i n g objects whose s h a p e s change as a function of time, such as t h e s h a p e s of flexible m a t e r i als, biological forms, and t h e b l e n d i n g of shapes. T h e simple p r i m i t i v e s are e i t h e r t o o l i m i t e d (as are spheres} in t h a t t h e y c a n n o t m o d e l m a n y of the d e s i r e d shapes, or else are t o o fine grained {as are p o l y g o n s a n d bicubic p a t c h e s ) in t h a t t h e y require large q u a n t i t i e s of d a t a t h a t h u m a n beings find difficult to m a n i p u l a t e . New geometric m o d e l i n g p r i m i t i v e s axe needed to help us c o n t r o l the f o r m a t i o n a n d b e h a v i o r of flexible objects. These p r i m i t i v e s could p e r m i t a m o r e succinct r e p r e s e n t a t i o n of a w i d e r r a n g e of o b j e c t s t h a n is curr e n t l y available. T h e c o m p u t a t i o n a l i n t e n s i t y of m o d eling and r e n d e r i n g w i t h the new p r i m i t i v e s should not overwhelm the o t h e r benefits of t h e i r use. Deformed surfaces have a p o t e n t i a l role in t h e e n d e a v o r to create such primitives; t h e m e t h o d s of this p a p e r c a n be used to efficiently r e n d e r the surfaces.

287

~.

2. I n v e r s e m e t h o d s in R a y Tracing T h e p a r a m e t r i c ray intersection problem is to find values of u, v, and t such t h a t the three dimensional r a y _~(t) and the p a r a m e t r i c surface f_(u, u) satisfy

f_Cu, v) • l(t).

S I G G R A P H

'86

A way to visualize the transformation f r o m U_ space to .D_ space is as follows: at each value of t, the image of a u - v region is a portion of the original surface f(u, v), translated in space by the amount at + b_.As t increases, this portion of the surface is translated paxal]el to vector a, sweeping out a region of space.

(2.1)

We create a "difference space" by choosing _D(u, v, t) to be the difference of the two functions, i.e.,

p_(u, v, t) ~ [ ( u , v) -- (_at + b_).

(2.2)

T h e intersection p r o b l e m becomes t h a t of finding the r o o t s of

_D_{u, v, t) = 0.

(2.3)

There are two coordinate s y s t e m s (other than the conventional modeling space) which we will use to set up the equations for this problem. T h e first coordinate s y s t e m is parameter ~pace, or ~'_U_space," in which we obtain three dimensional difference vectors {Dr, D2, D3) T as a function of u, v, and t, v i a E q u a t i o n 2.2. T h e inverse coordinate system is called difference space or "_D space/' in which we obtain parametric values of ( u , v , t ) T as a function of difference values D1, D2, and D s .

ray:l=at+

b, t ~ 0

y

Figure 2. A rectangular region of _U._8pace maps to a corresponding region of p_ space via (2.2)

Figure 1. Parametric surface function z = f_(~, v) and ray z_ = ~t + b, in Cartesian space. D_ space is a deformation of_U.,space (see [BARR 84]). Each point in a three d i m e n s i o n a l region in U space is m a p p e d to a c o r r e s p o n d i n g p o i n t in a three d i m e n s i o n a l region of D_ space, via E q u a t i o n 2.2. Figure 2 shows the m a p p i n g f r o m a r e c t a n g u l a r region of _U space to a region of _D_space.

288

T h e r e is a f u n d a m e n t a l fact at the h e a r t of the m e t h o d . In ._D space, i.e., difference space, we know where the solution is: i t ' s at the origin, where the difference vector is (0,0, 0) T. We will derive a m e t h o d to c o m p u t e the U space value which c o r r e s p o n d s to (0, 0, 0) T in ._Dspace, inverting E q u a t i o n 2.2. This gives us the intersection values of u, v, and t we seek.

Dallas, August 18-22

3. Derivation:

Volume 20, Number 4, 1986

Parametric

Method

D

2

In this section, we assume that a point _U = (u:, vl, tl)r is given, which approximates the solution values of u, v, and t. First, we m a p this point to D_ space, by creating the initial difference v e c t o r

: , = P_Cut, vl, t,).

(3.1)

from the initial values of u, v, and t. Second, we create a "difference curve" _d(s), connecting the initial difference vector 7_1 to (0, 0,0) z in D_ space.

The inverse image of the difference curve d(s) is a parametric curve p(s) in U space called the %oluFigure 3a. A region of D space tion curve." The endpoint of p_(s) which corresponds and the difference curve .d(s) to (0,0,0} T yields the solution values of u, v, and t (see Figures 3a and 3b). T h e difference curve d(s) can be The above equations can Be modified slightlyby alany piecewise s m o o t h curve in D_ space which termi- lowing s to be considered a function of an independent n a t e s at the origin, for which the inverse image exists. parameter :. We will e x a m i n e the case for two different choices D(]/I(8(~)),/-L2(8(~)), ~3(s(~))) "~ -~-1"(~) (3.5) of _d(s).

Formulation

1:

t

One such curve, for which the inverse image can exist, is:

_d(,) = ,~1,

s: : ~ 0

(ttl~~I~ tl)

(3.2,)

The above curve starts at the initialdifference vector ~-1, w h e r e s : 1, and ends w h e n s -~ 0, at (0, 0, 0) T. T h e solution curve p_(s) s t a r t s at the initial point

(~1, ~1, tl). T h e solution is o b t a i n e d w h e n s = 0, i.e, at ~_(0), as long as the inverse image of d(s) exists continuously along the segment. T h i s is a continuation m e t h o d for solving the intersection p r o b l e m . So, how do we find the solution curve ~_(s), which deforms to the difference curve d_(s) ? Where does the above curve have a unique inverse image in U_ space?

W e do this by expressing the condition that the deformation of the solution curve p_(s} is equal to d_(s}. Thus,

D(~,lCd, ~,2(~), ~,3(s)) = Z_13

(3.4)

Figure 3b. The corresponding region of U space and the solution curve p(s) W e compose the above functions, and consider u, v, t, and s, without loss of generality, to be functions of

p_(u(~), ~(~), t(~)) = _~,s(,~). u(6)=

(3.6}

-1

~(6) = ~,

289

S

G

G

R

A

4. Creating and Solving tial Value Problems

t { , ~ , ) = tl

A g e o m e t r i c i n t e r p r e t a t i o n of the above equation exists, which uses the original world space, w i t h o u t the explicit reference to the other two coordinate systems. We e x p a n d the definition of p_{u, v, t) in Equation 3.6, and n o t e t h a t u, v, t, and s are functions of ~ with the p r e v i o u s l y s t a t e d initial conditions.

P

the

H

'86

Ini-

Formulation 1: We take the derivative of E q u a t i o n 3.6 with respect

to ~. aA,a~ + ~aA/ + a-D-t'at Zxs' =

where ' signifies

L(u,,,) - (~t + b_) = ._,,

I

{4.1}

didO.

(3.7)

T h i s e q u a t i o n states t h a t as s goes f r o m one to sero, u, v, a n d t change in such a m a n n e r t h a t the difference v e c t o r {joining the r a y and the surface} gets smaller in m a g n i t u d e , b u t m a i n t a i n s its parallelism to ~x. T h u s , these values of u and v constrain f ( u , v) to lie in the plane containing b o t h _a and [ 1 - This plane contains the initial point £(tz) on the ray and the initial point f ( u l , vi) on the surface. T h e p a r a m e t e r t goes along the ray in direction a, while 8 is the p r o p o r t i o n of the length of the vector joining the surface and the r a y (parallel to the difference v e c t o r Zx)- W h e n s = 1, the distance is 100 percent of

l_r,I. T h e intersection curve on the surface is equal to the solution curve {as a function of s ) plus the ray position at each t value.

Formulation

2.

Figure 4. The plane P of Formulation 1, and the image of the solution curve in modeling space Thus, f r o m E q u a t i o n 2.2, _ ( } , + -af(u,v} az.u,,, ~,,'-~,t'

A n o t h e r curve, for which the inverse image can exist, is d(~, t} = 4 t ( a

- a) + __B}

0u

(4.2~,)

-

so, using s u b s c r i p t s to denote p a r t i a l derivatives,

As s goes f r o m one to zero, dis , t) goes to zero. T h e e q u a t i o n analagous to E q u a t i o n 3.6, is

p_(~,(~),~(,~),t(,~)) = 4~)(t(~)C_A-.~} +B_).

= Z,s'.

8v

L."' (3.8)

+

L ~'' - ~t'

= Z_/.

{4.2b)

where

-{h) = -x

~,(,,,) = ,,~ v(&)

=

,,,

t(,h) = t, s(~,}

= 1

where

B = D(.~,

~ , t~) - ( A - _~)t~.

This f o r m u l a t i o n will prove to be an i m p r o v e m e n t over the previous formulation, for suitable choices of the A vector.

290

t(~,)

=t,

s(~,)

=,

We wish to convert this into an initial value p r o b l e m and solve it to find values such t h a t s(~0) = 0, {thus showing t h a t the ray hits the surface} or else show t h a t such values do not exist (showing t h a t the ray does not hit the surface}. Rewriting E q u a t i o n 4.2 b in m a t r i x form, we obtain

Da|tas, August 18-22

Volume 20, Number 4, 1986

( auld ' (L~,,L,,,-_a) du/de|=7,dslde ]

We let the m a t r i x J = ( L

T h e m a t r i x J for this e q u a t i o n is given by

(4.3)

We can express e q u a t i o n 4.7 via:

L,, -a-)

x

We divide b o t h sides of equation 4.3 by obtain

dv/ds dt/ds

=

dsld~,

= J-l~l

and

du/dt du/dt | = J - l a

e, /dt J

(4.4}

If the right h a n d side of the above equation satisfies a "Lipschitz condition" on its d e p e n d e n t variables {see A p p e n d i x A), t h e n it is g u a r a n t e e d t h a t a solution exists, a n d t h a t the solution is unique. Effectively, this m e a n s t h a t the right h a n d side m u s t be continuous, and its various p a r t i a l derivatives b e bounded, in the region of U s p a c e u n d e r consideration. E q u a t i o n 4.4 is valid in all regions where the determ i n a n t of the m a t r i x J does not a p p r o a c h zero. T h e d e t e r m i n a n t is given by

(4.s}

T h i s e q u a t i o n is valid for values of t where the absolute value of the d e t e r m i n a n t of the m a t r i x J > e, and detJ does not change sign as a function of t. T h e d e t e r m i n a n t is given b y (4.9}

We solve this e q u a t i o n looking for values of u, v, and t such t h a t s < O. Thus, E q u a t i o n 4.8 is valid as long as the absolute value of the dot p r o d u c t of the initial surface direction ~1 and the n o r m a l vector does not a p p r o a c h zero. As before, this equation b e c o m e s singular as the vector ~1 detJ = × to) (4.5) becomes t a n g e n t to the current surface position f ( u , v}. So, w h a t h a p p e n s where b o t h criteria fail? -For inSince f ~ × /-v is the n o r m a l vector to the surface stance, o u r initial a p p r o x i m a t i o n c a n cause ~1 to be (although it is not necessarily the unit normal}, Equa- virtually parallel to a, so there will be no a d v a n t a g e to tion 4.4 is valid as long as the dot p r o d u c t of the ray switching b e t w e e n the two equations. In this circumdirection a and the n o r m a l vector is never zero as the stance, the matrices of b o t h equations are singular. We i n d e p e n d e n t p a r a m e t e r s goes f r o m 1 to 0. (Note t h a t can create a differential e q u a t i o n w i t h a Lipschitz conthe d e t e r m i n a n t would be zero if f u or fv were identl- dition even if this occurs, using o r t h o g o n a l projection caUy zero, such as at the n o r t h pole of a-sphere}. of the t e r m s in E q u a t i o n 4.2b, b u t it is preferable to In o t h e r words, E q u a t i o n 4.4 becomes unusable as use F o r m u l a t i o n 2. the v e c t o r a b e c o m e s t a n g e n t to the current surface position f ( u , v), n e a r the silhouette edges of the surface. We also will not use 4.4 if it would cause the values of t to decrease, so we can know if the ray has missed the surface by going o u t of the r a n g e in t. T h e equation is a d e q u a t e for those p a r t s of the surfaces where f ~ , f ~ , and a are nonzero a n d b o u n d e d , and the absolute value of the d e t e r m i n a n t IdetJI > e > 0. T h e Lipschitz b o u n d we need is p r o v i d e d by the c o n s t a n t ~. We t e r m i n a t e solving this differential equation if IdetJ] < e or detJ changes sign as a function of s. We are free to use the e x t r a degree of freedom in E q u a t i o n 4.2b: we switch the s and t t e r m s as follows:

fuduld~ + ~ dvld~ - .~ldsld~ = adtld~ Thus, dividing by

(4.6)

dt/d~, [ du/dt'~

(s,,,so,-z,) ld,,/dt/ =