13 Ray Tracing 1 Whitted-Style

Shadow Mapping before we move on


Whitted-Style Ray Tracing


Why Ray Tracing?

  • Rasterization couldn’t handle global effects well
    • Soft shadow
    • Light bounces more than once
  • Ray Tracing is accurate, but is very slow
    • Rasterization: real-time, ray tracing: offline
    • ~10k CPU core hours to render one frame in production.


  1. Light Rays:
    1. Light travels in straight lines 直线传播
    2. Light rays do not collide with each other if they cross 不相互影响
    3. Light rays travel from the light sources to the eye (but the physics is invariant under the path reversal - reciprocity) 光路可逆
  2. Ray Casting
    1. Generate an image by casting one ray per pixel.
    2. Check forshadows by sending a ray to the light.
  3. Recursive (Whitted-Style) Ray Tracing
    1. 从像素出发,折射再反射,每个点看一下是否有光,每次都着色。
    2. 过曝?每次都用一定的百分比衰减
    3. 术语:primary ray, secondary ray, shadow ray …
  4. 技术问题:
    1. Ray-surface intersection 光线和物体表面怎么求
      1. Ray Equation:
        • Ray is defined by its origin and a dierction vector.$Ray:R(t)=O+td$
      2. Ray Intersection With Sphere
      3. Ray Intersection with Triangle Mesh
        • Rendering: visibility shadows lighting
        • Geometry: inside/outside
        • Method: Triangle is in a plane.
          • Plane: a normal vector and a point in the plane
          • if a point p in the plane: $(p-p’)\cdot \vec{N} = 0$
          • MT Algorithm: t,b1,b2 的线性方程组
      4. Ray Tracing - Performance Challenges
        • Too Slow