Day 13 - Ray Tracing I

What do I need as a minimum to render an image?

  • Camera
  • Light
  • Object

How do we define these things in code?

Starter Code

  • Camera

    • Origin
    • Look at direction
    • FOV field of View
    • Camera Up vector
  • Light

    • Sun, direction to light
  • Object

    • Spheres, Origin + Radius
  • Ray + Sphere intersection

    • Line
    • Line Segment
    • Ray, Camera origin off to infinity
  • Ray

    • Origin + Direction * t
  • Discriminant

    • If the discriminant is negative.... We didn't hit the sphere.
    • If not we hit the sphere (but maybe by going backwards)

Ray + Sphere Collisions

  • a = dot(d,d)
  • b = 2 * dot(d, sub(o,center))
  • c = dot(sub(o, center), sub(o,center)) - (r * r)

Ending Code