GammaCorrectionShader.js 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. console.warn( "THREE.GammaCorrectionShader: As part of the transition to ES6 Modules, the files in 'examples/js' were deprecated in May 2020 (r117) and will be deleted in December 2020 (r124). You can find more information about developing using ES6 Modules in https://threejs.org/docs/index.html#manual/en/introduction/Import-via-modules." );
  2. /**
  3. * @author WestLangley / http://github.com/WestLangley
  4. *
  5. * Gamma Correction Shader
  6. * http://en.wikipedia.org/wiki/gamma_correction
  7. */
  8. THREE.GammaCorrectionShader = {
  9. uniforms: {
  10. "tDiffuse": { value: null }
  11. },
  12. vertexShader: [
  13. "varying vec2 vUv;",
  14. "void main() {",
  15. " vUv = uv;",
  16. " gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
  17. "}"
  18. ].join( "\n" ),
  19. fragmentShader: [
  20. "uniform sampler2D tDiffuse;",
  21. "varying vec2 vUv;",
  22. "void main() {",
  23. " vec4 tex = texture2D( tDiffuse, vUv );",
  24. " gl_FragColor = LinearTosRGB( tex );", // optional: LinearToGamma( tex, float( GAMMA_FACTOR ) );
  25. "}"
  26. ].join( "\n" )
  27. };