DirectX 10 Ray Tracing - University of Central Florida

Download Report

Transcript DirectX 10 Ray Tracing - University of Central Florida

DirectX 10 Ray
Tracing
Tad Litwiller
Background



Technique for image generation that traces
the path of light through pixels of an image
plane
Produces very realistic images, does well
with reflection, refraction, accurate
shadows, etc.
Computationally expensive
Algorithm




Trace a path from the viewpoint through each
pixel in an image plane and into the scene
Test for intersection with each object in the scene
If there is a ray-object collision, perform shading
and generate reflection, refraction, and shadow
rays
Composite results of shaded object material with
additional rays
Algorithm
Algorithm


Ray can be defined by direction vector, and
origin
My implementation supports spheres as
objects – defined by center point and radius


Objects have material with emissive, ambient,
diffuse, specular, specular power, reflection,
and refraction
Light source defined by position and color
Algorithm


Use DirectX to set up a Draw of points
(ex. 1024x1024)
The vertex shader will be run once per
vertex (point in this case)


Set up the initial eye ray origin and direction
The geometry shader is run once per
primitive, points in this case
Algorithm – Geometry Shader


Eye ray is sent from the VS
Test eye ray for intersection with each
sphere in the scene


Use the eye position and sphere center to get
the distance, multiply by the ray direction, use
quadratic equation to test intesection
If there is an intersection – cast additional
rays and use blinn-phong shading
Algorithm – Additional Rays

Shadow


Reflected


Trace a ray from the intersection point to each light source
– if this ray hits any other object – its in a shadow
Angle of incident ray matches angle of outgoing ray – if
reflected ray hits an object, use color from that object
Refracted

Ray passes through object and ray is bent depending on
properties of object - if refracted ray hits an object, use
color from that object
Algorith – Blinn-Phong Shading


Use light vector, view vector, and the normal
Ambient


Diffuse


Light and normal vectors – intensity is the same when
viewed from any angle
Specular


Constant – doesn’t depend on vectors
Depends on all – highlights vary depending on viewing
angle
Emissive

Constant – object emits light
Testing



Implemented same algorithm for both a CPU and
GPU
Tested resolutions of 512x512, 1024x1024, and
2048x2048
CPU – AMD Phenom X4



2.5 GHz
4GB RAM
GPU – ATI Radeon HD 4670



750 MHz Core
512 MB
320 Stream Processors
CPU
GPU - Video
Results
Conclusion

This is a very simplistic algorithm – only
spheres and no acceleration structure

Can be much more optimized on both CPU and
GPU, so speed up will likely change, but still be
very high because of the high level of data
parallelism
Future Work



Add ray-triangle intersection so much more
robust objects could be loaded
Add an acceleration structure such as
uniform grid, bounding volume, or k d-tree
Use geometry shader more effectively for
additional ray bounces – stream out and
DrawAuto
References




Timothy John Purcell, Ray Tracing on a Stream
Processor, 2004.
Martin Christen, Ray Tracing on GPU, 2005.
Timothy J. Purcell, Ray Tracing on Programmable
Graphics Hardware, SIGGRAPH
Colleagues: Vineet Goel, Mangesh Nijasure and
Marcos Zini
Questions?