LuminosityShader.js 632 B

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