ray tracing csis 5838: graphics and animation for gaming

8
Ray Tracing CSIS 5838: Graphics and Animation for Gaming

Upload: scot-baker

Post on 17-Jan-2016

214 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: Ray Tracing CSIS 5838: Graphics and Animation for Gaming

Ray Tracing

CSIS 5838: Graphics and Animation for Gaming

Page 2: 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

Page 3: Ray Tracing CSIS 5838: Graphics and Animation for Gaming

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)

Page 4: Ray Tracing CSIS 5838: Graphics and Animation for Gaming

Ray Tracing and Shading

Better solution:• For each visible face,

trace ray to each lightsource

• If intersect another object first, face is shaded

Page 5: Ray Tracing CSIS 5838: Graphics and Animation for Gaming

Ray Tracing and Color

• Color perceived depends on– Color of surface– Color of light source

• Minimum RGB levels– Surface color: (RS, GS, BS)

– Lamp color: (RL, GL, BL)

– Color reflected: (min(RS, RL), min(GS, GL), min(BS, BL))

Page 6: Ray Tracing CSIS 5838: Graphics and Animation for Gaming

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

Page 7: Ray Tracing CSIS 5838: Graphics and Animation for Gaming

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 …

Page 8: Ray Tracing CSIS 5838: Graphics and Animation for Gaming

Refraction

• Snell’s Law: n1sin1 = n2sin2– 1: Angle of incidence (normal to surface)

– 2: Angle of refraction of ray within new surface