Skip to content

Instantly share code, notes, and snippets.

@pingpoli
Created July 9, 2020 15:16
Show Gist options
  • Save pingpoli/0fc01f3aa38a12f148ce0e4ecbb46a21 to your computer and use it in GitHub Desktop.
Save pingpoli/0fc01f3aa38a12f148ce0e4ecbb46a21 to your computer and use it in GitHub Desktop.
#version 330 core
uniform float threshold;
uniform float strength;
uniform sampler2D colorTexture;
in vec2 uv;
out vec4 fragColor;
void main()
{
vec4 color = texture2D( colorTexture , uv );
// convert rgb to grayscale/brightness
float brightness = dot( color.rgb , vec3( 0.2126 , 0.7152 , 0.0722 ) );
if ( brightness > threshold ) fragColor = vec4( strength * color.rgb , 1.0 );
else fragColor = vec4( 0.0 , 0.0 , 0.0 , 1.0 );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment