Home --> Programming Projects --> Raytracing
Procedural Worlds Raytracing (lazily) procedurally generated worlds
Pixel Shifting Recycling pixels on the screen using raytracing to fill in holes

I am a huge fan of raytracing. It allows graphics code to be written much more elegantly and effectively, and I believe it is better (for complex enough scenes) than the paradigm of calculating PVS sets before rendering and then rasterizing the appropriate geometry.

If you ask most graphics programmers, they will tell you that raytracing is slower than rasterizing. This is true (for the current scenes being rendered in real time today) because of the relatively low ratio of the number of objects in the world to the number of pixels on the screen. That is, given that there are a million pixels on the screen, even a small amount of complex computations per pixel would make the raytracing process slower than simply telling the graphics card to rasterize a million objects.

But what about when there are a billion objects? Or a trillion? One might say that a scene with a trillion objects is contrived and that the amount of time required for paging would cripple the system anyway. However, we can imagine enormous scenes that do not take up all that much memory if they involve repetitions of geometry. For example, in the above picture of the reflective spheres, the amount of memory needed to store the sceene was sublinear in the number of spheres! It is in these sceenes in which raytracing is truly beneficial.

How do computer games, such as Quake or Half-Life rasterize complex sceenes in real-time? The secret is that, ahead of time, they break the level up into chunks and they compute which chunks are visible from every other chunk. This is a difficult task, because it is harder to determine what is visible from a region than what is visible from a single point (that latter is all raytracing has to do). Without this precomputed visibility information, rasterizing a scene in real time would be more time consuming (and in many cases quite wasteful). Thus, the real battle is not between Rasterizing and Raytracing, but between Rasterizing + Precomputing Visibility Information and Raytracing (raytracing solves the visibility problem automatically every frame). In sceenes in which effectively precomputing visibily information is infeasible, raytracing has a significant advantage.