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. 服务器架设笔记——打通MySQL和Apache
  2. 使用IDEA新建springboot工程
  3. ASP用DSN连接数sql数据库
  4. PowerDesigner16中的对象无效,不允许有扩展属性 问题的解决
  5. Linux中使用Msmtp+mutt+shell自动发邮件程序安装说明
  6. iOS中都有什么设计模式?各个设计模式的作用 (转载)
  7. Ubuntu的奇技淫巧
  8. 用javascript写Android和iOS naitve应用,实在炫酷。
  9. JPA getValidationMode()
  10. Linux:为什么那么多人讨厌systemd?
  11. 最大权闭合子图(poj 2987 Firing)
  12. 简述vue-router实现原理
  13. python bottle 终止返回_关于python的bottle框架跨域请求报错问题的处理
  14. QML 环形进度条canvas 98行代码实现
  15. 地理空间坐标系统-城市坐标系与国家统一坐标系之间的转换(含四参数转换代码)
  16. 闲聊企业数字化转型(1)-供应链数字化
  17. 立秋是中稻收割的日子
  18. mysql怎么给root设密码_mysql给root设置密码
  19. 北京工作居住证的申请条件和可享受的待遇
  20. FS2712A单片机可替换松翰SN8P2711

热门文章

  1. 关于智能家居,一篇绝对中立的详细指南及各类问题解答
  2. App Store2016年最新审核规则
  3. 山东大学项目实训——地图圈系统——微信小程序(18)
  4. 数据结构:弗洛伊德算法(最短路径)图文详解
  5. 惠普战66键盘win10亮度调节快捷键失灵的解决办法
  6. Android游戏开发教程------(绘制屏幕)
  7. 领淘宝优惠券的微信小程序
  8. 职业选手图解教你如何DIY装机
  9. 南陵中学2021高考成绩查询,南陵中学举行2021届高三距高考200天动员大会
  10. Frame-Pannel-Button综合