Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- varying float blurSize;
- uniform sampler2D tex;
- // Gaussian Blur
- // 512x512 and smaller textures give best results
- // 2 passes required
- void main()
- {
- // Echelon9 - Due to Apple not implementing array constructors in OS X's
- // GLSL implementation we need to setup the arrays this way as a workaround
- float BlurWeights[11];
- BlurWeights[0] = 0.0402;
- BlurWeights[1] = 0.0623;
- BlurWeights[2] = 0.0877;
- BlurWeights[3] = 0.1120;
- BlurWeights[4] = 0.1297;
- BlurWeights[5] = 0.1362;
- BlurWeights[6] = 0.1297;
- BlurWeights[7] = 0.1120;
- BlurWeights[8] = 0.0877;
- BlurWeights[9] = 0.0623;
- BlurWeights[10] = 0.0402;
- vec4 sum = texture2D(tex, gl_TexCoord[0].xy) * BlurWeights[0];
- #ifdef PASS_0
- for (int i = 1; i < 11; i++) {
- sum += texture2D(tex, vec2(clamp(gl_TexCoord[0].x - float(i) * (blurSize/2), 0.0, 1.0), gl_TexCoord[0].y)) * BlurWeights[i];
- sum += texture2D(tex, vec2(clamp(gl_TexCoord[0].x + float(i) * (blurSize/2), 0.0, 1.0), gl_TexCoord[0].y)) * BlurWeights[i];
- }
- #endif
- #ifdef PASS_1
- for (int i = 1; i < 11; i++) {
- sum += texture2D(tex, vec2(gl_TexCoord[0].x, clamp(gl_TexCoord[0].y - float(i) * (blurSize/2), 0.0, 1.0))) * BlurWeights[i];
- sum += texture2D(tex, vec2(gl_TexCoord[0].x, clamp(gl_TexCoord[0].y + float(i) * (blurSize/2), 0.0, 1.0))) * BlurWeights[i];
- }
- #endif
- gl_FragColor = sum;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement