Anti-aliasing

Because pixels are not infinitely small, diagonal lines will tend to be rendered as stairsteps, or jaggies. The following illustration shows a zoomed-in view:

images/next/aliased-image.png

This phenomenon is called aliasing, and a lot of effort goes into working around it in production-quality imagery. One such anti-aliasing technique renders the image at much higher resolution (double, triple, or more), and then requires a separate image editor to resample the picture to a smaller resolution. This essentially averages the values of adjacent pixels, and helps smooth those jagged stairsteps.

You can anti-alias in a single step, though, using a technique called supersampling. Instead of casting a single ray for each pixel, you cast multiple rays, each passing through a different (and perhaps random) point offset from the center of the pixel, and average their results. Once again, the more rays you cast, the higher the quality of the result. The image is an anti-aliased example of the previous image, rendered using this supersampling technique.

images/next/antialiased-image.png

More rays equals more work, so don’t expect this technique to come cheaply. You can optimize it, though. For instance, instead of always casting the same number of rays per pixel, you can start by casting one at each corner of the pixel, and one in the pixel’s center. If any of the corners differ from the center by more than some threshold amount, you can subdivide that quarter of the pixel and repeat the process, recursively. Even then, because of the time and energy cost, you’ll want to save this for the end of the production process.

You can do plenty of other things to your ray tracer that don’t require casting more rays. For instance, you can wallpaper textures and imagery onto shapes with texture maps.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.12.71.146