Ray Tracing
E0 271 - Lecture 19
October 28, 2019
Vijay Natarajan E0 271: Computer Graphics 1
Today
» Generic ray tracer
» Ray intersections
» Reading: Angel, Chapter 11
Vijay Natarajan E0 271: Computer Graphics 2
What is Ray Tracing?
» Ray tracing
§ Send a ray from eye through pixel
into scene
§ Color determined by ray
intersections with the scene
» Recursive ray tracing
§ Create new rays upon intersection
§ Simulate specular reflections and
indirect illumination
[courtesy: Anders Brodersen, University of Aarhus]
Vijay Natarajan E0 271: Computer Graphics 3
Examples
http://www.povray.org
Vijay Natarajan E0 271: Computer Graphics 4
Examples
http://www.povray.org
Vijay Natarajan E0 271: Computer Graphics 5
Examples
http://www.povray.org
Vijay Natarajan E0 271: Computer Graphics 6
Generic Ray Tracer
» Given camera parameters and image resolution
§ Generate rays r(i,j) from eye passing through center of pixel (i,j)
§ Call function trace (r) on each ray
§ trace (r) returns color of the pixel
» trace (r)
§ Follow ray r into scene
§ Let O be the first object it intersects, P be the point of intersection
§ If O is reflective or translucent, then compute reflected or
transmitted ray and call trace recursively
§ For each light source, apply Phong model to compute shade at
point P if light is visible from P
§ Combine colors obtained from above two steps and return the
composite color
Vijay Natarajan E0 271: Computer Graphics 7
How to determine
composite color?
» Ray tracing equation for a single light source L
I = ka Ia
+ visible (P,L) * (kd Id l · n + ks Is (n · h )b )
+ kr trace(P, rr)
+ kt trace(P, rt)
Vijay Natarajan E0 271: Computer Graphics 8
Rays
» A ray r(t), for 0 ≤ t < ∞, is defined by
its origin P and a direction u:
§ r(t) = P + tu
§ u is a unit vector or not?
Vijay Natarajan E0 271: Computer Graphics 9
Ray Generation
» LookAt()
§ Eye, Gaze, Up
» Perspective()
§ FOV, Aspect ratio
§ Near = 1
» Image resolution
§ nx, ny
Vijay Natarajan E0 271: Computer Graphics 10
Ray-Object Intersection
» Ray-Sphere
§ Point of intersection
§ Normal vector
» Ray-Polygon
§ Point of intersection
» Ray-Triangle
Vijay Natarajan E0 271: Computer Graphics 11
Ray Intersection
» Point of intersection specified by t
» Maintain smallest value t0 (>0) for
each ray
» t0 represents intersection with
nearest object

Given camera parameters and image resolution

  • 1.
    Ray Tracing E0 271- Lecture 19 October 28, 2019
  • 2.
    Vijay Natarajan E0271: Computer Graphics 1 Today » Generic ray tracer » Ray intersections » Reading: Angel, Chapter 11
  • 3.
    Vijay Natarajan E0271: Computer Graphics 2 What is Ray Tracing? » Ray tracing § Send a ray from eye through pixel into scene § Color determined by ray intersections with the scene » Recursive ray tracing § Create new rays upon intersection § Simulate specular reflections and indirect illumination [courtesy: Anders Brodersen, University of Aarhus]
  • 4.
    Vijay Natarajan E0271: Computer Graphics 3 Examples http://www.povray.org
  • 5.
    Vijay Natarajan E0271: Computer Graphics 4 Examples http://www.povray.org
  • 6.
    Vijay Natarajan E0271: Computer Graphics 5 Examples http://www.povray.org
  • 7.
    Vijay Natarajan E0271: Computer Graphics 6 Generic Ray Tracer » Given camera parameters and image resolution § Generate rays r(i,j) from eye passing through center of pixel (i,j) § Call function trace (r) on each ray § trace (r) returns color of the pixel » trace (r) § Follow ray r into scene § Let O be the first object it intersects, P be the point of intersection § If O is reflective or translucent, then compute reflected or transmitted ray and call trace recursively § For each light source, apply Phong model to compute shade at point P if light is visible from P § Combine colors obtained from above two steps and return the composite color
  • 8.
    Vijay Natarajan E0271: Computer Graphics 7 How to determine composite color? » Ray tracing equation for a single light source L I = ka Ia + visible (P,L) * (kd Id l · n + ks Is (n · h )b ) + kr trace(P, rr) + kt trace(P, rt)
  • 9.
    Vijay Natarajan E0271: Computer Graphics 8 Rays » A ray r(t), for 0 ≤ t < ∞, is defined by its origin P and a direction u: § r(t) = P + tu § u is a unit vector or not?
  • 10.
    Vijay Natarajan E0271: Computer Graphics 9 Ray Generation » LookAt() § Eye, Gaze, Up » Perspective() § FOV, Aspect ratio § Near = 1 » Image resolution § nx, ny
  • 11.
    Vijay Natarajan E0271: Computer Graphics 10 Ray-Object Intersection » Ray-Sphere § Point of intersection § Normal vector » Ray-Polygon § Point of intersection » Ray-Triangle
  • 12.
    Vijay Natarajan E0271: Computer Graphics 11 Ray Intersection » Point of intersection specified by t » Maintain smallest value t0 (>0) for each ray » t0 represents intersection with nearest object