Avoid Texture Aliasing and Mipmapping

来源:互联网 发布:企业淘宝开店流程 编辑:程序博客网 时间:2024/05/19 11:49

In ray tracing, if the objects with textures are far from the camera, the spatial sampling frequency would be relatively low, i.e. each pixel of the viewing plane would have to cover multiple texels (texel is the pixel of texture images). As such, it would lead to a kind of aliasing called moir´e pattern. The following is an exampling of the moire pattern (on the surface of floor and buildings):



The problem of aliasing can be addressed by sampling and filtering techniques. The signal frequency of texture depends upon how closely spaced its texels are on the screen. Due to the Nyquist limit, we need to make sure that the texture's signal frequency is no greater than half the sample frequency. For example, say an image is composed of alternating black and white lines, a texel apart. The wavelength is then two texels wide (from black line to black line), so the frequency is 1/2. To properly display this texture on a screen, the frequency must then be at least 2*1/2, i.e. at least one pixel per texel. So, for textures in general, there should be at most one texel per pixel to avoid aliasing.

To achieve this goal, either the pixel's sampling frequency has to increase or the texture frequency has to decrease. The anti-aliasing methods give ways to increase the pixel sampling rate. However, these give only a limited increase in sampling frequency. To more fully address this problem, various texture minification algorithms have been developed.

Mipmapping

The most popular method of anti-aliasing for textures is called mipmapping. It is implemented in some form on even the most modest graphics accelerators now produced. When the mipmapping minimization filter is used, the original texture is augmented with a set of ssmaller versions of the texture before the actual rendering takes place. The texture (level zero) is downsampled to a quater of the origianl data, with each new texel value often computed as the average of four neighbor texels in the original texture. The new, level-one texture is sometimes called a subtexture of the original texture. The reduction is performed recursively until one or both of the dimensions of the texture equals one texel. The set of images as a whole is often called a mipmap chain.

Two important elements in forming high-quality mipmaps are good filtering and gamma correction. The common way to form a mipmap level is to take each 2*2 set of texels and average them to get the mip texel value.

原创粉丝点击