LuminosityShader.js 954 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. console.warn( "THREE.LuminosityShader: As part of the transition to ES6 Modules, the files in 'examples/js' were deprecated in May 2020 (r117) and will be deleted in December 2020 (r124). You can find more information about developing using ES6 Modules in https://threejs.org/docs/#manual/en/introduction/Installation." );
  2. /**
  3. * Luminosity
  4. * http://en.wikipedia.org/wiki/Luminosity
  5. */
  6. THREE.LuminosityShader = {
  7. uniforms: {
  8. "tDiffuse": { value: null }
  9. },
  10. vertexShader: [
  11. "varying vec2 vUv;",
  12. "void main() {",
  13. " vUv = uv;",
  14. " gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
  15. "}"
  16. ].join( "\n" ),
  17. fragmentShader: [
  18. "#include <common>",
  19. "uniform sampler2D tDiffuse;",
  20. "varying vec2 vUv;",
  21. "void main() {",
  22. " vec4 texel = texture2D( tDiffuse, vUv );",
  23. " float l = linearToRelativeLuminance( texel.rgb );",
  24. " gl_FragColor = vec4( l, l, l, texel.w );",
  25. "}"
  26. ].join( "\n" )
  27. };