LuminosityShader.js 1021 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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/index.html#manual/en/introduction/Import-via-modules." );
  2. /**
  3. * @author alteredq / http://alteredqualia.com/
  4. *
  5. * Luminosity
  6. * http://en.wikipedia.org/wiki/Luminosity
  7. */
  8. THREE.LuminosityShader = {
  9. uniforms: {
  10. "tDiffuse": { value: null }
  11. },
  12. vertexShader: [
  13. "varying vec2 vUv;",
  14. "void main() {",
  15. " vUv = uv;",
  16. " gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
  17. "}"
  18. ].join( "\n" ),
  19. fragmentShader: [
  20. "#include <common>",
  21. "uniform sampler2D tDiffuse;",
  22. "varying vec2 vUv;",
  23. "void main() {",
  24. " vec4 texel = texture2D( tDiffuse, vUv );",
  25. " float l = linearToRelativeLuminance( texel.rgb );",
  26. " gl_FragColor = vec4( l, l, l, texel.w );",
  27. "}"
  28. ].join( "\n" )
  29. };