Download presentation
Presentation is loading. Please wait.
Published byKelley Hall Modified over 9 years ago
1
An Introduction to Ray Tracing CS 288 10/27/1998 Vic Baker
2
What is Ray Tracing? n “Ray Tracing” determines the visibility of surfaces by tracing imaginary rays of light from the viewer’s eye to the objects in the scene n Ray Tracing evolved from an algorithm used to simulate trajectories of ballistic projectiles and nuclear particles
3
Ray Tracing Algorithm Select center of projection and window on viewplane for (each scan line in image) { for (each pixel in scan line) { determine ray from center of projection through pixel; for (each object in scene) { if ( object is intersected and is closest thus far ) record intersection and object name; } set pixel’s color to that at closest object intersection; }
4
Why Speed Up Ray Tracing? n Depending on the output size of a ray traced image, as well as the complexity of the scene itself, it is not uncommon for a ray traced image to take minutes or days to render!!!! n A 1024x1024 image requires that 1 million pixels be calculated!!!!!
5
Why Speed Up Ray Tracing? n Since ray tracing calculates every pixel’s color, a picture of size 512 x 512 contains 262144 pixels that require a color which is dependent on its distance from the COP, your eye. n A 1024x768 image has 786432 pixels to calculate independently!
7
A Minimal Ray Tracing Program n In an attempt to investigate how computationally demanding rendering a 3D scene is, I will demonstrate a minimal ray tracing program known as Minray.
8
The History of Minray.c n Paul Heckbert (CMU, Pixar) issued a challenge to the graphics community to write the smallest ray tracing program possible. n Minray is the result of taking the best portions of the best entries and combining them into a ray tracer
9
Minray hierarchy chart
10
Frequency chart for a 32x32 image
11
vdot() n Calculates the dot product for two vectors n Each call to vdot requires 113 clock cycles n That’s 120978 * 113 = 13,670,514 clock cycles for a 32x32 image
12
vcomb() n Vcomb adds two vectors n Each call to vcomb requires 155 clock cycles n That’s 155 * 99408 = 15,408,240 clock cycles for a 32x32 image
13
vunit() n Normalizes vectors n Makes calls to vdot and vcomb n Costs 331 clock cycles to execute n That’s 331 * 15946 = 5,278,126 clock cycles
14
intersect() n Determines if a ray intersects an object n Requires vdot() and vcomb() n Costs 2547 clock cycles n Total cost for a 32x32 image is 9011 * 2547 = 22,951,017 clock cycles
15
trace() n Keeps track of nearest intersection of object and maps color to pixel n Costs 141 * 5998 = 845,718 clock cycles for a 32x32 image
16
How can we speed ray tracing up? n By using loop unrolling, straight-lining code, as well as using macros instead of function calls, you can drastically reduce overhead
17
What’s out there? n A good ray tracing program is the POV- Ray. n Let’s see some examples...
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.