LuminosityShader.js 655 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /** @module LuminosityShader */
  2. /**
  3. * Luminosity shader.
  4. *
  5. * @constant
  6. * @type {Object}
  7. */
  8. const LuminosityShader = {
  9. name: 'LuminosityShader',
  10. uniforms: {
  11. 'tDiffuse': { value: null }
  12. },
  13. vertexShader: /* glsl */`
  14. varying vec2 vUv;
  15. void main() {
  16. vUv = uv;
  17. gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
  18. }`,
  19. fragmentShader: /* glsl */`
  20. #include <common>
  21. uniform sampler2D tDiffuse;
  22. varying vec2 vUv;
  23. void main() {
  24. vec4 texel = texture2D( tDiffuse, vUv );
  25. float l = luminance( texel.rgb );
  26. gl_FragColor = vec4( l, l, l, texel.w );
  27. }`
  28. };
  29. export { LuminosityShader };
粤ICP备19079148号