14 - Ray Casting HSR

ucla | CS 174A | 2024-03-19 02:35


Table of Contents

Backward Ray casting

  • a WS or ES algo
  • Forward ray casting is hard:
  • Backward ray casting: hoot a ray FROM eye -> through pixel -> intersect with all objects in the world space
  • NOTE for complex polygons/polyhedrons, we can draw bounding boxes to make intersection calculations easier
  • Step 1

  • find coords of the ith pixel using the half angle
  • then generate the ray (in ES) from eye (origin) through the center of the pixel using the x,y coords of the pixel, then z is at z=1 (we position the grid representation of the viewport/screen at z=1)

    Step 2

  • check for intersection with each object
  • if there is an intersection, then calc intersection illumination

    Casting in WS: need to factor in eye coords

    Ray casting Spheres

  • pick the closest intersection of an intersected sphere
  • find the normal at that point: N=PPc
    • where P is the intersection point
    • Pc is the center of the intersected sphere B24AC<0 no intersection B24AC=0 1 intersection B24AC>0 2 intersections, choose the closest (smallest t) where we determine A,B,C as:

      Ray casting Polygons

  • if planar polygon, then normal is A,B,C
  • else, interp normal given vertex normals
  • after plugging ES ray with plane, we solve for the interp param t=DAxp+Byp+C