GammaCorrectionShader.js 677 B

1234567891011121314151617181920
  1. ( function () {
  2. /**
  3. * Gamma Correction Shader
  4. * http://en.wikipedia.org/wiki/gamma_correction
  5. */
  6. var GammaCorrectionShader = {
  7. uniforms: {
  8. 'tDiffuse': {
  9. value: null
  10. }
  11. },
  12. vertexShader: [ 'varying vec2 vUv;', 'void main() {', ' vUv = uv;', ' gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );', '}' ].join( '\n' ),
  13. fragmentShader: [ 'uniform sampler2D tDiffuse;', 'varying vec2 vUv;', 'void main() {', ' vec4 tex = texture2D( tDiffuse, vUv );', ' gl_FragColor = LinearTosRGB( tex );', // optional: LinearToGamma( tex, float( GAMMA_FACTOR ) );
  14. '}' ].join( '\n' )
  15. };
  16. THREE.GammaCorrectionShader = GammaCorrectionShader;
  17. } )();