Skip to content

Instantly share code, notes, and snippets.

@DBC-Works
Created November 18, 2018 06:48
Show Gist options
  • Save DBC-Works/aeb3366fc8a32aeffc2f6ce1e9d7a01a to your computer and use it in GitHub Desktop.
Save DBC-Works/aeb3366fc8a32aeffc2f6ce1e9d7a01a to your computer and use it in GitHub Desktop.
Grayscale translater fragment shader for Processing
uniform sampler2D texture;
uniform ivec2 u_size;
out vec4 o_fragColor;
void main()
{
vec4 color = texture(texture, gl_FragCoord.xy / u_size);
float grayScale = ((color.r * 0.109375) + (color.g * 0.30078125) + (color.b * 0.58984375));
o_fragColor = vec4(grayScale, grayScale, grayScale, 1);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment