1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
|
#ifdef GL_ES precision mediump float; #endif
varying vec4 v_fragmentColor; varying vec2 v_texCoord;
uniform vec2 resolution;
uniform float blurRadius;
vec4 blur(vec2);
void main(void) { vec4 col = blur(v_texCoord); gl_FragColor = vec4(col) * v_fragmentColor; }
vec4 blur(vec2 p) { vec4 col = vec4(0); float r = blurRadius;
vec2 unit = 1.0 / resolution.xy; float step = r / 5.0; float allWeight = 0.0; for(float x = -r; x < r; x += step) { for(float y = -r; y < r; y += step) { float weight = (r - abs(x)) * (r - abs(y)); col += texture2D(CC_Texture0, p + vec2(x * unit.x, y * unit.y)) * weight; allWeight += weight; } } return col / allWeight; }
|