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

42
1 Dr. Scott Schaefer Ray Tracing

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

Page 1: 1 Dr. Scott Schaefer Ray Tracing. 2/42 Ray Tracing Provides rendering method with  Refraction/Transparent surfaces  Reflective surfaces  Shadows.

1

Dr. Scott Schaefer

Ray Tracing

Page 2: 1 Dr. Scott Schaefer Ray Tracing. 2/42 Ray Tracing Provides rendering method with  Refraction/Transparent surfaces  Reflective surfaces  Shadows.

2/422/42

Ray Tracing

Provides rendering method withRefraction/Transparent surfacesReflective surfacesShadows

Page 3: 1 Dr. Scott Schaefer Ray Tracing. 2/42 Ray Tracing Provides rendering method with  Refraction/Transparent surfaces  Reflective surfaces  Shadows.

3/423/42

Ray Tracing

Provides rendering method withRefraction/Transparent surfacesReflective surfacesShadows

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

Page 4: 1 Dr. Scott Schaefer Ray Tracing. 2/42 Ray Tracing Provides rendering method with  Refraction/Transparent surfaces  Reflective surfaces  Shadows.

4/424/42

Ray Tracing

Provides rendering method withRefraction/Transparent surfacesReflective surfacesShadows

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

Page 5: 1 Dr. Scott Schaefer Ray Tracing. 2/42 Ray Tracing Provides rendering method with  Refraction/Transparent surfaces  Reflective surfaces  Shadows.

5/425/42

Ray Tracing

Provides rendering method withRefraction/Transparent surfacesReflective surfacesShadows

Page 6: 1 Dr. Scott Schaefer Ray Tracing. 2/42 Ray Tracing Provides rendering method with  Refraction/Transparent surfaces  Reflective surfaces  Shadows.

6/426/42

Essential Information for Ray Tracing

Eye point Screen position/orientation Objects

Material propertiesReflection/Refraction coefficients Index of refraction

Light sources

Page 7: 1 Dr. Scott Schaefer Ray Tracing. 2/42 Ray Tracing Provides rendering method with  Refraction/Transparent surfaces  Reflective surfaces  Shadows.

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)

Page 8: 1 Dr. Scott Schaefer Ray Tracing. 2/42 Ray Tracing Provides rendering method with  Refraction/Transparent surfaces  Reflective surfaces  Shadows.

8/42

eye

screen

Page 9: 1 Dr. Scott Schaefer Ray Tracing. 2/42 Ray Tracing Provides rendering method with  Refraction/Transparent surfaces  Reflective surfaces  Shadows.

9/42

eye

screen

Page 10: 1 Dr. Scott Schaefer Ray Tracing. 2/42 Ray Tracing Provides rendering method with  Refraction/Transparent surfaces  Reflective surfaces  Shadows.

10/42

eye

screen

Page 11: 1 Dr. Scott Schaefer Ray Tracing. 2/42 Ray Tracing Provides rendering method with  Refraction/Transparent surfaces  Reflective surfaces  Shadows.

11/42

eye

screen

normal

Page 12: 1 Dr. Scott Schaefer Ray Tracing. 2/42 Ray Tracing Provides rendering method with  Refraction/Transparent surfaces  Reflective surfaces  Shadows.

12/4212/42

Ray Casting

Removes hidden surfaces Per-pixel lighting computations

Page 13: 1 Dr. Scott Schaefer Ray Tracing. 2/42 Ray Tracing Provides rendering method with  Refraction/Transparent surfaces  Reflective surfaces  Shadows.

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!!!

Page 14: 1 Dr. Scott Schaefer Ray Tracing. 2/42 Ray Tracing Provides rendering method with  Refraction/Transparent surfaces  Reflective surfaces  Shadows.

14/42

shadow ray

normal

eye

screen

Page 15: 1 Dr. Scott Schaefer Ray Tracing. 2/42 Ray Tracing Provides rendering method with  Refraction/Transparent surfaces  Reflective surfaces  Shadows.

15/4215/42

Shadows

i

nisidia ERkNLkCAkI )()(

Page 16: 1 Dr. Scott Schaefer Ray Tracing. 2/42 Ray Tracing Provides rendering method with  Refraction/Transparent surfaces  Reflective surfaces  Shadows.

16/4216/42

Shadows

i

nisidia ERkNLkCshadowIfAkI )()(,0,

Page 17: 1 Dr. Scott Schaefer Ray Tracing. 2/42 Ray Tracing Provides rendering method with  Refraction/Transparent surfaces  Reflective surfaces  Shadows.

17/42

normal

eye

screen

reflected ray

Page 18: 1 Dr. Scott Schaefer Ray Tracing. 2/42 Ray Tracing Provides rendering method with  Refraction/Transparent surfaces  Reflective surfaces  Shadows.

18/42

normal

eye

screen

shadow ray

reflected ray

normal

Page 19: 1 Dr. Scott Schaefer Ray Tracing. 2/42 Ray Tracing Provides rendering method with  Refraction/Transparent surfaces  Reflective surfaces  Shadows.

19/42

normal reflected ray

eye

screen

normalreflected ray

Page 20: 1 Dr. Scott Schaefer Ray Tracing. 2/42 Ray Tracing Provides rendering method with  Refraction/Transparent surfaces  Reflective surfaces  Shadows.

20/4220/42

Reflection

Mirror-like/Shiny objects

V

N

Surface

R

VNNVR )(2

Page 21: 1 Dr. Scott Schaefer Ray Tracing. 2/42 Ray Tracing Provides rendering method with  Refraction/Transparent surfaces  Reflective surfaces  Shadows.

21/42

eye

screen

normal

refracted ray

Page 22: 1 Dr. Scott Schaefer Ray Tracing. 2/42 Ray Tracing Provides rendering method with  Refraction/Transparent surfaces  Reflective surfaces  Shadows.

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

Page 23: 1 Dr. Scott Schaefer Ray Tracing. 2/42 Ray Tracing Provides rendering method with  Refraction/Transparent surfaces  Reflective surfaces  Shadows.

23/4223/42

Snell’s Law

V N1

Surface

2

N R

)sin(

)sin(

2

1

2

1

c

c

Page 24: 1 Dr. Scott Schaefer Ray Tracing. 2/42 Ray Tracing Provides rendering method with  Refraction/Transparent surfaces  Reflective surfaces  Shadows.

24/4224/42

Snell’s Law

V N1

Surface

2

N R

)sin(

)sin(

2

1

2

1

c

cV

||V

Page 25: 1 Dr. Scott Schaefer Ray Tracing. 2/42 Ray Tracing Provides rendering method with  Refraction/Transparent surfaces  Reflective surfaces  Shadows.

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

Page 26: 1 Dr. Scott Schaefer Ray Tracing. 2/42 Ray Tracing Provides rendering method with  Refraction/Transparent surfaces  Reflective surfaces  Shadows.

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

Page 27: 1 Dr. Scott Schaefer Ray Tracing. 2/42 Ray Tracing Provides rendering method with  Refraction/Transparent surfaces  Reflective surfaces  Shadows.

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

Page 28: 1 Dr. Scott Schaefer Ray Tracing. 2/42 Ray Tracing Provides rendering method with  Refraction/Transparent surfaces  Reflective surfaces  Shadows.

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

Page 29: 1 Dr. Scott Schaefer Ray Tracing. 2/42 Ray Tracing Provides rendering method with  Refraction/Transparent surfaces  Reflective surfaces  Shadows.

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

Page 30: 1 Dr. Scott Schaefer Ray Tracing. 2/42 Ray Tracing Provides rendering method with  Refraction/Transparent surfaces  Reflective surfaces  Shadows.

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

Page 31: 1 Dr. Scott Schaefer Ray Tracing. 2/42 Ray Tracing Provides rendering method with  Refraction/Transparent surfaces  Reflective surfaces  Shadows.

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

Page 32: 1 Dr. Scott Schaefer Ray Tracing. 2/42 Ray Tracing Provides rendering method with  Refraction/Transparent surfaces  Reflective surfaces  Shadows.

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

Page 33: 1 Dr. Scott Schaefer Ray Tracing. 2/42 Ray Tracing Provides rendering method with  Refraction/Transparent surfaces  Reflective surfaces  Shadows.

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

Page 34: 1 Dr. Scott Schaefer Ray Tracing. 2/42 Ray Tracing Provides rendering method with  Refraction/Transparent surfaces  Reflective surfaces  Shadows.

34/4234/42

Recursive Ray Tracing

refractedareflectededirect IIII

speculardiffuseambientdirect IIII

directI

reflectedI refractedI

refractedIrefractedIreflectedI reflectedI

e

e e

a

aa

Truncate at finite depth!

Page 35: 1 Dr. Scott Schaefer Ray Tracing. 2/42 Ray Tracing Provides rendering method with  Refraction/Transparent surfaces  Reflective surfaces  Shadows.

35/4235/42

Recursive Ray Tracing

Recur for reflective/transparent objects

Page 36: 1 Dr. Scott Schaefer Ray Tracing. 2/42 Ray Tracing Provides rendering method with  Refraction/Transparent surfaces  Reflective surfaces  Shadows.

36/4236/42

Recursive Ray Tracing

Recur for reflective/transparent objects

Page 37: 1 Dr. Scott Schaefer Ray Tracing. 2/42 Ray Tracing Provides rendering method with  Refraction/Transparent surfaces  Reflective surfaces  Shadows.

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

Page 38: 1 Dr. Scott Schaefer Ray Tracing. 2/42 Ray Tracing Provides rendering method with  Refraction/Transparent surfaces  Reflective surfaces  Shadows.

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

Page 39: 1 Dr. Scott Schaefer Ray Tracing. 2/42 Ray Tracing Provides rendering method with  Refraction/Transparent surfaces  Reflective surfaces  Shadows.

39/4239/42

Ray Tracing: Special Effects

copyright Newline Cinema

Page 40: 1 Dr. Scott Schaefer Ray Tracing. 2/42 Ray Tracing Provides rendering method with  Refraction/Transparent surfaces  Reflective surfaces  Shadows.

40/4240/42

Ray Tracing: Video Games

Page 41: 1 Dr. Scott Schaefer Ray Tracing. 2/42 Ray Tracing Provides rendering method with  Refraction/Transparent surfaces  Reflective surfaces  Shadows.

41/4241/42

Ray Tracing: Massive Models

Page 42: 1 Dr. Scott Schaefer Ray Tracing. 2/42 Ray Tracing Provides rendering method with  Refraction/Transparent surfaces  Reflective surfaces  Shadows.

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”