GammaCorrectionShader.js 818 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /**
  2. * @module GammaCorrectionShader
  3. * @three_import import { GammaCorrectionShader } from 'three/addons/shaders/GammaCorrectionShader.js';
  4. */
  5. /**
  6. * Gamma Correction Shader
  7. *
  8. * References:
  9. * - {@link http://en.wikipedia.org/wiki/gamma_correction}.
  10. *
  11. * @constant
  12. * @type {ShaderMaterial~Shader}
  13. */
  14. const GammaCorrectionShader = {
  15. name: 'GammaCorrectionShader',
  16. uniforms: {
  17. 'tDiffuse': { value: null }
  18. },
  19. vertexShader: /* glsl */`
  20. varying vec2 vUv;
  21. void main() {
  22. vUv = uv;
  23. gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
  24. }`,
  25. fragmentShader: /* glsl */`
  26. uniform sampler2D tDiffuse;
  27. varying vec2 vUv;
  28. void main() {
  29. vec4 tex = texture2D( tDiffuse, vUv );
  30. gl_FragColor = sRGBTransferOETF( tex );
  31. }`
  32. };
  33. export { GammaCorrectionShader };