Rasterization and Ray Tracing

advertisement
Rasterization and Ray Tracing in
Real-Time Applications (Games)
Andrew Graff
Overview
• What are rasterization and ray tracing
• Why rasterization is King
• How rasterization works
– Pros/Cons
• How ray tracing works
– Pros/Cons
• Conclusion
• Questions?
What is rasterization and ray tracing?
• Rasterization
– Given a set of rays and a primitive, efficiently
compute the subset of rays hitting the primitive
• Ray Tracing
– Given a ray and a set of primitives, efficiently
compute the subset of primitives hit by the ray
Why rasterization is King
• Early 80’s
– Development was being done on several graphical
visualization techniques, but the two major were
rasterization and ray tracing.
– Ray tracing involved complex and time consuming
calculations
– Rasterization was relatively simple and required
little computation time
• Bottom line: Cost of hardware
How rasterization works
How rasterization works
• Application
– This is the application
that has the information
about what is to be
rendered.
– Sends information about
vertex locations of scene
to graphics hardware.
How rasterization works
• Vertex shader
– Collects information about
vertices one triangle at a time
– Multiple vertex shaders in
parallel
– Gathers X, Y, and Z
information for each vertex
– Also gather light information
if object is directly lit by a
source
– Optimization: Z-culling
How rasterization works
• Rasterizer
– Converts vertex
information into pixel
representation
How rasterization works
• Shader
– Most difficult stage
– Multiple pixel shaders in
parallel
– Two primary methods;
shadow maps and shadow
volumes
– Texture filtering
– Bump mapping
How rasterization works
• Framebuffer
– Memory structure that
holds final information
and is sampled for
display
– Multiple ways to sample
– May or may not update
all pixels (if no update)
Example of shadow volumes
Rasterization
• Pros
– Hardware is ubiquitous.
– Hardware is inexpensive.
– Primary real-time graphics method, therefore, lots of people
developing new techniques and improving all the time.
– Rasterization pipeline has evolved to be more flexible allowing
for new techniques to be developed.
• Cons
– Difficult to render realistic images.
– Requires new and complex algorithms to solve simple problems
like shadows, light, and reflection.
– Large memory requirements.
How ray tracing works
How ray tracing works
• Ray-generation
– Creates a ray that will
travel into or through
the scene
– May be called by the
shading stage
How ray tracing works
• Ray-traversal
– This step follows the ray
through the scene until a
possible intersection is
detected
– Scene stored in a 3D
structure, as ray passes
through, queries to see if
primitives exist within
distance of ray
How ray tracing works
• Intersection
– Calculates if the ray
actually intersects a
primitive
– If it intersects, move on
to shading; if not, go
back to ray traversal
How ray tracing works
• Shading
– Most complex stage.
– Gathers all data and finalizes
pixel color
– Calls ray-generation to create
reflection/refraction rays and
shadow rays
– Writes to the frame buffer
How ray tracing works
• Framebuffer
– Memory structure that
holds final information
and is sampled for
display
– Multiple ways to sample
– May or may not update
all pixels (if no update)
How ray tracing works
Image rendered using ray tracing
Image rendered using ray tracing
Image rendered using ray tracing
• This scene was rendered with a Nvidia GTX 480
using Nvidia’s OptiX ray tracing engine
– 1920x1080 resolution
– The GTX 480 is capable of processing 48 million rays/s.
– Runs at a stunning 4.5 fps!
Ray Tracing
• Pros
– Can create extremely realistic images
– Follows line-of-sight so only calculates what can
be seen
– Shadows can be calculated accurately at time of
rendering
• Cons
– Time consuming
– No real ray-tracing focused hardware
Conclusion
• Ray tracing isn’t ready for real-time yet.
• Potential to combine techniques for more
realistic images without sacrificing a lot of
performance.
• More focus on hardware and algorithms could
result in real-time ray tracing.
Questions?
Download