Skip to content

Instantly share code, notes, and snippets.

@omarojo
Created March 27, 2018 22:06
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 omarojo/37d8c884c26de52300656c1b00e21171 to your computer and use it in GitHub Desktop.
Save omarojo/37d8c884c26de52300656c1b00e21171 to your computer and use it in GitHub Desktop.
Black and White Shader (GPUImage)
precision highp float;
varying highp vec2 textureCoordinate;
uniform sampler2D inputImageTexture;
void main()
{
highp vec4 textureColor;
highp vec4 rCol;
highp vec4 gCol;
highp vec4 bCol;
highp vec4 outputColor;
textureColor = texture2D(inputImageTexture, textureCoordinate);
rCol = vec4(vec3(textureColor.r), 1.0);
textureColor = texture2D(inputImageTexture, textureCoordinate);
gCol = vec4(vec3(textureColor.g), 1.0);
textureColor = texture2D(inputImageTexture, textureCoordinate);
bCol = vec4(vec3(textureColor.b), 1.0);
float avgColorVal = (rCol.r+gCol.g+bCol.b)/3.0;
gl_FragColor = vec4(vec3(avgColorVal,avgColorVal,avgColorVal),1.0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment