2
0

GammaCorrectionShader.js 763 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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": { type: "t", 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. "#define GAMMA_OUTPUT",
  20. "#define GAMMA_FACTOR 2",
  21. "uniform sampler2D tDiffuse;",
  22. "varying vec2 vUv;",
  23. THREE.ShaderChunk[ "common" ],
  24. "void main() {",
  25. "vec4 tex = texture2D( tDiffuse, vec2( vUv.x, vUv.y ) );",
  26. "gl_FragColor = vec4( linearToOutput( tex.rgb ), tex.a );",
  27. "}"
  28. ].join( "\n" )
  29. };