LuminosityShader.js 664 B

12345678910111213141516171819
  1. ( function () {
  2. /**
  3. * Luminosity
  4. * http://en.wikipedia.org/wiki/Luminosity
  5. */
  6. var LuminosityShader = {
  7. uniforms: {
  8. 'tDiffuse': {
  9. value: null
  10. }
  11. },
  12. vertexShader: [ 'varying vec2 vUv;', 'void main() {', ' vUv = uv;', ' gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );', '}' ].join( '\n' ),
  13. fragmentShader: [ '#include <common>', 'uniform sampler2D tDiffuse;', 'varying vec2 vUv;', 'void main() {', ' vec4 texel = texture2D( tDiffuse, vUv );', ' float l = linearToRelativeLuminance( texel.rgb );', ' gl_FragColor = vec4( l, l, l, texel.w );', '}' ].join( '\n' )
  14. };
  15. THREE.LuminosityShader = LuminosityShader;
  16. } )();