Skip to content

Instantly share code, notes, and snippets.

@jrsa
Last active March 16, 2016 16:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jrsa/b0f0920cb9b0e4f83548 to your computer and use it in GitHub Desktop.
Save jrsa/b0f0920cb9b0e4f83548 to your computer and use it in GitHub Desktop.
kernel vec4 basicBlur(sampler image, float width)
{
// get coordinates of the current pixel
vec2 center = samplerCoord(image);
// sum the current pixel and 4 pixels around it
vec4 result = sample(image, center);
result += sample(image, samplerTransform(image, samplerCoord(image) + vec2(-width, -width)));
result += sample(image, samplerTransform(image, samplerCoord(image) + vec2( width, -width)));
result += sample(image, samplerTransform(image, samplerCoord(image) + vec2( width, width)));
result += sample(image, samplerTransform(image, samplerCoord(image) + vec2(-width, width)));
// scale result
return result * vec2(0.2);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment