Ray Tracing Assignment Goal is to reproduce the following Whitted, - - PDF document

ray tracing assignment
SMART_READER_LITE
LIVE PREVIEW

Ray Tracing Assignment Goal is to reproduce the following Whitted, - - PDF document

So You Want to Write a Ray Tracer Checkpoint 3 Basic Shading Ray Tracing Assignment Goal is to reproduce the following Whitted, 1980 1 Ray Tracing Assignment Seven checkpoints Setting the Scene Camera Modeling


slide-1
SLIDE 1

1

So You Want to Write a Ray Tracer

Checkpoint 3 – Basic Shading

Ray Tracing Assignment

 Goal is to reproduce the following Whitted, 1980

slide-2
SLIDE 2

2

Ray Tracing Assignment

Seven checkpoints

  Setting the Scene  Camera Modeling  Basic Shading   Procedural Shading  Recursive Ray Tracing – Reflection  Recursive Ray Tracing – Transmission   Tone Reproduction

Ray Tracing Assignment

Seven checkpoints

  Setting the Scene  Camera Modeling  Basic Shading   Procedural Shading  Recursive Ray Tracing – Reflection  Recursive Ray Tracing – Transmission   Tone Reproduction

slide-3
SLIDE 3

3

Basic Shading

 Add Illumination Model and Shadow

testing to your ray tracer.

 On intersection

 Rather than return color of object hit  Check to see if point is illuminated (by

spawning shadow ray)

 If so calculate color at intersection point using

Illumination model

Illumination Models

 Geometry

N H S V R

reflection viewer normal Half-way source

slide-4
SLIDE 4

4

Illumination Models

 Geometry

 N - normal vector  S - direction of incoming light  R - direction of perfect mirror reflection  H - halfway between light direction and

viewing direction.

 V - viewing direction.

Phong Model

 Default is to implement Phong Model

 introduces specular (mirror-like) reflections  Viewer direction becomes more important  three components

 ambient - background light (ka)  diffuse - Lambertian reflection (kd)  specular – mirror-like reflection(ks)

slide-5
SLIDE 5

5

Illumination Models

 Recall from Linear Algebra

θ u v

  • cos

v u v u =

  • Just one reason to normalize!

Phong Model

specular diffuse ambient

V) R ( N) S ( ) (

∑ ∑

  • +
  • +

=

i k i i s i i i d a a

e

L k L k L k V L

Note: Ln are radiance terms, include both light and material info

slide-6
SLIDE 6

6

Parameters to add

 To your world:

 Ambient light – background light (r,g,b)

 To the light source

 Color (r,g,b) gives intensity and chroma.

Parameters to add

 To each object

 Phong parameters

 ambient - background light (ka)  diffuse - Lambertian reflection (kd)  specular – mirror-like reflection(ks)  exponent – controls size of specular highlight (ke)

 Object “color”

 ambient / diffuse color – basic color of object  Specular color – color of specular highlight (white

usually)

slide-7
SLIDE 7

7

Only apply if you can see the light from point of intersection!

Phong Model

specular diffuse ambient

V) R ( N) S ( ) (

∑ ∑

  • +
  • +

=

i k i i s i i i d a a

e

L k L k L k V L

Ambient light color x ambient object color light source color x diffuse object color light source color x specular object color

Phong Model

 A note about ambient

 Ambient light is a kludge to model

“background light” resulting from multiple scatterings.

 If shadow ray does not reach a light

source…should ambient component be included?

 You make the call.

slide-8
SLIDE 8

8

Vectors you will need

 Point of intersection

 Get from intersection calculation

 N - normal vector

 Get from intersection calculation

 S - direction of incoming light

 Light position – point of intersection  Shadow ray: Need to know if we can see the light

 R - direction of perfect mirror reflection

 On next slides

 V - viewing direction.

 Camera position – point of intersection

 NORMALIZE ALL VECTORS

Reflection

Reflection Angle of incidence of ray = Angle of reflectance Perfect mirror surface

i

  • r
  • d

r

slide-9
SLIDE 9

9

Calculating Reflection

n n n S 2 S 2a S r

2

= + =

i

  • r
  • S

r n a

where S is the ray from the intersection point to the light source, r is the reflected ray, and θr equals θi

a

For derivation, see http://astronomy.swin.edu.au/~pbourke/geometry/reflected.

Applying Phong

 If there is an intersection

 Calculate ambient component  Get the point of intersection (P)  Spawn a shadow ray from P to the light source  If the ray reaches the light before any other object

 Obtain N, V, S, and calculate R  Calculate specular and diffuse components  Add to ambient componet

 Return resultant color.

slide-10
SLIDE 10

10

Basic Shading

 Due date:

 Must be posted to Web site by Monday, Jan 14.  Recall:

 10% penalty per day

 Having trouble?

 Let me know EARLY.

 Questions?

Object oriented hints

slide-11
SLIDE 11

11

Extra, Extra

 For 5 points

 Add support for multiple light sources  Implement another illumination model

 Phong-Blinn (see slides)  Strauss (see paper)

 Include multiple images on Web site if

extras are implemented