Speed (t)Racer Gene Au-yeung, Daniel Quach, Jeffrey Su, Albert Wang, Jessica Wang, David Woo
What Is Ray Tracing?
Rendering technique: 3D scene to 2D image
Simulates physics of light propagation (rays).
Primary ray: from perspective of viewer (shot for every pixel on the screen)
Algorithm determines which object is hit first on ray’s path
What Is Ray Tracing? (cont’d)
At that hitpoint, a shader program is invoked.
To simulate a mirror reflection, the shader program can cast another ray
What Is Ray Tracing? (cont’d)
Shadow rays depend if the pixel is lit or in shadow
A pixel is lit if a ray can be shot to the light source without obstruction
If blocked, the pixel is in shadow
Sequential Algorithm
for each row for each column▪ Construct ray from camera through
pixel (row, column)▪ Find first shape hit by ray▪ If (shape)
Calculate color at intersection point▪ Else
Calculate background color▪ Draw color
Sequential Algorithm
Color Calculation for each light source▪ if light is visible from this point▪ Add light source’s contribution
Add contribution due to reflected ray
Add contribution due to refracted ray
Raytracer Features
Currently supports: spheres, reflections, shadows, diffuse lighting
Implement: Refraction (Gene) Planes (David) Triangles (Albert) Textures (Jessica) Anti-Aliasing (Gene, Daniel)
Parallelization: Initial investigation: Jeffrey Whoever finishes their feature help Jeffrey
Parallelization Opportunities
The bulk of ray tracer’s work lies in the recursive steps of reflecting each ray
However, we cannot parallelize each reflection since the second reflection cannot be completed until the first is doneMust wait for this ray to
trace
Before starting the 2nd or 3rd
Parallelization Opportunities
Instead, we can parallelize the primary rays traced from the camera to the viewport
Divide viewport into 8 columns, have one thread calculating primary rays in each column
No data dependency, since each pixel’s color can be found independently of other pixels
Parallelization Opportunities
With addition of anti-aliasing, a potential data dependency can occur as each primary ray requires information about the results of surrounding rays
Our potential solution is to re-check for edges at the boundaries between the 8 columns, then only apply anti-aliasing to pixels which are an edge
Projected Schedule
Currently: framework and repository ready
Week 7: Implement raytracing features Investigate parallelism using baseline
code Week 8:
Parallelize finished raytracer Week 9:
Conduct performance tests between sequential and parallelized versions
Sources
http://www.athlonmp.com/reviews/processors/ray-tracing-and-gaming-one-year-later/
http://www.codermind.com/articles/Raytracer-in-C++-Part-III-Textures.html