static-curis.ku.dk filespatial and temporal ray differentials technical report nr. 2009/04, 2nd...

15
university of copenhagen Københavns Universitet Spatial and Temporal Ray Differentials Sporring, Jon; Schjøth, Lars; Erleben, Kenny Publication date: 2009 Document version Early version, also known as pre-print Citation for published version (APA): Sporring, J., Schjøth, L., & Erleben, K. (2009). Spatial and Temporal Ray Differentials. Department of Computer Science: Department of Computer Science, University of Copenhagen. Technical Report, No. 04, Vol.. 2009 Download date: 27. dec.. 2019

Upload: others

Post on 05-Sep-2019

1 views

Category:

Documents


0 download

TRANSCRIPT

u n i ve r s i t y o f co pe n h ag e n

Københavns Universitet

Spatial and Temporal Ray Differentials

Sporring, Jon; Schjøth, Lars; Erleben, Kenny

Publication date:2009

Document versionEarly version, also known as pre-print

Citation for published version (APA):Sporring, J., Schjøth, L., & Erleben, K. (2009). Spatial and Temporal Ray Differentials. Department of ComputerScience: Department of Computer Science, University of Copenhagen. Technical Report, No. 04, Vol.. 2009

Download date: 27. dec.. 2019

D E P A R T M E N T O F C O M P U T E R S C I E N C E ( D I K U ) U N I V E R S I T Y O F C O P E N H A G E N

Spatial and Temporal Ray Differentials

Jon Sporring Lars Schjøth

Kenny Erleben

2nd edition

December 13, 2012

Technical Report no. 04/2009

ISSN: 0107-8283

Spatial and Temporal Ray DifferentialsTechnical Report nr. 2009/04, 2nd edition

Jon Sporring, Lars Schjøth, and Kenny ErlebeneScience Center, Department of Computer Science, University of Copenhagen

Universitetsparken 1, DK-2100 Copenhagen, DenmarkContact email: [email protected]

December 13, 2012

Abstract

We consider ray bundles emanating from a source such as a camera or light source. We derive the complete spatialand temporal structure to first order of the intersection of ray bundles with scene geometry where scene geometry isgiven as any implicit function. Further, we present the complete details of two often used geometrical representations.The first order structure may be used as the linear approximation of the change of photon shape as the camera, objects,and light source change as function of space and time. Our work generalizes previous work on ray differentials[Igehy, 1999] and photon differentials [Schjøth et al., 2007].

1 Ray differential

In this work we consider reflection and refraction of light rays off and through surfaces as illustrated in Figure 1. Wewill derive the spatial-temporal first order structure of these processes without any simplifying assumptions. Considertwo points in 3-space, P ,x 2 R3. We define the line Q(s) parametrized by s 2 R passing through x and V as,

Q = P + sV (1)

where

V =

v

kvk2, (2a)

v = x� P . (2b)

The line is henceforth called the ray, and we use column vectors, such that kvk2 =

pv

T

v. This work extends[Igehy, 1999, Schjøth et al., 2007]: We develop the complete first order structure of Q in terms of its intersection withscene geometry and the following directions of reflection and refraction.

We use the notation of differential matrix calculus [Magnus and Neudecker, 1988]. Differentials are rooted inTaylor series, i.e., consider an analytical function f : R ! R, and write its Taylor series as, f (y +�y) = f (y) +

f

0(y)�y+O ��y

2�, where O is the remainder in Landau notation, and f

0 is the first order derivative of f . We definethe differential of f as the limit, f (y +�y)� f (y) ! df as �y ! dy, and write

df = f

0(y) dy. (3)

The extension to vector and matrix equations is straight forward, since their Taylor series are element-wise Taylorseries. We use the same notation and note that derivative are now Jacobian matrix, e.g., for vector equations such asV 2 Rn ! Rm and x 2 Rn, the Jacobian of V w.r.t. the variable x is the matrix @V

@x

who’s ij’th entry is the partialderivative @Vi

@xj. Hence, the j’th column is the change vector of V when only considering the coordinate direction x

j

.The Jacobian w.r.t. the complete space of parameters is often just written as @V for convenience. The differentialembodies the complete first order structure of a function, and a first order estimate of the change of, e.g., �Q isobtained by replacing the infinitesimals with finite values, i.e., dx with �x in the expression of the differential of dQ.

1

Figure 1: Transfer, Reflection, and Refraction by a flat surface. Black arrows are ray directions from origin, throughreflection and refraction, green arrow is the normal for the green surface patch.

The differentials are useful, since by the usual rules of differentiation, such as the chain rule and the derivativeof inverse functions, they allow for a step-by-step derivation of the Jacobian of a function w.r.t. its parameters muchlike the peels of an onion. As an example, consider V , which is a composition of functions v, x, and P . To find theJacobian of V (v(x,P )) we first find the Jacobian of V (v) by evaluating the differential of (2a) to dv as follows.

dV =

(dv)�v

T

v

�1/2 � v

�v

T

v

��1/2v

T dvv

T

v

(4a)

=

v

T

vI3 � vv

T

(v

T

v)

3/2dv (4b)

where I3 is the 3 ⇥ 3 identity matrix. Thus, if v is the free parameter, then the above expression is the final form ofthe Jacobian. However, as in our case, when v is a function of other variables, we repeat the exercise until we have anexpression solely in terms of the differentials of the free parameters. I.e., the Jacobian of v w.r.t. parameters x and P

is found to be,dv = (dx� dP ) , (5)

and hence, we conclude that the Jacobian of V w.r.t. parameters x and P is

dV =

v

T

vI3 � vv

T

(v

T

v)

3/2(dx� dP ) , (6)

where it is to be understood that all variables that are not differentials, are evaluated at the particular point of interest asterms in Taylor series usually are. This is the complete first order structure of V in terms of x and P , and we identifythe Jacobians as

@V

@x

=

v

T

vI3 � vv

T

(v

T

v)

3/2,

@V

@P

= �@V

@x

. (7)

By replacing dx and dP with finite steps �x and �P we may evaluate the linear approximation to the changes ofV . Geometrically speaking, this approximation is a point in the tangent space at V w.r.t. x and P and parametrizedby @V

@x

�x and @V

@P

�P where �x and �P are the free vector parameters of the approximation. Finally, note that if

2

one parameter is constant, then it’s differential is evaluated to be zero, e.g., consider that P = const. in which casedP = 0, and the differential of V reduces to dV =

@V

@x

dx.Often, x is restricted to be a point on a 2-dimensional surface such as an image plane or a sphere, and as a conse-

quence we must further evaluate the Jacobian of the parametrization of x. E.g., a plane may be parametrized as, x =

x1e1+x2e2 for some constant and orthogonal coordinate axes e1 and e2, and we evaluate dx =

⇥e1 e2

⇤ ⇥dx1 dx2

⇤T

and @V

@[x1 x2]T=

@V

@x

⇥e1 e2

⇤. Likewise, when x restricted to the surface of a unite sphere, centered at P , then we

may use the spherical parametrization,

x =

⇥cos�(t) sin ✓(t) sin�(t) sin ✓(t) cos ✓(t)

⇤T

, (8a)

P =

⇥P1(t) P2(t) P3(t)

⇤T

, (8b)

such that

dx =

2

4� sin� sin ✓ cos� cos ✓

@x1@t

cos� sin ✓ sin� cos ✓

@x2@t

0 � sin ✓

@x3@t

3

5

2

4d�d✓dt

3

5, (9a)

dP =

⇥@P1@t

@P2@t

@P3@t

⇤T dt, (9b)

where @x

@t

and @P

@t

are the linear part of the time dependence of x and P . Hence, the differential of V w.r.t. the ✓, �,and t parameters is,

dV =

v

T

vI3 � vv

T

(v

T

v)

3/2

0

@

2

4� sin� sin ✓ cos� cos ✓

@x1@t

cos� sin ✓ sin� cos ✓

@x2@t

0 � sin ✓

@x3@t

3

5

2

4d�d✓dt

3

5�2

4@P1@t

@P2@t

@P3@t

3

5 dt

1

A (10a)

=

v

T

vI3 � vv

T

(v

T

v)

3/2

2

4� sin� sin ✓ cos� cos ✓

@x1@t

� @P1@t

cos� sin ✓ sin� cos ✓

@x2@t

� @P2@t

0 � sin ✓

@x3@t

� @P3@t

3

5

2

4d�d✓dt

3

5. (10b)

Hence, we identify the Jacobian,

@V

@[�, ✓, t]

T

=

v

T

vI3 � vv

T

(v

T

v)

3/2

2

4� sin� sin ✓ cos� cos ✓

@x1@t

� @P1@t

cos� sin ✓ sin� cos ✓

@x2@t

� @P2@t

0 � sin ✓

@x3@t

� @P3@t

3

5, (11)

which is evaluated at a specific value of the parameters ✓0, �0, and t0. For static scenes, all terms involving dt is zero,i.e., the right most column of the Jacobian is zero.

The above illustrates the advantage of matrix differential algebra: When the parametrization of v is changed, thendv changes, but @V

@v

is remains the same, all of which matrix differential algebra allows us to express in terms ofmatrices.

2 Transfer, Reflection, and Refraction

In the following we will investigate light’s interaction with dielectric material, i.e., reflection and refraction. Weconsider a ray from a source at point P with direction V , which intersects a surface at position Q and is reflected andrefracted in directions Wreflect and Wrefract respectively. To avoid discussion on any particular parametrization of V ,we will in the following evaluate expressions no further than dV . The normal at Q will be denoted N , and the ratio ofrefraction at Q will be denoted ⌘. Our main goal will be to calculate the differentials, dQ, dWreflect, and dWrefract as afunction of relevant parametrizations, e.g.,

dQ =

@Q

@V

dV +

@Q

@P

dP +

@Q

@N

dN , (12a)

dWreflect =@Wreflect

@V

dV +

@Wreflect

@N

dN , (12b)

dWrefract =@Wrefract

@V

dV +

@Wrefract

@N

dN +

@Wrefract

@⌘

d⌘, (12c)

3

and subsequently identify the respective Jacobians.Following [Igehy, 1999] we sketch an iterative process, where in each iteration: 1) The ray is transfered to the

point of intersecting geometry, Q, 2) the directions of reflection and refraction,Wreflect and Wrefract, are calculatedsimultaneously. The pairs (Q,Wreflect) and (Q,Wrefract) are used as two new source points and directions for followingiterations.

2.1 Transfer

The transfer of a ray onto a surface at distance s is,

Q = P + sV . (13)

We will assume that the smooth surface Q 2 ⌦ embedded in R3 is given implicitly as the zero level-set of a scalarfunction of M parameters, F : RM ⇥ R3 ! R, as 0 = F

(Q), where ↵ 2 RM is a vector of parameters thatspecify the shape of F , and we will assume that there exists a method for solving for the smallest s⇤ > 0, such that0 = F

(P + s

⇤V ). Finally, we require that the surface unit normal, N , exists at Q.

The differential is found to be

dQ = dP + s

⇤ dV + V ds. (14)

Had P , V , and s been independent of each other, then this would be the final form and Jacobians w.r.t. the 3 variables.However, ds depends on P , V , and ↵ through F , which is why we expand ds as, ds =

@s

@P

dP +

@s

@V

dV +

@s

@↵

d↵,and get

dQ = dP + s

⇤ dV + V

✓@s

@P

dP +

@s

@V

dV +

@s

@↵

d↵◆

(15a)

=

✓I3 + V

@s

@P

◆dP +

✓s

⇤I3 + V

@s

@V

◆dV + V

@s

@↵

d↵, (15b)

where I3 is the 3⇥3 identity matrix. The Jacobians of Q are now identifiable as, @Q

@P

= I3+V

@s

@P

, @Q

@V

= s

⇤I3+V

@s

@V

,and @Q

@↵

= V

@s

@↵

. In the examples given later, we shall evaluate these terms for flat and pseudo-flat geometry F .Finally note that when the differential ds depends on dN , then ds will depend on the curvature of the surface at s⇤.For readability we will in the remainder of this article use the symbol s to denote s

⇤.

2.2 Reflection

Given a ray transferred to a surface, specified by its normal vector N , reflection is given by

Wreflect = V � 2

�V

T

N

�N . (16)

Hence,

dWreflect = dV � 2

��dV T

N + V

T dN�N +

�V

T

N

�dN�

(17a)

=

�I3 � 2NN

T

�dV � 2

�V

T

NI3 +NV

T

�dN . (17b)

Hence, we identify the Jacobians as @Wreflect@V

=

�I3 � 2NN

T

�, and @Wreflect

@N

= �2

�V

T

NI3 +NV

T

�.

2.3 Refraction

Given a ray transferred to a surface, specified by its normal vector N and its ratio of refraction indices ⌘, refraction isgiven by Snell’s law [Watt and Watt, 1992, Igehy, 1999],

Wrefract = ⌘V � µN , (18)

4

where

µ = ⌘V

T

N +

p⇠, (19a)

⇠ = 1� ⌘

2⇣1� �V T

N

�2⌘. (19b)

The refraction ratio between water and air is typically ⌘ = 1.33, and an often use approximation is ⌘ ' 1 in whichcase ⇠ ' �V T

N

�2, nevertheless, we will derive the complete structure to facilitate a greater range of ⌘ values as wellas allow for ⌘ to vary. The differential is found to be,

dWrefract = d⌘V + ⌘dV � dµN � µdN (20a)

= ⌘dV � µdN + V d⌘ �N

✓@µ

@V

dV +

@N

dN +

@⌘

d⌘◆

(20b)

=

✓⌘I3 �N

@V

◆dV �

✓µI3 +N

@N

◆dN +

✓V �N

@⌘

◆d⌘. (20c)

Thus, in order to identify the Jacobians of Wrefract, we must identify those of µ. Using d⇠ = �2⌘

⇣1� �V T

N

�2⌘ d⌘+

2⌘

2�V

T

N

� �dV T

N + V

T dN�, we see that

dµ = V

T

Nd⌘ + ⌘

�dV T

N + V

T dN�+

d⇠2

p⇠

(21a)

= V

T

Nd⌘ + ⌘

�dV T

N + V

T dN�+

�⌘

⇣1� �V T

N

�2⌘ d⌘ + ⌘

2V

T

N

�dV T

N + V

T dN�

p⇠

(21b)

=

0

@V

T

N �⌘

⇣1� �V T

N

�2⌘

p⇠

1

A d⌘ + ⌘

�N

T dV + V

T dN�+

2V

T

N

�N

T dV + V

T dN�

p⇠

(21c)

=

✓V

T

N � 1� ⇠

p⇠

◆d⌘ + ⌘

✓1 +

⌘V

T

Np⇠

◆N

T dV + ⌘

✓1 +

⌘V

T

Np⇠

◆V

T dN . (21d)

Gathering terms we find that

dWrefract =

✓⌘I3 � ⌘

✓1 +

⌘V

T

Np⇠

◆NN

T

◆dV

�✓µI3 + ⌘

✓1 +

⌘V

T

Np⇠

◆NV

T

◆dN

+

✓V �

✓V

T

N � 1� ⇠

p⇠

◆N

◆d⌘, (22)

and we find the Jacobians as, @Wrefract@V

=

⇣⌘I3 � ⌘

⇣1 +

⌘V

TNp⇠

⌘NN

T

⌘, @Wrefract

@N

= �⇣µI3 + ⌘

⇣1 +

⌘V

TNp⇠

⌘NV

T

⌘,

and @Wrefract@⌘

=

⇣V �

⇣V

T

N � 1�⇠

p⇠

⌘N

⌘.

3 Examples: Triangular Surface Models

A number of differentials described above depend on the surface of intersection. We will now evaluate the differentialsto complete depth for two popular and practical surface models based on triangles. The implicit function of the interiorof a triangle is identical to that of a plane, and the implicit function of a plane with normal Nflat, and where Q0 is apoint in the plane, is given as

F

Q0,Nflat (Q) = (Q0 �Q)

T

Nflat. (23)

The models we will investigate originates from flat and Phong shading. The cumbersome “flat” subscript is used todistinguish the geometry normal from the interpolated normal in Phong shading. Further, we will assume that themedia is homogeneous, i.e., d⌘ = 0.

5

3.1 Flat Surface

Assuming that we have identified a triangle intersected by the ray, where N

T

V 6= 0, then we combine (13) and (23)and seek the zero point,

0 = (Q0 � P � sV )

T

Nflat, (24)

which implies that

s =

(Q0 � P )

T

Nflat

V

T

Nflat. (25)

The complete differential of s is found as follows,

ds =

⇣d⇣(Q0 � P )

T

Nflat

⌘⌘ �V

T

Nflat��

⇣(Q0 � P )

T

Nflat

⌘d�V

T

Nflat�

(V

T

Nflat)2 (26a)

=

⇣(dQ0 � dP )

T

Nflat + (Q0 � P )

T dNflat

⌘� s

��dV T

�Nflat + V

T dNflat�

V

T

Nflat(26b)

=

N

T

flatV

T

NflatdQ0 � N

T

flatV

T

NflatdP +

(Q0 � P )

T � sV

T

V

T

NflatdNflat � sN

T

flatV

T

NflatdV , (26c)

and thus we identify, @s

@Q0=

N

Tflat

V

TNflat

, @s

@P

= � @s

@Q0, @s

@Nflat=

(Q0�P )T�sV

T

V

TNflat

, and @s

@V

= �s

@s

@Q0. Combining (15a),

(17), (22), and (26) we find,

dQflat=

✓I3 + V

@s

@P

◆dP +

✓sI3 + V

@s

@V

◆dV + V

@s

@Q0dQ0 + V

@s

@NflatdNflat,

= KdP + sKdV + (I3 �K) dQ0 +LdNflat, (27a)

dW flatreflect =

@W

flatreflect

@V

dV +

@W

flatreflect

@N

dNflat (27b)

dW flatrefract =

@W

flatrefract

@V

dV +

@W

flatrefract

@N

dNflat +@W

flatrefract@⌘

d⌘ (27c)

where superscript on the Jacobians of the W ’s implies that the Jacobians have the same form as (17) and (22) but withuse of Nflat as the normal, and where

K = I3 + V

@s

@P

= I3 � V N

T

flatV

T

Nflat, (28a)

L = V

@s

@Nflat=

V (Q0 � P )

T � sV V

T

V

T

Nflat. (28b)

Although the surface is flat, and the spatial part of dNflat is zero, we cannot disregard terms involving dNflat, since thetemporal part need not be zero.

For static geometry, only terms of dP and dV are non-zero. Their Jacobians, K and sK, describe the change inshape of the ray by intersection with the geometry. Their column vectors lie in the plane of the intersecting triangle,which can be proven as follows: First we show that K column vectors lie in the intersecting geometry, i.e., 0 = N

T

flatK.By transpose and expansion we find,

�N

T

flatK�T

= K

T

Nflat

=

✓I3 � NflatV

T

V

T

Nflat

◆Nflat

= Nflat � NflatVT

Nflat

V

T

Nflat

= 0. (29)

Since @Q

flat

@P

and @Q

flat

@V

depends linearly on K we conclude that the column vectors of both lie in the plane of the triangleregardless of whatever parameterization is chosen for P and V . Further, in the limiting case, where V

T

N ! 0, the

6

shape of the intersecting ray bundles diverges in the direction of V . To show this, consider the limit of the in planecoordinate system, e1 = V � (N

T

V )N ! V and e2 = e1 ⇥N ! V ⇥N . In this coordinate system we find thefollowing limits,

e

T

1 K ! V

T

K = V

T � V

T

V N

T

flatV

T

Nflat= V

T � N

T

flatV

T

Nflat= 1

e

T

2 K ! (V ⇥N)

T

K = (V ⇥N)

T � (V ⇥N)

T

V N

T

flatV

T

Nflat= (V ⇥N)

T (30)

Thus, as should be expected, the shape of intersecting ray bundles becomes infinitely long in the ray direction, whileconstant in perpendicular direction. This is a consequence of modeling rays as lines, not an error in the first orderapproximation. But in practice, almost all triangles are finite, hence care must be taken in actual implementations.

Typically, a triangle will be parametrized by its vertices, Q0, Q1, and Q2, and a more natural parametrization ofchanges is in terms of the vertices. Such a parametrization allows us to further develop dNflat. Assume that,

nflat = (Q2 �Q0)⇥ (Q1 �Q0) , (31)

To be consistent w.r.t. models for reflection and refraction, we will assume that nT

flatV < 0, otherwise we will inter-change Q1 and Q2. Evaluating the differentials, we find that

Nflat =nflat

knflatk2, (32a)

dNflat =n

T

flatnflatI3 � nflatnT

flat�n

T

flatnflat�3/2 dnflat, (32b)

dnflat = (Q2 �Q0)⇥ (dQ1 � dQ0)� (Q1 �Q0)⇥ (dQ2 � dQ0) (32c)= (Q1 �Q2)⇥ dQ0 + (Q2 �Q0)⇥ dQ1 + (Q0 �Q1)⇥ dQ2. (32d)

However, in order to isolate the differentials on the right hand side of each term, we instead used the matrix form of thecross product. Consider two vectors a, b 2 R3. Their cross-product may be written as, a⇥b = a⇥b = b

T

⇥a = �b⇥a,where

a =

2

4a1

a2

a3

3

5) a⇥ =

2

40 �a3 a2

a3 0 �a1

�a2 a1 0

3

5, (33)

and likewise for b⇥. Thus, we write, dnflat = (Q1⇥ �Q2⇥) dQ0+(Q2⇥ �Q0⇥) dQ1+(Q0⇥ �Q1⇥) dQ2. Further,Using

J =

n

T

flatnflatI3 � nflatnT

flat�n

T

flatnflat�3/2 , (34)

we identify @Nflat@Q0

= J (Q1⇥ �Q2⇥), @Nflat@Q1

= J (Q2⇥ �Q0⇥), and @Nflat@Q2

= J (Q0⇥ �Q1⇥). Hence, we enterdNflat into dQ from (27) and find that

dQflat=

✓I3 + V

@s

@P

◆dP +

✓sI3 + V

@s

@V

◆dV

+ V

✓@s

@Q0+

@s

@Nflat

@Nflat

@Q0

◆dQ0 + V

@s

@Nflat

@Nflat

@Q1dQ1 + V

@s

@Nflat

@Nflat

@Q2dQ2,

= KdP + sKdV + (I3 �K +LJ (Q1⇥ �Q2⇥)) dQ0 +LJ (Q2⇥ �Q0⇥) dQ1 +LJ (Q0⇥ �Q1⇥) dQ2.

(35)

We have now identified @Q

flat

@P

= K, @Q

flat

@V

= sK, @Q

flat

@Q0= I3 �K +LJ (Q1⇥ �Q2⇥), @Q

flat

@Q1= LJ (Q2⇥ �Q0⇥),

and @Q

flat

@Q2= LJ (Q0⇥ �Q1⇥).

The rays and spatial differentials are illustrated in Figure 2. In Figure 3 are examples of time differentials shown.The yellow arrows denote velocity vectors, and in Figures 3(a)-(c) it should be noted that a velocity of P in differentdirections implies a velocity of Qflat in the plane of the triangle. In Figures 3(d)-(e) we see that a rotational velocity ofV implies both a velocity of Qflat in the plane of the triangle as well as a rotation of W flat

reflect and W

flatrefract. Finally but

not shown, motion of the triangle tangent to the triangle does not imply any velocity on any parameters, and a rotationof the triangle normal implies a velocity on Q

flat along the ray.

7

(a) (b) (c)

(d)

Figure 2: Transfer, Reflection, and Refraction for Flat surfaces. Black arrows are ray directions, green is trianglenormal, blue and red arrow illustrate the row vectors of @P

@[�,✓]T , @Q

@[�,✓]T , @V

@[�,✓]T , and @W

@[�,✓]T as relevant. Subfigures(a)-(c) show orthographic projections of (d).

8

(a) (b) (c)

(d) (e)

Figure 3: Time differentials for Flat surfaces. Yellow arrows denote imposed and resulting time derivatives. Subfigures(a)-(c) shows imposed velocities in three orthogonal directions on the origin, P , (d)-(e) shows imposed rotationalvelocities in viewing direction V , and (f)-(h) shows imposed velocities in three orthogonal directions on one of thevertices.

9

(a) (b) (c)

Figure 4: Phong shading assumes fish scale geometry. A triangle, 4(a), shaded with Phong’s model, 4(b), expresses acomplexity not supported by the real geometry. One way of conceptualizing this model is to think of the triangle asconsisting of fish scales, 4(c); in this mindset every point on the surface of the triangle is associated with an independentlocal plane or fish scale whose normal is interpolated from the corners of the triangle.

3.2 Phong Shaded Surface

Phong shading uses a triangle as a base geometry, but imposes varying normals across it. Since the flatness of thetriangle contradicts the changing normals, we prefer to think of this as a fish scale model as illustrated in Figure 4.

Phong shading assumes a plane represented by the 3 vertices of a triangle, Q0, Q1, and Q2, and correspondingvertex normals N0, N1, and N2. To calculate the intersection of the view ray with the triangle we use the Flatsurface model (23), calculate the flat normal, Nflat, by (31), and we find the point of intersection by solving (25). Forreflection and refraction we construct a linearly interpolated normal from the three vertex normals. The flat normaland interpolated vertex normal most often will not coincide, and, as a consequence, @Q

phong

@V

will not span the triangle.Therefore, we calculate dQphong=dQflat by (35) and simply write Q and dQ in the remaining text.

To interpolate the vertex normals at the point of intersection, Q, we calculate the Barycentric coordinates,

Q = �0Q0 + �1Q1 + �2Q2, (36)

where �

i

� 0 are homogeneous Barycentric coordinates such that �0 + �1 + �2 = 1. The Barycentric coordinates arethen used to interpolate the vertex normals as,

n = �0N0 + �1N1 + �2N2, (37a)

N =

n

knk2. (37b)

Note that the Barycentric coordinates are local to the triangle, and their differentials d�i

may be used to estimate thechange in Q in terms of the triangle. However, this requires algorithmic care near the border of the triangle, where�

i

+��

i

may fall outside the triangle.Assuming a ray passing through P with direction V , which intersects a triangle within vertices Q0, Q1, and Q2,

then 0 �

i

1, and we may find the Barycentric coordinates as follows:

E1 = Q1 �Q0, (38a)E2 = Q2 �Q0, (38b)T = P �Q0, (38c)

A =

⇥E1 E2 �V

⇤, (38d)

in which case we may write the point of intersection as the system of linear equations, T = A[�1,�2, s]T . We solve

for the unknown in this system of equations using Cramer’s rule: consider the matrices Ai

, i = 1, 2 where the i’thecolumn of matrix A has been replaced by T such that A1 =

⇥T E2 �V

⇤, and A2 =

⇥E1 T �V

⇤, in that case

the solutions are,

�0 = 1� �1 � �2, (39a)

i

=

|Ai

||A| , i = 1, 2. (39b)

10

The differential, dN , is now found to be,

dN =

n

T

nI3 � nn

T

(n

T

n)

3/2dn, (40a)

dn = N0d�0 + �0dN0 +N1d�1 + �1dN1 +N2d�2 + �2dN2, (40b)

and the differentials of the Barycentric coordinates are found as follows:

d�0 = �d�1 � d�2, (41a)

d�i

=

|A| d |Ai

|� |Ai

| d |A||A|2 , i = 1 . . . 2. (41b)

Using the triple product form of the determinant,��⇥a b c

⇤��= (a⇥ b) · c, that any interchange in columns of a

matrix flips the sign of its determinant, and linearity of the cross and dot products, we may write,

d |A| = d��⇥E1 E2 �V

⇤�� (42a)

= (E2 ⇥E1)T dV + (V ⇥E2)

T dE1 � (V ⇥E1)T dE2, (42b)

=

T dV + ⇣

T dE1 + �T dE2, (42c)

d |A1| = d��⇥T E2 �V

⇤��, (42d)

= (E2 ⇥ T )

T dV + (V ⇥E2)T dT � (V ⇥ T )

T dE2, (42e)

=

T dV + ⇣

T dT + ⌧

T dE2, (42f)

d |A2| = d��⇥E1 T �V

⇤��, (42g)

= (T ⇥E1)T dV + (V ⇥ T )

T dE1 � (V ⇥E1)T dT , (42h)

= !

T dV � ⌧T dE1 + �T dT , (42i)

where = E2 ⇥E1, ⌧ = �V ⇥ T , � = �V ⇥E1, ⇣ = V ⇥E2, = E2 ⇥ T , and ! = T ⇥E1. Thus,

d�1 =

|A| �T dV + ⇣

T dT + ⌧

T dE2

�� |A1|�

T dV + ⇣

T dE1 + �T dE2

|A|2 (43a)

=

�|A|T � |A1| T

�dV + |A| ⇣T dT � |A1| ⇣T dE1 +

�|A| ⌧T � |A1|�T

�dE2

|A|2 , (43b)

d�2 =

|A| �!T dV � ⌧T dE1 + �T dT

�� |A2|�

T dV + ⇣

T dE1 + �T dE2

|A|2 (43c)

=

�|A|!T � |A2| T

�dV + |A|�T dT � �|A| ⌧T

+ |A2| ⇣T�

dE1 � |A2|�T dE2

|A|2 . (43d)

11

Gathering terms we get,

dN =

J

✓�0dN0 + �1dN1 + �2dN2

+

(N1 �N0)

|A|2��|A|T � |A1| T

�dV + |A| ⇣T dT � |A1| ⇣T dE1 +

�|A| ⌧T � |A1|�T

�dE2

+

(N2 �N0)

|A|2��|A|!T � |A2| T

�dV + |A|�T dT � �|A| ⌧T

+ |A2| ⇣T�dE1 � |A2|�T dE2

�◆

(44a)

= J

✓�0dN0 + �1dN1 + �2dN2

+

(N1 �N0)�|A|T � |A1| T

�+ (N2 �N0)

�|A|!T � |A2| T

|A|2 dV

+

(N1 �N0) |A| ⇣T + (N2 �N0) |A|�T

|A|2 dT

+

� (N1 �N0) |A1| ⇣T � (N2 �N0)�|A| ⌧T

+ |A2| ⇣T�

|A|2 dE1

+

(N1 �N0)�|A| ⌧T � |A1|�T

�� (N2 �N0) |A2|�T

|A|2 dE2

◆, (44b)

where J =

n

TnI3�nn

T

(nTn)3/2

. Since dE1 = dQ1 � dQ0, dE2 = dQ2 � dQ0, dT = dP � dQ0, we find that

dN = J

✓�0dN0 + �1dN1 + �2dN2

+

(N1 �N0)�|A|T � |A1| T

�+ (N2 �N0)

�|A|!T � |A2| T

|A|2 dV

+

(N1 �N0) |A| ⇣T + (N2 �N0) |A|�T

|A|2 dP

+

(N1 �N0)�|A1|

�⇣

T

+ �

T

�� |A| �⇣T + ⌧

T

��

|A|2 dQ0

+

(N2 �N0)�|A2|

��

T

+ ⇣

T

�� |A| ��T � ⌧T

��

|A|2 dQ0

+

� (N1 �N0) |A1| ⇣T � (N2 �N0)�|A| ⌧T

+ |A2| ⇣T�

|A|2 dQ1

+

(N1 �N0)�|A| ⌧T � |A1|�T

�� (N2 �N0) |A2|�T

|A|2 dQ2

◆(45a)

= J

✓��1

T � �1 T

�+�2

�!

T � �2 T

��dV

+

��1⇣

T

+�2�T

�dP

+ �0dN0 + �1dN1 + �2dN2

+

��1

��1

�⇣

T

+ �

T

�� ⇣T � ⌧T

�+�2

��2

��

T

+ ⇣

T

�� �T

+ ⌧

T

��dQ0

+

���1�1⇣T ��2

�⌧

T

+ �2⇣T

��dQ1

+

��1

�⌧

T � �1�T

���2�2�T

�dQ2

◆, (45b)

12

where �i

= (N

i

�N0) / |A|. Hence, we identify the Jacobians, @N

@V

= J

��1

T � �1 T

�+�2

�!

T � �2 T

��,

@N

@P

= J

��1⇣

T

+�2�T

�, @N

@Ni= �

i

J , @N

@Q0= J

��1

��1

�⇣

T

+ �

T

�� ⇣T � ⌧T

�+�2

��2

��

T

+ ⇣

T

�� �T

+ ⌧

T

��,

@N

@Q1= J

���1�1⇣T ��2

�⌧

T

+ �2⇣T

��, and @N

@Q2= J

��1

�⌧

T � �1�T

���2�2�T

�.

Expanding dN in (17) we find that

dW phongreflect =

@W

phongreflect

@V

+

@W

phongreflect

@N

@N

@V

!dV +

@W

phongreflect

@N

@N

@P

dP +

@W

phongreflect

@N

2X

i=0

✓@N

@N

i

dNi

+

@N

@Q

i

dQi

(46a)

where superscript on the Jacobians implies the same form as (17) but with use of the Phong normal, and where the allremaining terms have been have been evaluated in (17) and (45b). Likewise, expanding dN in (22) we find that

dW phongrefract =

@W

phongrefract

@V

+

@W

phongrefract

@N

@N

@V

!dV +

@W

phongrefract

@N

@N

@P

dP

+

@W

phongrefract

@N

2X

i=0

✓@N

@N

i

dNi

+

@N

@Q

i

dQi

◆+

@W

phongrefract@⌘

d⌘ (47a)

where superscript on the Jacobians implies the same form as (22) but with use of the Phong normal, and where the allremaining terms have been have been evaluated in (22) and (45b).

4 Conclusion

In this work, we have evaluated the complete first order spatiotemporal structure of light’s interaction with dielectricmaterials as reflection and refraction. In contrast to earlier work, [Igehy, 1999, Schjøth et al., 2007], we only assumethat the geometry is given as a piecewise smooth surface. The derivation allows for easy extension to other parametersthan viewing directions, and parallel rays are briefly treated as a special case as well as velocities on both the viewpoint, direction and surfaces. Finally, we give two examples in complete detail of common shading models, flat andPhong.

Conceptually, we model ray bundles instead of rays and obvious applications are ray tracing and photon splatting,but the methodology is naturally and easily extended to all phenomena well approximated by first order Taylor series.Our generalization offer more accurate and faithful reconstruction of ray bundles in space and time.

References

[Igehy, 1999] Igehy, H. (1999). Tracing ray differential. In Rockwood, A., editor, Siggraph 1999, Computer GraphicsProceedings, pages 179–186, Los Angeles. Addison Wesley Longman.

[Magnus and Neudecker, 1988] Magnus, J. R. and Neudecker, H. (1988). Matrix Differential Calculus with Applica-tions in Statistics and Econometrics. John Wiley & Sons.

[Schjøth et al., 2007] Schjøth, L., Frisvad, J. R., Erleben, K., and Sporring, J. (2007). Photon differentials. In Pro-ceedings of GRAPHITE 2007.

[Watt and Watt, 1992] Watt, A. and Watt, M. (1992). Advanced Animation and Rendering Techniques – Theory andPractice. Addison-Wesley.

13