Ray Tracing and Gaming - One Year Later
Ray tracing faster than rasterization: Example 2
The second example is a case study on multiple reflections in reflections on spheres and tori.
|A Torus is the mathematical term for a geometric object that has the shape of a donut. The plural of a Torus is some Tori.
Multiple reflections in reflections - Click here for 80MB PNG file (10200x6000)
If we could just pretend for a moment, and ignore the fact that is scene would be impossible to render this scene using rasterization, not only is it possible to do this correctly with ray tracing, it's actually much cheaper than you might think! Ray tracing efficiently and accurately calculates all reflections on an as-needed basis. That means that only what is actually visible will be actually calculated. Consider the following sequence of images to see how the rays are actually used:
Step 1: "Eye" rays – at least one per pixel - (Tinted Red)
Step 2: Primary reflections (Tinted Green)
Step 3: Secondary reflections (Tinted Blue)
Step 4: 3rd order reflections (Tinted Yellow)
Step 5: ...
So clearly, with each iteration, the number of subsequent reflection rays decreases dramatically, therefore even a complex scene with many reflections represents only a small incremental cost with ray tracing.
How are reflections handled in rasterization?
In order to simulate reflections, the scene is pre-rendered from at least one camera position and saved to a texture map (called a reflection map, sometimes a cube map) which is then applied as a layer of texturing in a subsequent rendering of the scene, a similar method is used to create shadow maps, each of these passes requires rendering the scene before you really render the scene!
There are different cases and methods:
- Below is an example of a one-pass reflection map texture notice the fish-eye lens distortion effect.
- Here is a 2-pass reflection mapping which results in parabolic distortion.
Here we have 6 passes to create a cube-map.
Image copyright Paul Bourke (http://local.wasp.uwa.edu.au/~pbourke/projection/cuberender/)
There are several more algorithms that result in only minor improvements over these techniques
Limitations of the rasterization approaches:
- Rendering into a texture can lead to visible jaggies due to incorrect sampling issues (an object that may have been far away from the camera in the reflection map calculation pass, and hence represent a tiny part of the reflection map, might end up being much closer to the camera during game play and hence get distorted).
- Rendering into a texture consumes time. Worst case: In the final image only one pixel of the reflection is visible, but to create the cube map approach the scene has been rendered additionally six times.
- How to handle multiple reflections? Very difficult to achieve, and in most cases just hopelessly impossible. It requires pre-calculating the reflections then rendering the scene, then evaluating the reflections in reflections and then re-rendering the scene and...
- As these reflection maps are not based on physical laws therefore the reflections are not correct anyway.
What all those approaches try to do is an approximation of ray tracing.
As mentioned in the first example: The speed of ray tracing scales logarithmically with the number of triangles. This applies, of course, also for all reflection rays. So in a scene with a very high poly count and with reflections ray tracing can take even greater advantage of this situation (ie single rendering pass, only pay for reflections where they actually happen).
Get notified when we go live!
PC Perspective Live! Google Calendar RSS