1 Dr. Scott Schaefer Ray Tracing. 2/42 Ray Tracing Provides rendering method with ...

Post on 03-Jan-2016

224 views 2 download

Tags:

Transcript of 1 Dr. Scott Schaefer Ray Tracing. 2/42 Ray Tracing Provides rendering method with ...

1

Dr. Scott Schaefer

Ray Tracing

2/422/42

Ray Tracing

Provides rendering method withRefraction/Transparent surfacesReflective surfacesShadows

3/423/42

Ray Tracing

Provides rendering method withRefraction/Transparent surfacesReflective surfacesShadows

Image taken from http://radsite.lbl.gov/radiance/book/img/plate10.jpg

4/424/42

Ray Tracing

Provides rendering method withRefraction/Transparent surfacesReflective surfacesShadows

Image taken from http://www.tjhsst.edu/~dhyatt/superap/samplex.jpg

5/425/42

Ray Tracing

Provides rendering method withRefraction/Transparent surfacesReflective surfacesShadows

6/426/42

Essential Information for Ray Tracing

Eye point Screen position/orientation Objects

Material propertiesReflection/Refraction coefficients Index of refraction

Light sources

7/427/42

Recursive Ray Tracing

For each pixel Intersect ray from eye through pixel with

all objects in sceneFind closest (positive) intersection to eyeCompute lighting at intersection pointRecur for reflected and refracted rays (if

necessary)

8/42

eye

screen

9/42

eye

screen

10/42

eye

screen

11/42

eye

screen

normal

12/4212/42

Ray Casting

Removes hidden surfaces Per-pixel lighting computations

13/4213/42

Shadows

Cast a virtual ray to each light source If ray hits an opaque object before the light,

then omit contribution of that light If ray hits a semi-transparent object, scale the

contribution of that light and continue to look for intersections

Note: objects may be self-shadowing!!!

14/42

shadow ray

normal

eye

screen

15/4215/42

Shadows

i

nisidia ERkNLkCAkI )()(

16/4216/42

Shadows

i

nisidia ERkNLkCshadowIfAkI )()(,0,

17/42

normal

eye

screen

reflected ray

18/42

normal

eye

screen

shadow ray

reflected ray

normal

19/42

normal reflected ray

eye

screen

normalreflected ray

20/4220/42

Reflection

Mirror-like/Shiny objects

V

N

Surface

R

VNNVR )(2

21/42

eye

screen

normal

refracted ray

22/4222/42

Refraction

Bending of light caused by different speeds of light in different medium

Each (semi-)transparent

object has an index of

refraction ci Use Snell’s law to find

refracted vector

Image taken from http://hyperphysics.phy-astr.gsu.edu/hbase/geoopt/refr2.html

23/4223/42

Snell’s Law

V N1

Surface

2

N R

)sin(

)sin(

2

1

2

1

c

c

24/4224/42

Snell’s Law

V N1

Surface

2

N R

)sin(

)sin(

2

1

2

1

c

cV

||V

25/4225/42

Snell’s Law

N1

Surface

2

N R

)sin(

)sin(

2

1

2

1

c

c

||)sin())(cos( 22 V

VNR

VV

||V

26/4226/42

Snell’s Law

V N1

Surface

2

N R

)sin(

)sin(

2

1

2

1

c

c

||

)()sin())(cos( 22 V

VNNVNR

27/4227/42

Snell’s Law

V N1

Surface

2

N R

)sin(

)sin(

2

1

2

1

c

c

)sin(

)()sin())(cos(

122

VNNVNR

28/4228/42

Snell’s Law

V N1

Surface

2

N R

)sin(

)sin(

2

1

2

1

c

c

))(())(cos(1

22 VNNV

c

cNR

29/4229/42

Snell’s Law

V N1

Surface

2

N R

)sin(

)sin(

2

1

2

1

c

c

))(()()sin(11

222 VNNV

c

cNR

30/4230/42

Snell’s Law

V N1

Surface

2

N R

)sin(

)sin(

2

1

2

1

c

c

))(()()sin(11

22

1

222

1 VNNVc

cN

c

cR

31/4231/42

Snell’s Law

V N1

Surface

2

N R

)sin(

)sin(

2

1

2

1

c

c

))(()(1

)sin(1

2

1

21

22

21 VNNV

c

cN

cccR

32/4232/42

Snell’s Law

V N1

Surface

2

N R

)sin(

)sin(

2

1

2

1

c

c

))(()(1

))(1(1

2

1

222

21 VNNV

c

cN

cNVccR

33/4233/42

Total Internal Reflection

V N1

Surface

2

N R

)sin(

)sin(

2

1

2

1

c

c

))(()(1

))(1(1

2

1

222

21 VNNV

c

cN

cNVccR

34/4234/42

Recursive Ray Tracing

refractedareflectededirect IIII

speculardiffuseambientdirect IIII

directI

reflectedI refractedI

refractedIrefractedIreflectedI reflectedI

e

e e

a

aa

Truncate at finite depth!

35/4235/42

Recursive Ray Tracing

Recur for reflective/transparent objects

36/4236/42

Recursive Ray Tracing

Recur for reflective/transparent objects

37/4237/42

Optimizations

Lots of rays to cast! Ray-Surface intersections are expensive

Associate with each objectBounding box in 3-space

If ray doesn’t intersect box, then ray doesn’t intersect object

38/4238/42

Parallel Processing

Ray tracing is a trivially parallel algorithm!Cast rays in parallelCast reflection, refraction, shadow rays in

parallelCalculate ray/surface intersections

independently in parallel

39/4239/42

Ray Tracing: Special Effects

copyright Newline Cinema

40/4240/42

Ray Tracing: Video Games

41/4241/42

Ray Tracing: Massive Models

42/4242/42

Extensions of Ray Tracing

Only considers totally specular interactions rays either reflect perfectly or refract

perfectly Ray traced scenes don't

show “color bleed”