GammaCorrectionShader.js 616 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /**
  2. * Gamma Correction Shader
  3. * http://en.wikipedia.org/wiki/gamma_correction
  4. */
  5. const GammaCorrectionShader = {
  6. uniforms: {
  7. 'tDiffuse': { value: null }
  8. },
  9. vertexShader: /* glsl */`
  10. varying vec2 vUv;
  11. void main() {
  12. vUv = uv;
  13. gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
  14. }`,
  15. fragmentShader: /* glsl */`
  16. uniform sampler2D tDiffuse;
  17. varying vec2 vUv;
  18. void main() {
  19. vec4 tex = texture2D( tDiffuse, vUv );
  20. gl_FragColor = LinearTosRGB( tex ); // optional: LinearToGamma( tex, float( GAMMA_FACTOR ) );
  21. }`
  22. };
  23. export { GammaCorrectionShader };