GammaCorrectionShader.js 665 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /**
  2. * @author WestLangley / http://github.com/WestLangley
  3. *
  4. * Gamma Correction Shader
  5. * http://en.wikipedia.org/wiki/gamma_correction
  6. */
  7. THREE.GammaCorrectionShader = {
  8. uniforms: {
  9. "tDiffuse": { value: null }
  10. },
  11. vertexShader: [
  12. "varying vec2 vUv;",
  13. "void main() {",
  14. "vUv = uv;",
  15. "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
  16. "}"
  17. ].join( "\n" ),
  18. fragmentShader: [
  19. "uniform sampler2D tDiffuse;",
  20. "varying vec2 vUv;",
  21. "void main() {",
  22. "vec4 tex = texture2D( tDiffuse, vec2( vUv.x, vUv.y ) );",
  23. "gl_FragColor = LinearToGamma( tex, float( GAMMA_FACTOR ) );",
  24. "}"
  25. ].join( "\n" )
  26. };