LuminosityShader.js 612 B

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