Skip to content

Instantly share code, notes, and snippets.

@kazukitanaka0611
Last active December 17, 2015 13:28
Show Gist options
  • Save kazukitanaka0611/5616997 to your computer and use it in GitHub Desktop.
Save kazukitanaka0611/5616997 to your computer and use it in GitHub Desktop.
#pragma mark -
- (NSString *)getFragmentShaderString
{
NSString *const kFragmentShaderString = SHADER_STRING
(
varying highp vec2 textureCoordinate;
uniform sampler2D inputImageTexture;
const highp vec3 W = vec3(0.2125, 0.7154, 0.0721);
void main()
{
    // To gray
highp float gray = step(0.5,dot(texture2D(inputImageTexture, textureCoordinate).rgb, W));
lowp vec4 colorToDisplay = vec4(1.0, 1.0, 1.0, 1.0);
if (gray < 1.00)
{
colorToDisplay = vec4(1.0, 0.0, 0.0, 1.0);
}
gl_FragColor = colorToDisplay;
}
);
return kFragmentShaderString;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment