GammaCorrectionShader.js 679 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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:
  13. /* glsl */
  14. `
  15. varying vec2 vUv;
  16. void main() {
  17. vUv = uv;
  18. gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
  19. }`,
  20. fragmentShader:
  21. /* glsl */
  22. `
  23. uniform sampler2D tDiffuse;
  24. varying vec2 vUv;
  25. void main() {
  26. vec4 tex = texture2D( tDiffuse, vUv );
  27. gl_FragColor = LinearTosRGB( tex ); // optional: LinearToGamma( tex, float( GAMMA_FACTOR ) );
  28. }`
  29. };
  30. THREE.GammaCorrectionShader = GammaCorrectionShader;
  31. } )();