17.2. Avoiding Aliasing
One way to achieve good results without aliasing is to avoid situations in which aliasing occurs.
For instance, if you know that a particular object will always be a certain size in the final rendered image, you can design a shader that looks good while rendering that object at that size. This is the assumption behind some of the shaders presented previously in this book. The smoothstep, mix, and clamp functions are handy functions to use to avoid sharp transitions and to make a procedural texture look good at a particular scale.
Aliasing is often a problem when you are rendering an object at different sizes. Mipmap textures address this very issue, and you can do something similar with shaders. If you know that a particular object must appear at different sizes in the final rendering, you can design a shader for each different size. Each of these shaders would provide an appropriate level of detail and avoid aliasing for an object of that size. For this to work, the application must determine the approximate size of the final rendered object before it is drawn and then install the appropriate shader. In addition, if a continuous zoom (in or out) is applied to a single object, some "popping" will occur when the level of detail changes.
You can avoid aliasing in some situations by using a texture instead of computing something procedurally. This lets you take advantage of the FILTERING (i.e., antialiasing) support that is built into the texture-mapping hardware. However, there are issues with using stored textures as opposed to doing things procedurally, as discussed in Chapter 11.