SearchTex

SearchTex.png (x10)


边界样式

# This dict returns which edges are active for a certain bilinear fetch:
# (it's the reverse lookup of the bilinear function)
edge = {bilinear([0, 0, 0, 0]): [0, 0, 0, 0],bilinear([0, 0, 0, 1]): [0, 0, 0, 1],bilinear([0, 0, 1, 0]): [0, 0, 1, 0],bilinear([0, 0, 1, 1]): [0, 0, 1, 1],bilinear([0, 1, 0, 0]): [0, 1, 0, 0],bilinear([0, 1, 0, 1]): [0, 1, 0, 1],bilinear([0, 1, 1, 0]): [0, 1, 1, 0],bilinear([0, 1, 1, 1]): [0, 1, 1, 1],bilinear([1, 0, 0, 0]): [1, 0, 0, 0],bilinear([1, 0, 0, 1]): [1, 0, 0, 1],bilinear([1, 0, 1, 0]): [1, 0, 1, 0],bilinear([1, 0, 1, 1]): [1, 0, 1, 1],bilinear([1, 1, 0, 0]): [1, 1, 0, 0],bilinear([1, 1, 0, 1]): [1, 1, 0, 1],bilinear([1, 1, 1, 0]): [1, 1, 1, 0],bilinear([1, 1, 1, 1]): [1, 1, 1, 1],
}

SMAA采用双线性采样加快搜索速度,一次采样可获取4个像素的边界信息。
以左边界为例,存在16种边界样式:

采样偏移值(-0.25, -0.125),如图所示,

采样结果 :
0/32, 21/32, 7/32, 28/32, 
3/32, 24/32, 10/32, 31/32, 
1/32, 22/32, 8/32, 29/32, 
4/32, 25/32, 11/32, 32/32,
每一个值都代表了一种边界样式


纹理大小

为了使用纹理坐标表示上面的16个值,则需要33个像素 [0 - 32]。
同理,上边界需要33个像素,分左右搜索,纹理大小为 66 x 33。

无上下搜索值。上下搜索时,只需要把 x,y 调换,上下就变成了左右。纹理大小就减少一半。

为什么最终的纹理大小为 64 * 16 ?

原始纹理如下:66 x 33

观察原始纹理,存在大部分为 0(黑色)的部分。直接裁掉这些为0的部分,并将其大小变为2次幂。

# Crop it to power-of-two to make it BC4-friendly:
# (Cropped area and borders are black)
image = image.crop([0, 17, 64, 33])

裁剪后纹理,如下

纹理被裁剪了,现纹理与原纹理的UV对应产生了变化。
现纹理与原纹理的对应关系
x : [0 - 66/64] => [0 - 1]
y : [0 - 2] => [0 - 1]
现纹理均有一部分超过了1,超过1的部分认为是被剪裁的值为 0 的部分。
超过的部分没有被保存,但是需要在计算时还原。
在x分量上,x = 1 的部分值为0(最右边一列),只要将纹理采样的 WarpMode 设置为 Clamp,超过1的部分采样后的值即为0。
在y分量上,y = 1 的部分不均为 0 (最下边一行),但是 y = 0 的部分均为0(最上边一行)。

为了与x分量采用相同的优化方式,只需将纹理在y分量上翻转。

image = image.transpose(Image.FLIP_TOP_BOTTOM)

这样就得到了最终的 64*16 的纹理。


纹理颜色

# Delta distance to add in the last step of searches to the left:
def deltaLeft(left, top):d = 0# If there is an edge, continue:if top[3] == 1:d += 1# If we previously found an edge, there is another edge and no crossing# edges, continue:if d == 1 and top[2] == 1 and left[1] != 1 and left[3] != 1:d += 1return d# Delta distance to add in the last step of searches to the right:
def deltaRight(left, top):d = 0# If there is an edge, and no crossing edges, continue:if top[3] == 1 and left[1] != 1 and left[3] != 1:d += 1# If we previously found an edge, there is another edge and no crossing# edges, continue:if d == 1 and top[2] == 1 and left[0] != 1 and left[2] != 1:d += 1return d

从算法可以得出:
纹理中的值只有 0, 1, 2。
但是 0,1,2 三个值非常接近,采样时容易产生误差。
将其变为 0, 127, 254,以此去掉误差,也有助于人眼分辨。
因此,纹理中的颜色为 0, 127, 254

至于以上算法如何得出的,查看SMAA算法详解-SMAASearchXLeft(Right)


SMAA算法详解 - SearchTex相关推荐

  1. SMAA算法详解 - SMAANeighborhoodBlendingPS

    目录 - SMAA代码详解 SMAANeighborhoodBlendingPS //--------------------------------------------------------- ...

  2. SMAA算法详解 - SMAALumaEdgeDetectionPS

    目录 - SMAA代码详解 SMAALumaEdgeDetectionPS /*** Luma Edge Detection** IMPORTANT NOTICE: luma edge detecti ...

  3. SMAA算法详解 - SMAANeighborhoodBlendingVS

    目录 - SMAA代码详解 SMAANeighborhoodBlendingVS /*** Neighborhood Blending Vertex Shader*/ void SMAANeighbo ...

  4. SMAA算法详解 - SMAASearchYUp(Down)

    SMAASearchYUp(Down) SMAASearchYUp 与 SMAASearchXLeft大致相同. 不同点: 在Y方向上偏移2. SearchTex采样时,e.rg 改为 e.gr. S ...

  5. SMAA算法详解 - AreaTex

    AreaTex 以下均在无SubPixel的情况下,即offset = (0,0).subpixel将单独讲解. areaortho.area # Calculates the area under ...

  6. SMAA算法详解 - SMAABlendingWeightCalculationVS

    SMAABlendingWeightCalculationVS /*** Blend Weight Calculation Vertex Shader*/ void SMAABlendingWeigh ...

  7. SMAA算法详解 - SMAADetectHorizontalCornerPattern

    SMAADetectHorizontalCornerPattern 修正水平转角 //--------------------------------------------------------- ...

  8. SMAA算法详解 - SMAAEdgeDetectionVS

    SMAAEdgeDetectionVS ​计算从当前像素点到目标像素点的偏移值. /*** Edge Detection Vertex Shader*/ void SMAAEdgeDetectionV ...

  9. SMAA算法详解 - SMAADetectVerticalCornerPattern

    SMAADetectVerticalCornerPattern void SMAADetectVerticalCornerPattern(SMAATexture2D(edgesTex), inout ...

最新文章

  1. get_magic_quotes_gpc异常
  2. centos7下docker 部署javaweb
  3. PSO求解梯级水库优化调度
  4. python 实现倒排索引,建立简单的搜索引擎
  5. 30岁转行测试工程师_30岁一无所长,转行UI设计还合适吗?
  6. nagios学习笔记(一)
  7. [Python图像处理] 十二.图像几何变换之图像仿射变换、图像透视变换和图像校正
  8. 【壹刊】Azure AD(二)调用受Microsoft 标识平台保护的 ASP.NET Core Web API (上)
  9. 【转】JVM 架构解读
  10. Tensorflow相关面试题
  11. 计算机网络实验_专业介绍篇 | 计算机网络技术专业
  12. java类、抽象类、接口的继承规则
  13. HTML5 History API让ajax能回退到上一页
  14. ubuntu虚拟机启动失败黑屏解决方案及原因
  15. 10计算机语言代表什么,win10是什么编程语言写的_win10史诗般的巨型编程项目
  16. 附件携马之CS免杀shellcode过国内主流杀软
  17. 计算机中sqrt函数是什么意思,(excle sqrt)excel中的SQRT是什么意思?
  18. 联想手机吹响反攻号角,“诺曼底计划”未来要剑指何方?
  19. 如何进行一篇论文的阅读
  20. 华为鸿蒙研究团队,喜报!!衡水高中毕业生丁聪百万年薪入职华为鸿蒙研发团队...

热门文章

  1. [VOT14](2022CVPR)CSWinTT: Transformer Tracking with Cyclic Shifting Window Attention
  2. 红米K40游戏 红米Note10Pro等出现dm-verity corruption your device is corrupt 设备在5秒内关机 无限重启 怎么解决
  3. 【推荐系统】:Deep Crossing模型解析以及代码实现
  4. linux读取class下的文件路径,Class类getResource方法获取文件路径
  5. Unity 激活许可证的时候出现 serial has reached the maximum number of activations提示
  6. 浅析GPU通信技术(上)-GPUDirect P2P
  7. 马克思 第一章 世界的物质性及其发展规律
  8. MAC去掉更新小红点
  9. c++“不允许使用不完整的类型“
  10. error An unexpected error occurred: “https://registry.npmjs.org/react: ETIMEDOUT“.