PageRenderTime 135ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/samples/Cpp/TestCpp/Resources/Shaders/example_Blur.fsh

https://github.com/hailongiPhone/cocos2d-x
Fragment Shader File | 29 lines | 21 code | 7 blank | 1 comment | 0 complexity | d320521d2a4faaa943655928ed66a513 MD5 | raw file
  1. // Shader taken from: http://webglsamples.googlecode.com/hg/electricflower/electricflower.html
  2. #ifdef GL_ES
  3. precision mediump float;
  4. #endif
  5. varying vec4 v_fragmentColor;
  6. varying vec2 v_texCoord;
  7. uniform sampler2D CC_Texture0;
  8. uniform vec2 blurSize;
  9. uniform vec4 substract;
  10. void main() {
  11. vec4 sum = vec4(0.0);
  12. sum += texture2D(CC_Texture0, v_texCoord - 4.0 * blurSize) * 0.05;
  13. sum += texture2D(CC_Texture0, v_texCoord - 3.0 * blurSize) * 0.09;
  14. sum += texture2D(CC_Texture0, v_texCoord - 2.0 * blurSize) * 0.12;
  15. sum += texture2D(CC_Texture0, v_texCoord - 1.0 * blurSize) * 0.15;
  16. sum += texture2D(CC_Texture0, v_texCoord ) * 0.16;
  17. sum += texture2D(CC_Texture0, v_texCoord + 1.0 * blurSize) * 0.15;
  18. sum += texture2D(CC_Texture0, v_texCoord + 2.0 * blurSize) * 0.12;
  19. sum += texture2D(CC_Texture0, v_texCoord + 3.0 * blurSize) * 0.09;
  20. sum += texture2D(CC_Texture0, v_texCoord + 4.0 * blurSize) * 0.05;
  21. gl_FragColor = (sum - substract) * v_fragmentColor;
  22. }