HiEnd3D
About
News
Demos & Docs
SmartFlt
16xFSAA
hq2x
hq3x
hq4x
Links
Author
E-mail


Demos & Docs -- SmartFlt


Smart Texture Filtering

by Maxim Stepin


Screenshots:



Point Sampling Filtering Bilinear Filtering Smart Filtering


Files:

Executable SmartFlt.zip90Kb04.20.2002
Source codeSmartFlt_src.zip30Kb04.20.2002


Description:

Texture filtering is a fundamental feature of modern 3D graphics. Before 3D acceleration was born, 'blocky' point-sampling filter was the only choice for real-time texture mapping. Now we have variety of filters for texture minification, mostly based on mip-mapping technique, and only one - bilinear filter - for texture magnification.

Bilinear filter provides satisfactory results in most cases, especially when color derivation of adjacent texels in relatively low. However, in practice, many textures contain several color-uniform areas with apparent borders between them. By smoothing these borders, bilinear filter causes image appear too blurry. Human visual perception based a lot on detecting edges between uniform areas, so it is very important to represent them sharp, not blurry.

This demo presents texture filtering method designed to address this issue.

First, on preprocessing stage, for each four adjacent texels is determined, whether some of them are belong to the same uniform area. It could be done easily just by comparing their color difference to some threshold. There are 14 different cases possible:

14 types
For each case we will use the separate filter.

Case 0: all four texels are belong to the same area, so for this inter-texel interval it makes sense to use bilinear filter.

Case 1: two top texels are belong to one area, and two bottom ones - to another. The color of the field above horizontal border calculated as linear interpolation between colors of two top texels, below border - as linear interpolation of two bottom texels. Filters for other cases defined in a similar way.

The filter number for each inter-texel interval is stored along with the texture - it will take additional 4 bits for each texel. At the rendering stage, by reading this filter number, it is possible to use correct specific filter for each inter-texel interval.

So using this technique, it is possible to represent the borders between uniform areas as sharp regardless of magnification level. At the same time, by using bilinear filter inside uniform areas, we achieve desired smoothness here.

This particular demo uses a little more complicated technique - 4 additional bits per texel helps to describe position of the border in each inter-texel interval more precise. So texture is stored as 32-bit TGA file, with 24 bits for color and 8 bits for filter description. All rendering implemented completely in software, and performance hit for this "smart" texture filtering method is only about 10% comparing to software bilinear filtering. The reason of such good performance is simple - for typical texture image, the number of "border" texels is much less then number of "inside" texels.

The current hardware does not support this texture filtering technique, but in the future, more advanced versions of programmable pixel shaders could make the hardware implementation possible.




Copyright (c) 2001, 2002 Maxim Stepin