2
0

GammaCorrectionShader.js 641 B

123456789101112131415161718192021222324252627282930313233343536
  1. ( function () {
  2. /**
  3. * Gamma Correction Shader
  4. * http://en.wikipedia.org/wiki/gamma_correction
  5. */
  6. const GammaCorrectionShader = {
  7. uniforms: {
  8. 'tDiffuse': {
  9. value: null
  10. }
  11. },
  12. vertexShader: `varying vec2 vUv;
  13. void main() {
  14. vUv = uv;
  15. gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
  16. }`,
  17. fragmentShader: `uniform sampler2D tDiffuse;
  18. varying vec2 vUv;
  19. void main() {
  20. vec4 tex = texture2D( tDiffuse, vUv );
  21. gl_FragColor = LinearTosRGB( tex ); // optional: LinearToGamma( tex, float( GAMMA_FACTOR ) );
  22. }`
  23. };
  24. THREE.GammaCorrectionShader = GammaCorrectionShader;
  25. } )();