Raytracing vs Rasterization
There used to be an interesting debate between Professer Philipp Slusallek of the University of Saarbruecken and chief scientist David Kirk of nVidia at GameStar.de (dead link) The original article has been taken down, but I found a slightly mangled version on the Wayback machine and I've cleaned it up a bit....
[snip]
Ray tracing or rasterization?GameStar: Current games are rendered via the well-known rasterization technique. Ray tracing is an old technology, but for the first time we've the power to calculate it in real-time. Why is ray tracing the better (or the worse) technique to render a PC game?
Kirk: Rasterization (Painter's Algorithm or Depth Buffering) has a rendering time that is typically linear in the number of triangles that are drawn, because each polygon must be processed. Since there is specialized hardware for rasterization in modern GPUs, this time is very small per triangle, and modern GPUs can draw 600M polygons per second, or so. Also, Z or depth culling and hierarchical culling can allow the game to not even draw large numbers of polygons, making the complexity even less than linear.
Although it is tempting to think of GPUs as only rasterization engines, modern GPUs are now highly programmable parallel floating processors. The rasterization part of the GPU is only a small part; most of the hardware is devoted to 32-bit floating point shader processors. So, it is now possible to demonstrate real time ray tracing running on GPUs. It is not yet faster than rasterization, but often ray tracers are doing more calculation for the global illumination - shadows, reflections, etc.
I don't think of this as "ray tracing vs. rasterization". I think of it as ray tracing and rasterization. Rasterization hardware can be used to accelerate the intersection and lighting calculations that are part of ray tracing. In particular, the initial visibility calculations - what's in front - are best done with rasterization. Reflections, transparency, etc, can be done with ray tracing shader programs.
Slusallek: Since I am not limited by company politics I will try to be a bit controversial in my responses
.
Ray tracing offers a fairly long list of advantages over rasterization. The fundamental difference is that rasterization can only look at a single triangle at a time. However, most effects require access to at least two triangles: e.g. casting a shadow from one triangle to the other, computing the reflection of one triangle off of another, or simulating the indirect illumination due to light bouncing between all triangles in the scene.
Rasterization must do various tricks to even approximate these effects, e.g. using reflections maps instead of real reflection. For changing environments these maps must be re-computed for every frame using costly additional rendering passes. But even worse, they are simply incorrect for almost all geometry, in particular for close-by or curved objects. Try rendering a car that reflects the street correctly -- games don't, because they can't.
Another big advantage of ray tracing is the ability to render huge data sets very efficiently. Recently we implemented a very simple addition to ray tracing that allows for rendering a Boeing 777 model consisting of ~350 million polygons (roughly 30 GB on disk) at 2-3 frames per second on a single dual Opteron system with just 3-4 GB of memory. Since it uses ray tracing you can automatically also render it with shadows, reflections, and complex shading even in such a large model.
You see, ray tracing is a fundamentally new way of doing interactive graphics that opens up many new opportunities for doing things that were impossible before. Many researchers are picking up realtime ray tracing now that we have demonstrated it running with realtime performance.
Kirk: You missed my point, perhaps intentionally. Rasterization-specific hardware is now <5% of GPU core area. Most of the silicon is devoted to instruction processing, memory access, and floating point computation. Given that a GeForce 6800 has 10-20x the floating point of the Opteron system you describe, you are a poor programmer if you cannot program it to run a ray tracer at least twice as fast on a GPU as on a CPU.
There are no barriers to writing a ray tracer on a GPU, except perhaps in your mind. The triangle database can be kept in the GPU memory buffers as texture information (textures are simply structured arrays). Multiple triangles can be accessed through longer shader programs. Although current GPU memory is limited to 256MB-512MB, the root of the geometry hierarchy can be kept resident, and the detail (leaf nodes) kept in the system memory and disk. In your example of ray tracing 30GB of triangle data, you are clearly using hierarchy or instancing to create a 350M polygon database, since in your 2-3 seconds you do not have time to read that volume of data from disk.
By the way, ray tracing is not a new idea. Turner Whitted's original ray tracing research paper was written in 1980. Most of the algorithmic innovation in the technique happened in the late 80s and early 90s. The most interesting recent advances are path tracing, which casts many more rays to get a more global illumination (light inter-reflection) result. Several universities have written path tracers for GPUs that run on extremely large databases.