zoukankan      html  css  js  c++  java
  • GLSL学习_高斯滤波

    使用RenderMonkey:

    从自带的sobel修改的。

    vertex:

    复制代码
    uniform float height;
    
    varying vec4 vTexCoords00;
    varying vec4 vTexCoords01;
    varying vec4 vTexCoords02;
    varying vec4 vTexCoords10;
    varying vec4 vTexCoords11;
    varying vec4 vTexCoords12;
    varying vec4 vTexCoords20;
    varying vec4 vTexCoords21;
    varying vec4 vTexCoords22;
    
    void main(void)
    {
       vec4 Pos = gl_Vertex;
    
       gl_Position = vec4(Pos.xy,0, 1);
       
       vec4 BaseTexCoord;
       BaseTexCoord.x = 0.5 * (1.0 - Pos.x);
       BaseTexCoord.y = 0.5 * (1.0 + Pos.y);
       BaseTexCoord.zw = vec2(0.0, 1.0);
       
       float vOffset = (1.0 / height);
       
       vTexCoords00 = BaseTexCoord + vec4(-vOffset, -vOffset, 0.0, 0.0);
       vTexCoords01 = BaseTexCoord + vec4( 0.0,     -vOffset, 0.0, 0.0);
       vTexCoords02 = BaseTexCoord + vec4( vOffset, -vOffset, 0.0, 0.0);
    
       vTexCoords10 = BaseTexCoord + vec4(-vOffset,  0.0, 0.0, 0.0);
       vTexCoords11 = BaseTexCoord;  
       vTexCoords12 = BaseTexCoord + vec4( vOffset,  0.0, 0.0, 0.0);
       
       vTexCoords20 = BaseTexCoord + vec4(-vOffset,  vOffset, 0.0, 0.0);
       vTexCoords21 = BaseTexCoord + vec4( 0.0,      vOffset, 0.0, 0.0);
       vTexCoords22 = BaseTexCoord + vec4( vOffset,  vOffset, 0.0, 0.0);
    
    }
    复制代码

    Fragment:

    复制代码
    uniform sampler2D BaseMap;
    
    varying vec4 vTexCoords00;
    varying vec4 vTexCoords01;
    varying vec4 vTexCoords02;
    
    varying vec4 vTexCoords10;
    varying vec4 vTexCoords11;
    varying vec4 vTexCoords12;
    
    varying vec4 vTexCoords20;
    varying vec4 vTexCoords21;
    varying vec4 vTexCoords22;
    
    void main(void)
    {
       
       vec4 s00; vec4 s01; vec4 s02;
       vec4 s10; vec4 s11; vec4 s12;  
       vec4 s20; vec4 s21; vec4 s22;
      
       s00 = texture2DProj(BaseMap, vTexCoords00);
       s01 = texture2DProj(BaseMap, vTexCoords01);
       s02 = texture2DProj(BaseMap, vTexCoords02);
    
       s10 = texture2DProj(BaseMap, vTexCoords10);
       s11=  texture2DProj(BaseMap, vTexCoords11);   
       s12 = texture2DProj(BaseMap, vTexCoords12);
       
       s20 = texture2DProj(BaseMap, vTexCoords20);
       s21 = texture2DProj(BaseMap, vTexCoords21);
       s22 = texture2DProj(BaseMap, vTexCoords22);
    
       vec4 re=s00*0.0625+s01*0.125+s02*0.0625+
               s10*0.1250+s11*0.250+s12*0.1250+
               s20*0.0625+s21*0.125+s22*0.0625;
         
       gl_FragColor = re;
    }
    复制代码
  • 相关阅读:
    gw经销商上传部分代码
    lib
    【转】sql server的随机函数newID()和RAND()
    【源码】仿qq记住登录信息
    关于ConfigurationManager类
    oracle 10 协议适配器错误解决办法
    配置对象数据源时,无法找到业务对象的解决办法
    private的由来,让能你很容易地区分private与protected的用法!
    大树扎根不稳,缘何不倒?
    Html服务器控件常用属性InnerHtml属性及InnerText属性的区别
  • 原文地址:https://www.cnblogs.com/tiandsp/p/7440842.html
Copyright © 2011-2022 走看看