紋理篩選Texture filtering

原始物件透過將 3D 原始物件對應到 2D 畫面上進行轉譯時,紋理篩選會為原始物件的 2D 轉譯影像中的每個像素產生色彩。Texture filtering produces a color for each pixel in the primitive's 2D rendered image when a primitive is rendered by mapping a 3D primitive onto a 2D screen.

當 Direct3D 轉譯原始物件時,會將 3D 原始物件對應到 2D 畫面上。When Direct3D renders a primitive, it maps the 3D primitive onto a 2D screen. 若原始物件帶有紋理,Direct3D 必須使用該紋理為原始物件的 2D 轉譯影像中的每個像素產生色彩。If the primitive has a texture, Direct3D must use that texture to produce a color for each pixel in the primitive's 2D rendered image. 針對畫面上原始物件影像的每個像素,程式必須從紋理中取得色彩值。For every pixel in the primitive's on-screen image, it must obtain a color value from the texture. 這個過程稱為 「紋理篩選」This process is called texture filtering.

執行紋理篩選作業時,通常也會放大或縮小使用的紋理。When a texture filter operation is performed, the texture being used is typically also being magnified or minified. 換句話說,其會對應到比自身大或小的原始影像。In other words, it is being mapped into a primitive image that is larger or smaller than itself. 放大紋理可能會導致許多像素對應到一個材質。Magnification of a texture can result in many pixels being mapped to one texel. 其結果可能為外觀粗短。The result can be a chunky appearance. 縮小紋理通常表示一個像素會對應到許多材質。Minification of a texture often means that a single pixel is mapped to many texels. 其結果影像可能會顯得模糊或帶有鋸齒。The resulting image can be blurry or aliased. 若要解決這些問題,您必須對材質色彩稍作混合,以達到像素的色彩。To resolve these problems, some blending of the texel colors must be performed to arrive at a color for the pixel.

Direct3D 將複雜的紋理篩選過程予以簡化。Direct3D simplifies the complex process of texture filtering. Direct3D 提供您三種紋理篩選的類型:線性篩選、非等向性篩選,及 Mipmap 篩選。It provides you with three types of texture filtering - linear filtering, anisotropic filtering, and mipmap filtering. 如果您並未選擇任何紋理篩選方式,Direct3D 會使用一種稱作「最近點取樣」的技術。If you select no texture filtering, Direct3D uses a technique called nearest-point sampling.

每一種紋理篩選都有優點和缺點。Each type of texture filtering has advantages and disadvantages. 例如:線性紋理篩選可能會使最終影像產生鋸齒狀的邊緣,或是矮胖的外觀。For instance, linear texture filtering can produce jagged edges or a chunky appearance in the final image. 然而,其為運算上低負荷的一種紋理篩選方法。However, it is a computationally low-overhead method of texture filtering. 使用 Mipmap 進行紋理篩選通常會產生最好的結果,特別是與非等向性篩選搭配使用時。Filtering with mipmaps usually produces the best results, especially when combined with anisotropic filtering. 然而,其在 Direct3D 支援的技術中是最消耗記憶體的一種。However, it requires the most memory of the techniques that Direct3D supports.

類型的紋理篩選Types of texture filtering

Direct3D 支援以下紋理篩選方法。Direct3D supports the following texture filtering approaches.

本節內容In this section

主題Topic 描述Description

最接近點取樣Nearest-point sampling

使用紋理篩選不需要應用程式。Applications are not required to use texture filtering. 可設定 Direct3D 讓它計算紋素位址,其通常不評估整數,並以最接近的整數位址複製紋素色彩。Direct3D can be set so that it computes the texel address, which often does not evaluate to integers, and copies the color of the texel with the closest integer address. 這個過程稱作最近點取樣This process is called nearest-point sampling.

雙線性紋理篩選Bilinear texture filtering

「線性篩選」會計算最接近取樣點的 4 項材質之加權平均值。Bilinear filtering calculates the weighted average of the 4 texels closest to the sampling point. 此篩選的方式比最近點篩選更準確和常見。This filtering approach is more accurate and common than nearest-point filtering. 因為這種方式在現代化圖形硬體內實作,所以很有效率。This approach is efficient because it is implemented in modern graphics hardware.

非等向性紋理篩選Anisotropic texture filtering

非等向性是材質中可見的失真,屬於角度以螢幕平面為方向的 3D 物件表面。Anisotropy is the distortion visible in the texels of a 3D object whose surface is oriented at an angle with respect to the plane of the screen. 當非等向性原始物件的像素對應至材質時,其形狀會失真。When a pixel from an anisotropic primitive is mapped to texels, its shape is distorted.

篩選具有 mipmap 的材質Texture filtering with mipmaps

Mipmap 是一組紋理序列,序列中的每個影像都是相同影像漸進式降低解析度的結果。A mipmap is a sequence of textures, each of which is a progressively lower resolution representation of the same image. 每個影像的高度、寬度,或是層級,都是前一層級以 2 的乘冪縮小的結果。The height and width of each image, or level, in the mipmap is a power-of-two smaller than the previous level.

 

相關主題Related topics

紋理Textures