使用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,, );

   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;
}
05-11 14:04