GammaCorrectionShader.js 737 B

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