CS计算机代考程序代写 Ray Tracing

Ray Tracing

1

Ray Tracing: Selection of
advanced topics

2

Features

Advantages
 model higher order specular reflection and transmission
 model visible surface detection, complex shadow effects

and transparency
 highly realistic for shiny objects

Limitations
 does not model diffuse effects
 produce “hard shadow” (i.e. boundary of shadow is

sharp)
 more computationally intensive than ray casting

3

Ray Casting (fig. 9-26)

 retrace the light paths of the rays that arrive at the pixel

 for each pixel, send a ray from PRP that goes through
the pixel

 find all intersections of the ray with the surfaces
 the nearest intersections is the visible part of the surface

for that pixel

4

5

Ray Tracing
 extension of ray casting. Ray tracing continues to

bounce the ray around the scene, collecting intensity
contributions

6

Reflection and refraction rays

 reflect the ray off the surface along the specular path R
 R is calculated in the usual way (see Lecture 7)
 if the surface is semi-transparent, also send a ray

through the surface in the refraction direction T.

 reflection and refraction rays are called secondary rays.

7

Modelling transparency

NuT i
r

i
r

r

i )cos(cos θ
η
η

θ
η
η

−−=

Lu −=

8

9

Binary ray tracing tree

 recursively apply to each secondary ray, generate a
binary ray-tracing tree (Fig. 10-55)

 a secondary ray terminates if
i) it does not hit any surface or
ii) it hits a light source

 ray tracing tree terminates if it reaches a pre-set
maximum depth

10

Calculate intensity at each node

 Intensity at each node is calculated in the usual way,
i.e.,

 Incorporate shadow effect
 “multiple shadows”, “shadow within shadow” can be modelled

 The path along L is referred to as the shadow ray. The idea is to
let Ili = 0 if there is an object between the surface and light source
i

I k I I k N L k V Ra a li d i s i
n

i

n
s= + ⋅ + ⋅

=
∑ [ ( ) ( ) ]

1

11

Attenuate light intensity at each edge
 surface intensity from each node in the tree is attenuated

by the distance from the “parent surface” (next node up
the tree) and added to the intensity of the parent surface

 light attenuates according to inverse square law 1/d2

 Include constant and linear term as well for realism



++

=

2
210 dadaa

1

0.1
)d(f

if light source at infinity

if otherwise

12

Calculating pixel intensity
 At the bottom (terminal nodes) of tree. If a secondary ray

i) hits a light source, assign the intensity of the source
ii) does not hit any surface, assign the intensity of the
background

 Start at the bottom and proceed to the top, sum up the
attenuated intensity at each node (i.e., reverse trace the
light paths)

 pixel intensity = Intensity at the root node of the tree

13

References

 Ray tracing: Ch. 21-1
 Distance attenuation function: Ch. 17-1

Ray Tracing: Selection of advanced topics
Features
Ray Casting (fig. 9-26)
Slide Number 4
Ray Tracing
Reflection and refraction rays
Modelling transparency
Slide Number 8
Binary ray tracing tree
Calculate intensity at each node
Attenuate light intensity at each edge
Calculating pixel intensity
References