Bilateral Filter
来源:互联网 发布:2kol球员数据更新2017 编辑:程序博客网 时间:2024/05/17 21:05
Bilateral Filter是一个非常神奇的Filter,在实时渲染从低分辨向高分辨率转换的时候可以起到很好的抑制锯齿的作用。
1. AMD Way
Jeremy在Mixed Resolution中有详细的讲到:一般的Filter是根据像素和周围像素的距离作为权重来插值的,而Jemery采用的是高精度和低精度depth或者normal的差异来计算权重,在游戏里depth很容易拿到,所以一般就采用depth差异来决定权重,这样需要得到高精度深度和4个低精度深度和颜色值,一共是9个sample,而且这是一个全屏pass,因此最原始的Bilateral Filter是一个很费的操作,对于实时图形渲染尤其是尤其还是很奢侈的操作。
Linear Filter
Bilateral Filter
2.NV Way
NV SDK 11有一个OpacityMapping的demo讲的是Volume Particle及其Shadow,里面正好展示了Bilateral Filter,这里的Filter是经过优化的,从最终结果来看,效果还是很不错的。在这个demo把这个技术称之为Nearest-Depth Filter,它的原理和Cross Bilateral Filter类似,区别在于只需要采一次颜色值,这个颜色值不是周围像素加权平均的结果而是和高精度深度差异最小的低精度像素的颜色值,这就减少了3次Sample.
采用Nearest-Depth Filter会带来一个问题:因为只采用了低精度的颜色值可能会在非边缘区域噪声像素块比较明显的瑕疵。因此对于edge的像素采用Nearest-Depth Filter,而对于非edge的像素采用双向性插值。Edge可以通过低精度和高精度深度差异来检测,我们可以认为如果一个像素附近的所有低精度深度和对应的高精度深度的差异小于一定阈值时这个像素一定是非edge像素。可以理解为自适应的Bilateral Filter.
Nearest-Depth Filter Shader代码
float4 LowResUpsample_PS(VS_SAQ_OUTPUT In) : SV_Target{uint w, h;g_ReducedResDepth.GetDimensions(w,h);float2 LowResTexelSize = 1.f/float2(w,h);g_FullResDepth.GetDimensions(w, h);// This corrects for cases where the hi-res texture doesn't correspond to 100% of the low-res// texture (e.g. 1023x1023 vs 512x512)float2 LoResUV = g_ReductionFactor * LowResTexelSize * float2(w,h) * In.TexCoord;float ZFull = FetchFullResDepth(In.Position.xy);float MinDist = 1.e8f;float4 ZLo = FetchLowResDepths(LoResUV);float2 UV00 = LoResUV - 0.5 * LowResTexelSize;float2 NearestUV = UV00;float Z00 = ZLo.w;UpdateNearestSample(MinDist, NearestUV, Z00, UV00, ZFull);float2 UV10 = float2(UV00.x+LowResTexelSize.x, UV00.y);float Z10 = ZLo.z;UpdateNearestSample(MinDist, NearestUV, Z10, UV10, ZFull);float2 UV01 = float2(UV00.x, UV00.y+LowResTexelSize.y);float Z01 = ZLo.x;UpdateNearestSample(MinDist, NearestUV, Z01, UV01, ZFull);float2 UV11 = UV00 + LowResTexelSize;float Z11 = ZLo.y;UpdateNearestSample(MinDist, NearestUV, Z11, UV11, ZFull);[branch]if (abs(Z00 - ZFull) < g_DepthThreshold && abs(Z10 - ZFull) < g_DepthThreshold && abs(Z01 - ZFull) < g_DepthThreshold && abs(Z11 - ZFull) < g_DepthThreshold){return g_ScreenAlignedQuadSrc.SampleLevel(g_SamplerLoResBilinear, LoResUV, g_ScreenAlignedQuadMip);}else{return g_ScreenAlignedQuadSrc.SampleLevel(g_SamplerLoResNearest, NearestUV, g_ScreenAlignedQuadMip);}}
3. Splint Cell 5 Way
- bilateral filter
- Bilateral filter
- Bilateral Filter
- bilateral filter
- bilateral filter
- bilateral filter
- Bilateral Filter、Cross/Joint Bilateral Filter
- bilateral filter using opencv
- opencv bilateral filter vs matlab bilateral filter 双边滤波
- 双边滤波器(Bilateral Filter)
- 双边滤波(Bilateral filter)
- 双边滤波(Bilateral filter)
- 双边滤波Matlab实现<The Bilateral Filter>
- 双边滤波(Bilateral Filter)详解
- Bilateral Filter:一种保边平滑滤波器
- Bilateral Filter:保护边缘的平滑滤波器
- Bilateral Filter:保护边缘的平滑滤波器
- 双边滤波Matlab实现<The Bilateral Filter>
- Ajax 异步请求的基本步骤
- poll函数
- cocos2dx使用TiledMap创建斜45度地图场景
- 【数据结构】单向链表
- SET命令用法详解
- Bilateral Filter
- Map与Hash
- discuz x3.1实现QQ登录
- 菜鸟Android学习31——图片预览窗口
- 文件系统相关文章地址
- 索引器
- Storm安装
- Hadoop源码分析之NameNode的启动与停止
- B+ Tree 与 B- Tree