blur.fs 916 B

12345678910111213141516171819202122232425262728293031323334
  1. #version 100
  2. precision mediump float;
  3. // Input vertex attributes (from vertex shader)
  4. varying vec2 fragTexCoord;
  5. varying vec4 fragColor;
  6. // Input uniform values
  7. uniform sampler2D texture0;
  8. uniform vec4 colDiffuse;
  9. // NOTE: Add here your custom variables
  10. // NOTE: Render size values must be passed from code
  11. const float renderWidth = 800;
  12. const float renderHeight = 450;
  13. float offset[3] = float[]( 0.0, 1.3846153846, 3.2307692308 );
  14. float weight[3] = float[]( 0.2270270270, 0.3162162162, 0.0702702703 );
  15. void main()
  16. {
  17. // Texel color fetching from texture sampler
  18. vec3 tc = texture2D(texture0, fragTexCoord).rgb*weight[0];
  19. for (int i = 1; i < 3; i++)
  20. {
  21. tc += texture2D(texture0, fragTexCoord + vec2(offset[i])/renderWidth, 0.0).rgb*weight[i];
  22. tc += texture2D(texture0, fragTexCoord - vec2(offset[i])/renderWidth, 0.0).rgb*weight[i];
  23. }
  24. gl_FragColor = vec4(tc, 1.0);
  25. }