http://www.extremetech.com/computing/51994-the-naked-truth-about-anisotropic-filtering

1、 为什么在纹理采样时需要texture filter(纹理过滤)。

我们的纹理是要贴到三维图形表面的,而三维图形上的pixel中心和纹理上的texel中心并不一至(pixel不一定对应texture上的采样中心texel),大小也不一定一至。当纹理大于三维图形表面时,导至一个像素被映射到许多纹理像素上;当维理小于三维图形表面时,许多个象素都映射到同一纹理。

当这些情况发生时,贴图就会变得模糊或发生错位,马赛克。要解决此类问题,必须通过技术平滑texel和pixel之间的对应。这种技术就是纹理滤波。

不同的过滤模式,计算复杂度不一样,会得到不同的效果。过滤模式由简单到复杂包括:Nearest Point Sampling(最近点采样),Bilinear(双线性过滤)、Trilinear(三线性过滤)、Anisotropic Filtering(各向异性过滤)。

在了解这些之前,有必要了解什么是MipMap和什么时各向同性,各向异性。

2、 什么是MipMap?

Mipmap由Lance Williams 在1983的一篇文章“Pyramidal parametrics”中提出。Wiki中有很详细的介绍( http://en.wikipedia.org/wiki/Mipmap ) . 比如一张256X256的图,在长和宽方向每次减少一倍,生成:128X128,64X64,32X32,16X16,8X8,4X4,2X2,1X1,八张图,组成MipMap,如下图示。

Mipmap早已被硬件支持,硬件会自动为创建的Texture生成mipmap的各级。在D3D的API:CreateTexture中有一个参数levels,就是用于指定生成mipmap到哪个级别,当不指定时就一直生成到1X1。

3、 什么是各向同性和各向异性?

当需要贴图的三维表面平行于屏幕(viewport),则是各向同性的。当要贴图的三维表面与屏幕有一定角度的倾斜,则是各向异性的。

也可以这样理解,当一个texture贴到三维表面上从Camera看来没有变形,投射到屏幕空间中后U方向和V方向比例仍然是一样的,便可以理解成各向同性。反之则认为是各向异性。

4、 Nearest Point Sampling(最近点采样)

这个最简单,每个像素的纹理坐标,并不是刚好对应Texture上的一个采样点texel,怎么办呢?最近点采样取最接近的texel进行采样。

当纹理的大小与贴图的三维图形的大小差不多时,这种方法非常有效和快捷。如果大小不同,纹理就需要进行放大或缩小,这样,结果就会变得矮胖、变形或模糊。

5、 Bilinear(双线性过滤)

双线性过滤以pixel对应的纹理坐标为中心,采该纹理坐标周围4个texel的像素,再取平均,以平均值作为采样值。

双线性过滤像素之间的过渡更加平滑,但是它只作用于一个MipMap Level,它选取texel和pixel之间大小最接近的那一层MipMap进行采样。当和pixel大小匹配的texel大小在两层Mipmap level之间时,双线性过滤在有些情况效果就不太好。于是就有了三线性过滤。

6、 Trilinear(三线性过滤)

三线性过滤以双线性过滤为基础。会对pixel大小与texel大小最接近的两层Mipmap level分别进行双线性过滤,然后再对两层得到的结果进生线性插值。

三线性过滤在一般情况下效果非常理想了。但是到目前为止,我们均是假设是texture投射到屏幕空间是各向同性的。但是当各向异性的情况时,效果仍然不理想,于是产生了Anisotropic Filtering(各向异性过滤)。

7、 Anisotropic Filtering(各向异性过滤)

先看效果,左边的图采用三线性过滤,右边的图采用各向异性过滤。

各向同性的过滤在采样的时候,是对正方形区域里行采样。各向异性过滤把纹理与屏幕空间的角度这个因素考虑时去。简单地说,它会考滤一个pixel(x:y=1:1)对应到纹理空间中在u和v方向上u和v的比例关系,当u:v不是1:1时,将会按比例在各方向上采样不同数量的点来计算最终的结果(这时采样就有可能是长方形区域)。

我们一般指的Anisotropic Filtering(AF)均是基于三线过滤的Anisotropic Filtering,因此当u:v不为1:1时,则Anisotropic Filtering比Trilinear需要采样更多的点,具体要采多少,取决于是多少X的AF,现在的显卡最多技持到16X AF。

当开启16X AF的时候,硬件并不是对所有的texture采样都用16X AF,而是需要先计算屏幕空间与纹理空间的夹角(量化后便是上面所说的u:v),只有当夹角大到需要16X时,才会真正使用16X.

如果想了解AF的实现原理,可以查阅此篇Paper: “Implementing an anisotropic texture filter”. 现在AF都是硬件实现,因此只有少数人才清楚AF就尽是怎样实现了(其实细节我也没搞清楚),其实完全可以由Pixel Shader来实现AF,当然性能和由硬件做是没得比的。

8、 各过滤模式性能比较。

下表是各种过滤模式采一个pixel需要sample的次数:

Sample Number

Nearest Point Sampling

1

Bilinear

4

Trilinear

8

Anisotropic Filtering 4X

32

Anisotropic Filtering 16X

128

Anisotropic Filtering 16X效果最好,但是显卡Performance会下降很多,当然也是测试你手中显卡Texture Unit的好方法。如果你觉得你的显卡够牛,那么就把AA和AF都打到最高再试试吧:)

In 3D computer graphics, anisotropic filtering (abbreviated AF) is a method of enhancing the image quality of textures on surfaces of computer graphics that are atoblique viewing angles with respect to the camera where the projection of the texture (not the polygon or other primitive on which it is rendered) appears to be non-orthogonal (thus the origin of the word: "an" for not, "iso" for same, and "tropic" from tropism, relating to direction; anisotropic filtering does not filter the same in every direction).

Like bilinear and trilinear filtering, anisotropic filtering eliminates aliasing effects, but improves on these other techniques by reducing blur and preserving detail at extreme viewing angles.

Anisotropic compression is relatively intensive (primarily memory bandwidth and to some degree computationally, though the standard space-time tradeoff rules apply) and only became a standard feature of consumer-level graphics cards in the late 1990s. Anisotropic filtering is now common in modern graphics hardware (and video driver software) and is enabled either by users through driver settings or by graphics applications and video games through programming interfaces.

Contents

[hide]

  • 1 An improvement on isotropic MIP mapping
  • 2 Degree of anisotropy supported
  • 3 Implementation
  • 4 Performance and optimization
  • 5 See also
  • 6 References
  • 7 External links

An improvement on isotropic MIP mapping[edit]

An example of anisotropic mipmap image storage: the principal image on the top left is accompanied by filtered, linearly transformed copies of reduced size. (click to compare to previous, isotropic mipmaps of the same image)

From this point forth, it is assumed the reader is familiar with MIP mapping.

If we were to explore a more approximate anisotropic algorithm, RIP mapping, as an extension from MIP mapping, we can understand how anisotropic filtering gains so much texture mapping quality. If we need to texture a horizontal plane which is at an oblique angle to the camera, traditional MIP map minification would give us insufficient horizontal resolution due to the reduction of image frequency in the vertical axis. This is because in MIP mapping each MIP level is isotropic, so a 256 × 256 texture is downsized to a 128 × 128 image, then a 64 × 64 image and so on, so resolution halves on each axis simultaneously, so a MIP map texture probe to an image will always sample an image that is of equal frequency in each axis. Thus, when sampling to avoid aliasing on a high-frequency axis, the other texture axes will be similarly downsampled and therefore potentially blurred.

With RIP map anisotropic filtering, in addition to downsampling to 128 × 128, images are also sampled to 256 × 128 and 32 × 128 etc. These anisotropically downsampled images can be probed when the texture-mapped image frequency is different for each texture axis. Therefore, one axis need not blur due to the screen frequency of another axis, and aliasing is still avoided. Unlike more general anisotropic filtering, the RIP mapping described for illustration is limited by only supporting anisotropic probes that are axis-aligned in texture space, so diagonal anisotropy still presents a problem, even though real-use cases of anisotropic texture commonly have such screenspace mappings.

In layman's terms, anisotropic filtering retains the "sharpness" of a texture normally lost by MIP map texture's attempts to avoid aliasing. Anisotropic filtering can therefore be said to maintain crisp texture detail at all viewing orientations while providing fast anti-aliased texture filtering.

Degree of anisotropy supported[edit]

Different degrees or ratios of anisotropic filtering can be applied during rendering and current hardware rendering implementations set an upper bound on this ratio. This degree refers to the maximum ratio of anisotropy supported by the filtering process. So, for example 4:1 (pronounced “4-to-1”) anisotropic filtering will continue to sharpen more oblique textures beyond the range sharpened by 2:1.

In practice what this means is that in highly oblique texturing situations a 4:1 filter will be twice as sharp as a 2:1 filter (it will display frequencies double that of the 2:1 filter). However, most of the scene will not require the 4:1 filter; only the more oblique and usually more distant pixels will require the sharper filtering. This means that as the degree of anisotropic filtering continues to double there are diminishing returns in terms of visible quality with fewer and fewer rendered pixels affected, and the results become less obvious to the viewer.

When one compares the rendered results of an 8:1 anisotropically filtered scene to a 16:1 filtered scene, only a relatively few highly oblique pixels, mostly on more distant geometry, will display visibly sharper textures in the scene with the higher degree of anisotropic filtering, and the frequency information on these few 16:1 filtered pixels will only be double that of the 8:1 filter. The performance penalty also diminishes because fewer pixels require the data fetches of greater anisotropy.

In the end it is the additional hardware complexity vs. these diminishing returns, which causes an upper bound to be set on the anisotropic quality in a hardware design. Applications and users are then free to adjust this trade-off through driver and software settings up to this threshold.

Implementation[edit]

True anisotropic filtering probes the texture anisotropically on the fly on a per-pixel basis for any orientation of anisotropy.

In graphics hardware, typically when the texture is sampled anisotropically, several probes (texel samples) of the texture around the center point are taken, but on a sample pattern mapped according to the projected shape of the texture at that pixel.

Each anisotropic filtering probe is often in itself a filtered MIP map sample, which adds more sampling to the process. Sixteen trilinear anisotropic samples might require 128 samples from the stored texture, as trilinear MIP map filtering needs to take four samples times two MIP levels and then anisotropic sampling (at 16-tap) needs to take sixteen of these trilinear filtered probes.

However, this level of filtering complexity is not required all the time. There are commonly available methods to reduce the amount of work the video rendering hardware must do.

The anisotropic filtering method most commonly implemented on graphics hardware is the composition of the filtered pixel values from only one line of MIP map samples, which is referred to as "footprint assembly".[1][2]

Performance and optimization[edit]

The sample count required can make anisotropic filtering extremely bandwidth-intensive. Multiple textures are common; each texture sample could be four bytes or more, so each anisotropic pixel could require 512 bytes from texture memory, although texture compression is commonly used to reduce this.

A video display device can easily contain over two million pixels, and desired application framerates are often upwards of 30 frames per second. As a result, the required texture memory bandwidth may grow to large values. Ranges of hundreds of gigabytes per second of pipeline bandwidth for texture rendering operations is not unusual where anisotropic filtering operations are involved.[citation needed]

Fortunately, several factors mitigate in favor of better performance:

  • The probes themselves share cached texture samples, both inter-pixel and intra-pixel.
  • Even with 16-tap anisotropic filtering, not all 16 taps are always needed because only distant highly oblique pixel fills tend to be highly anisotropic.
  • Highly Anisotropic pixel fill tends to cover small regions of the screen (i.e. generally under 10%)
  • Texture magnification filters (as a general rule) require no anisotropic filtering.

转载于:https://www.cnblogs.com/kylegui/p/3855710.html

anisotropy texture filtering相关推荐

  1. Texture Filtering

    Texture Filtering 在纹理映射时,需要进行Filter,原因在于: 观察者在不同视角.与object不同距离的情况下,进行纹理映射时,屏幕上的一个像素未必对应于纹理图像上的一个像素. ...

  2. 初识OpenGL (-)纹理过滤(Texture Filtering)

    1. OpenGL需要知道怎样将纹理像素(Texture Pixel,也叫Texel)映射到纹理坐标. 纹理坐标 不依赖于分辨率(Resolution),它可以是任意浮点值, 给模型顶点设置的那个数组 ...

  3. qnetworkreply 获取状态_谈谈Unity Shader中的采样器状态和(Texture Filtering)纹理滤波方式

    参考文章: 使用采样器状态 - Unity 手册​docs.unity3d.comhttps://blog.csdn.net/chenjinxian_3D/article/details/518169 ...

  4. OpenGL之纹理过滤(Texture Filtering)、MipMap方法、纹理坐标

    1.1 纹理过滤 像素.片元都是具有面积的,一个像素可能对应物体上的一小块区域,而物体上这个小区域对应于纹理图像上的一个小区域,因此一个像素的颜色可能来自于纹理中的一小个不规则区域,如果纹理的分辨率比 ...

  5. 关于Texture Cache简单总结

    Texture Cache是一个存储图片数据的只读cache 按照正常uv顺序读贴图tex cache有高命中率 Texture Cache在 shader processor附近,所以它有高吞吐率, ...

  6. HLSL Texture Object Sample 的一些笔记

    Practical Rendering And Computation With D3D11 书上的解释 "The Sample method allows for hardware tex ...

  7. 纹理 Texture

    [Toc] 1. 纹理的理论 纹理是一个2D图片(甚至也有1D和3D的纹理),它可以用来添加物体的细节:可以想象纹理是一张绘有砖块的纸,无缝折叠贴合到你的3D的房子上,这样你的房子看起来就像有砖墙外表 ...

  8. unity.生成表示地图信息的二维数组_Unity3D 中生成任意形状3D Texture amp; 体积云...

    3d 贴图一般在 Houdini等软件生成,毕竟需要其他软件支持,导入导出预览效率和制作效率都不高 (Houdini也不便宜....别问就是穷...) Unity中只见到过一些3D噪音图的生成,本文提 ...

  9. C for Graphic:各向异性(anisotropy)

    最近做一个效果涉及到各向异性着色,顺便记录一下. 各向异性,如果刚听过这个词的人,可能觉得绕口难懂,它的英文名:Anisotropy.它是各同向性(Isotropy)的反义词,各向同性这个词在第一次接 ...

  10. OpenGL Texture 纹理

    Texture 纹理 纹理是一个2D图片(也可以是一个1D和3D的纹理) 效果如下(https://github.com/curtain521517/learnOpenGL) 为了能够映射到三角形上, ...

最新文章

  1. Python,OpenCV使用KNN来构建手写数字及字母识别OCR
  2. ASP.NET Core [1]:Hosting(笔记)
  3. 【C 语言】二级指针作为输出 ( 指针输入 | 指针输出 | 二级指针 作为 函数形参 使用示例 )
  4. 中国新十大军工企业名单及简称
  5. Gradle修改本地仓库的位置
  6. 一段代码看出JS的的解析到执行的顺序规则
  7. windows10和ubuntu双系统win10时间不正确
  8. hibernate annotation注解方式来处理映射关系
  9. 敏捷开发 看板_什么是看板? 定义的敏捷方法论,以及如何将其用于您的软件开发团队
  10. python for mac下载_Python for Mac
  11. SQLServer数据库写操作报错String or binary data would be truncated问题解决
  12. 可以检测手机帧率和温度的软件_腾讯黑鲨游戏手机3评测:深度定制带来的全新游戏体验...
  13. Tilera平台使用体会
  14. i5 1340p和r7 7735h差距 酷睿i51340p和锐龙r77735h对比
  15. 惠普打印机故障代码_HP打印机故障代码
  16. 浅谈卡尔曼滤波(Kalman Filter)(一)
  17. 恒定帧率30帧以上录制掉帧问题分析
  18. 飞书面临3个劣势,那又怎样?
  19. codeforce B. Cutting Carrot
  20. 自用 学习BCR 免疫组化

热门文章

  1. 计算机程序手工编织,丝绸编程秒杀计算机 《锦绣纪》致敬最强大脑
  2. 帕斯卡恒等式(二项式相关
  3. 闵华 oracle,Oracle 数据库上机试验指导1(答案).doc
  4. dingo php,laravel 中安装 Dingo API 基本设置
  5. Log4j发送日志到服务器上
  6. UVA - 12304(B - 2D Geometry 110 in 1!)计算几何板子
  7. [Asp.net Core]局部视图
  8. STM32:SPI驱动ADXL345
  9. lamp技术_LAMP技术简介:
  10. mysql 密码复杂度要求_MySQL设置密码复杂度