Advertisement
Guest User

Untitled

a guest
Jul 30th, 2014
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.40 KB | None | 0 0
  1. VertexShader VSBLUR
  2. {
  3.     Source =
  4.     """
  5.         attribute highp vec3    a_position;
  6.         attribute highp vec2    a_texCoord0;
  7.  
  8.         varying highp vec2 v_texCoord0;
  9.         varying highp vec2 v_texCoord1;
  10.         varying highp vec2 v_texCoord2;
  11.         varying highp vec2 v_texCoord3;
  12.         varying highp vec2 v_texCoord4;
  13.         varying highp vec2 v_texCoord5;
  14.         varying highp vec2 v_texCoord6;
  15.  
  16.         uniformbuffer FrameUniforms;
  17.         uniformbuffer BasicMaterialUniforms;
  18.  
  19.         const vec2 futher   = vec2(5.15); // Todo calculate?
  20.         const vec2 mid      = vec2(3.2307692308);
  21.         const vec2 close    = vec2(1.3846153846);
  22.  
  23.         highp vec2 transformTexCoord (highp vec2 texCoord)
  24.         {
  25.             return texCoord * u_texScaleOffset.xy + u_texScaleOffset.zw;
  26.         }
  27.  
  28.         void main()
  29.         {
  30.             #if defined(HORIZONTAL)
  31.                 vec2 sizeAndDir = vec2(4.0, 0.0) / u_screenSize;
  32.             #else
  33.                 vec2 sizeAndDir = vec2(0.0, 4.0) / u_screenSize;
  34.             #endif
  35.  
  36.             vec2 c = futher * sizeAndDir;
  37.             vec2 b = mid    * sizeAndDir;
  38.             vec2 a = close  * sizeAndDir;
  39.            
  40.             vec2 uv = transformTexCoord(a_texCoord0);
  41.             v_texCoord0 = uv - c;
  42.             v_texCoord1 = uv - b;
  43.             v_texCoord2 = uv - a;  
  44.             v_texCoord3 = uv;
  45.             v_texCoord4 = uv + a;
  46.             v_texCoord5 = uv + b;
  47.             v_texCoord6 = uv + c;
  48.            
  49.             gl_Position = vec4(a_position, 1.0);
  50.         }
  51.     """
  52. }
  53.  
  54. PixelShader PS
  55. {
  56.     Source =
  57.     """
  58.         varying highp vec2      v_texCoord0;
  59.  
  60.         //resourcebuffer        BackgroundResources;
  61.         resourcebuffer          BasicMaterialResources;
  62.  
  63.         void main()
  64.         {
  65.             gl_FragColor = texture2D(u_texture, v_texCoord0);
  66.         }
  67.     """
  68. }
  69.  
  70. PixelShader BLUR
  71. {
  72.     Source =
  73.     """
  74.         resourcebuffer          BasicMaterialResources;
  75.  
  76.  
  77.         varying highp vec2 v_texCoord0;
  78.         varying highp vec2 v_texCoord1;
  79.         varying highp vec2 v_texCoord2;
  80.         varying highp vec2 v_texCoord3;
  81.         varying highp vec2 v_texCoord4;
  82.         varying highp vec2 v_texCoord5;
  83.         varying highp vec2 v_texCoord6;
  84.        
  85.         #define center  0.2270270270
  86.         #define close   0.2962162162
  87.         #define far     0.0702702703
  88.         #define further 0.0375000000 // Todo calculate?
  89.         void main()
  90.         {    
  91.            gl_FragColor.rgb = further   * texture2D(u_texture, v_texCoord0).rgb
  92.                             + far       * texture2D(u_texture, v_texCoord1).rgb
  93.                             + close     * texture2D(u_texture, v_texCoord2).rgb
  94.                             + center    * texture2D(u_texture, v_texCoord3).rgb
  95.                             + close     * texture2D(u_texture, v_texCoord4).rgb
  96.                             + far       * texture2D(u_texture, v_texCoord5).rgb
  97.                             + further   * texture2D(u_texture, v_texCoord6).rgb;
  98.         }
  99.     """
  100. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement