LuminosityShader.js 624 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /**
  2. * Luminosity
  3. * http://en.wikipedia.org/wiki/Luminosity
  4. */
  5. const LuminosityShader = {
  6. name: 'LuminosityShader',
  7. uniforms: {
  8. 'tDiffuse': { value: null }
  9. },
  10. vertexShader: /* glsl */`
  11. varying vec2 vUv;
  12. void main() {
  13. vUv = uv;
  14. gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
  15. }`,
  16. fragmentShader: /* glsl */`
  17. #include <common>
  18. uniform sampler2D tDiffuse;
  19. varying vec2 vUv;
  20. void main() {
  21. vec4 texel = texture2D( tDiffuse, vUv );
  22. float l = luminance( texel.rgb );
  23. gl_FragColor = vec4( l, l, l, texel.w );
  24. }`
  25. };
  26. export { LuminosityShader };