Shader 学习笔记 ---Looking Through a Filter 过滤器

来源:互联网 发布:软件限制策略怎么打开 编辑:程序博客网 时间:2024/05/28 15:25

    Expanding a dot product operation to its final equation

    简单的点积计算颜色混合

  

 

     Decomposition of a matrix multiplication into a set of dot product operations.

     多个点积计算,矩阵计算

    

 

    这部分感觉理解起来很简单,但是颜色混合那些数值的来历就要以后慢慢研究了。

 

   Blurring Things Up

 

  

 

 边缘化

 An edge detection filter highlights the edges of an image. The edges are defined as sharp
color transitions between pixels. An edge detection filter serves little purpose in most
applications beyond teaching you about different filters but will come in handy later on
when you’re rendering silhouettes.

 

边缘化会探测出图像的边缘,并使它的像素有一个急剧的颜色突变。在绘制阴影时有很大作用。

 

动态模糊

A motion blur screen effect can serve one of two purposes. The first is the obvious: a simple emulation
of the real-life motion blur effect. The second is that when the effect is applied slightly to a
scene, it can cancel out aliasing effects that can occur in your rendering, effectively serving as an
inexpensive alternative when you do not have hardware antialiasing.

 

有两个作用,一个当然就是模拟现实中的动态模糊现象,第二个就是消除渲染中的锯齿现象, 当图形硬件不支持抗锯齿时,这是个廉价的选择   

简单的PS代码

float4 blur_factor;
sampler Texture0;
sampler Texture1;
float4 ps_main(float2 texCoord: TEXCOORD0) : COLOR
{
      float4 col1 = tex2D(Texture0, texCoord);
      float4 col2 = tex2D(Texture1, texCoord);
     // Interpolate in-between the two render targets
      return lerp(col1,col2,blur_factor);
}

 

 

 

 

原创粉丝点击