To keep the frame rate up, let's only sample eight points for the blur.

This commit is contained in:
Andrzej Kapolka 2013-08-13 14:52:35 -07:00
parent 581b60995a
commit d24e340c91
2 changed files with 5 additions and 21 deletions

View file

@ -13,20 +13,12 @@ uniform sampler2D originalTexture;
void main(void) {
float ds = dFdx(gl_TexCoord[0].s);
gl_FragColor = (texture2D(originalTexture, gl_TexCoord[0].st + vec2(ds * -15.5, 0.0)) +
texture2D(originalTexture, gl_TexCoord[0].st + vec2(ds * -13.5, 0.0)) +
texture2D(originalTexture, gl_TexCoord[0].st + vec2(ds * -11.5, 0.0)) +
texture2D(originalTexture, gl_TexCoord[0].st + vec2(ds * -9.5, 0.0)) +
texture2D(originalTexture, gl_TexCoord[0].st + vec2(ds * -7.5, 0.0)) +
gl_FragColor = (texture2D(originalTexture, gl_TexCoord[0].st + vec2(ds * -7.5, 0.0)) +
texture2D(originalTexture, gl_TexCoord[0].st + vec2(ds * -5.5, 0.0)) +
texture2D(originalTexture, gl_TexCoord[0].st + vec2(ds * -3.5, 0.0)) +
texture2D(originalTexture, gl_TexCoord[0].st + vec2(ds * -1.5, 0.0)) +
texture2D(originalTexture, gl_TexCoord[0].st + vec2(ds * 1.5, 0.0)) +
texture2D(originalTexture, gl_TexCoord[0].st + vec2(ds * 3.5, 0.0)) +
texture2D(originalTexture, gl_TexCoord[0].st + vec2(ds * 5.5, 0.0)) +
texture2D(originalTexture, gl_TexCoord[0].st + vec2(ds * 7.5, 0.0)) +
texture2D(originalTexture, gl_TexCoord[0].st + vec2(ds * 9.5, 0.0)) +
texture2D(originalTexture, gl_TexCoord[0].st + vec2(ds * 11.5, 0.0)) +
texture2D(originalTexture, gl_TexCoord[0].st + vec2(ds * 13.5, 0.0)) +
texture2D(originalTexture, gl_TexCoord[0].st + vec2(ds * 15.5, 0.0))) / 16.0;
texture2D(originalTexture, gl_TexCoord[0].st + vec2(ds * 7.5, 0.0))) / 8.0;
}

View file

@ -16,21 +16,13 @@ uniform sampler2D horizontallyBlurredTexture;
void main(void) {
float dt = dFdy(gl_TexCoord[0].t);
vec4 blurred = (texture2D(horizontallyBlurredTexture, gl_TexCoord[0].st + vec2(0.0, dt * -15.5)) +
texture2D(horizontallyBlurredTexture, gl_TexCoord[0].st + vec2(0.0, dt * -13.5)) +
texture2D(horizontallyBlurredTexture, gl_TexCoord[0].st + vec2(0.0, dt * -11.5)) +
texture2D(horizontallyBlurredTexture, gl_TexCoord[0].st + vec2(0.0, dt * -9.5)) +
texture2D(horizontallyBlurredTexture, gl_TexCoord[0].st + vec2(0.0, dt * -7.5)) +
texture2D(horizontallyBlurredTexture, gl_TexCoord[0].st + vec2(0.0, dt * -4.5)) +
vec4 blurred = (texture2D(horizontallyBlurredTexture, gl_TexCoord[0].st + vec2(0.0, dt * -7.5)) +
texture2D(horizontallyBlurredTexture, gl_TexCoord[0].st + vec2(0.0, dt * -5.5)) +
texture2D(horizontallyBlurredTexture, gl_TexCoord[0].st + vec2(0.0, dt * -3.5)) +
texture2D(horizontallyBlurredTexture, gl_TexCoord[0].st + vec2(0.0, dt * -1.5)) +
texture2D(horizontallyBlurredTexture, gl_TexCoord[0].st + vec2(0.0, dt * 1.5)) +
texture2D(horizontallyBlurredTexture, gl_TexCoord[0].st + vec2(0.0, dt * 3.5)) +
texture2D(horizontallyBlurredTexture, gl_TexCoord[0].st + vec2(0.0, dt * 5.5)) +
texture2D(horizontallyBlurredTexture, gl_TexCoord[0].st + vec2(0.0, dt * 7.5)) +
texture2D(horizontallyBlurredTexture, gl_TexCoord[0].st + vec2(0.0, dt * 9.5)) +
texture2D(horizontallyBlurredTexture, gl_TexCoord[0].st + vec2(0.0, dt * 11.5)) +
texture2D(horizontallyBlurredTexture, gl_TexCoord[0].st + vec2(0.0, dt * 13.5)) +
texture2D(horizontallyBlurredTexture, gl_TexCoord[0].st + vec2(0.0, dt * 15.5))) / 16.0;
texture2D(horizontallyBlurredTexture, gl_TexCoord[0].st + vec2(0.0, dt * 7.5))) / 8.0;
gl_FragColor = blurred * blurred.a + texture2D(originalTexture, gl_TexCoord[0].st) * (1.0 + blurred.a * 0.5);
}