Ray Tracing CSIS 5838: Graphics and Animation for Gaming
Ray Tracing Goals: – Find what surfaces are visible to camera – Find the color/shading of those surfaces Simple solution (from physics) – Project rays from light sources in all directions – Determine which rays reach visual plane Extremely inefficient! – Most rays never reach visual plane
Ray Tracing and Visibility Better solution: Project rays from focal center in all directions that intersect visual plane Determine first face that ray intersects (visibility)
Ray Tracing and Shading Better solution: For each visible face, trace ray to each light source If intersect another object first, face is shaded
Ray Tracing and Color Color perceived depends on – Color of surface – Color of light source Minimum RGB levels – Surface color: (R S, G S, B S ) – Lamp color: (R L, G L, B L ) – Color reflected: (min(R S, R L ), min(G S, G L ), min(B S, B L ))
Reflection Reflection done by continuing ray trace off of mirrored surfaces – Continue in opposite angle as incident angle to surface normal – Specify maximum number of ray trace steps
Refraction Density of transparent objects cause light to bend Index of refraction (IOR) n = c/v – c = speed of light in vacuum – v = speed of light in medium Examples: – Water: n = 1.33 – Glass: n 1.5 …
Refraction Snell’s Law: n 1 sin 1 = n 2 sin 2 – 1 : Angle of incidence (normal to surface) – 2 : Angle of refraction of ray within new surface