Day 14 - Ray Tracing II
Ray + Sphere Collision Review
- a = dot(d,d)
- b = 2 * dot(d, sub(o,center))
- c = dot(sub(o, center), sub(o,center)) - (r * r)
Getting the collision Point
Two possible values for t
What is both less than 0?
What if one greater than 0?
What is both greater than 0?
Shading the sphere
Calculate the nomrmal at the collision point
Calculate the diffuse ilumination
Add the ambient component
Run the ray tracer in a for loop
Store the location of the closest collision and the object at that location
If there is no collision, ose the background color.