monochrome.glsl 516 B

123456789101112131415161718192021222324252627282930
  1. //@renderpasses 0
  2. uniform sampler2D r_SourceBuffer;
  3. uniform vec2 r_SourceBufferScale;
  4. varying vec2 v_SourceBufferCoords;
  5. //@vertex
  6. attribute vec2 a_Position;
  7. void main(){
  8. v_SourceBufferCoords=a_Position * r_SourceBufferScale;
  9. gl_Position=vec4( a_Position * 2.0 - 1.0,-1.0,1.0 );
  10. }
  11. //@fragment
  12. uniform float m_Level;
  13. void main(){
  14. vec4 color=texture2D( r_SourceBuffer,v_SourceBufferCoords );
  15. float i=(color.r+color.g+color.b)/3.0;
  16. gl_FragColor=vec4( mix( color.rgb,vec3( i ),m_Level ),color.a );
  17. }