Skip to content

Instantly share code, notes, and snippets.

@weavejester
Last active June 10, 2016 20:32
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 weavejester/65a44ed7358abba6a11a3e500e7cb148 to your computer and use it in GitHub Desktop.
Save weavejester/65a44ed7358abba6a11a3e500e7cb148 to your computer and use it in GitHub Desktop.
precision mediump float;
varying vec2 vTextureCoord;
uniform sampler2D uSampler;
uniform vec2 dimensions;
void main(void) {
vec2 pixelSize = vec2(1.0) / dimensions;
vec4 pixel = texture2D(uSampler, vTextureCoord);
vec4 pixelUp = texture2D(uSampler, vTextureCoord - vec2(0.0, pixelSize.y));
vec4 pixelDown = texture2D(uSampler, vTextureCoord + vec2(0.0, pixelSize.y));
vec4 pixelLeft = texture2D(uSampler, vTextureCoord - vec2(pixelSize.x, 0.0));
vec4 pixelRight = texture2D(uSampler, vTextureCoord + vec2(pixelSize.x, 0.0));
if (pixel.a == 0.0 && (pixelUp.a > 0.0 ||
pixelDown.a > 0.0 ||
pixelLeft.a > 0.0 ||
pixelRight.a > 0.0)) {
pixel = vec4(1.0, 0.0, 0.0, 1.0);
}
gl_FragColor = pixel;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment