OutputShader.js 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. const OutputShader = {
  2. uniforms: {
  3. 'tDiffuse': { value: null },
  4. 'toneMappingExposure': { value: 1 }
  5. },
  6. vertexShader: /* glsl */`
  7. varying vec2 vUv;
  8. void main() {
  9. vUv = uv;
  10. gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
  11. }`,
  12. fragmentShader: /* glsl */`
  13. uniform sampler2D tDiffuse;
  14. #include <tonemapping_pars_fragment>
  15. varying vec2 vUv;
  16. void main() {
  17. gl_FragColor = texture2D( tDiffuse, vUv );
  18. // tone mapping
  19. #ifdef LINEAR_TONE_MAPPING
  20. gl_FragColor.rgb = LinearToneMapping( gl_FragColor.rgb );
  21. #elif defined( REINHARD_TONE_MAPPING )
  22. gl_FragColor.rgb = ReinhardToneMapping( gl_FragColor.rgb );
  23. #elif defined( CINEON_TONE_MAPPING )
  24. gl_FragColor.rgb = OptimizedCineonToneMapping( gl_FragColor.rgb );
  25. #elif defined( ACES_FILMIC_TONE_MAPPING )
  26. gl_FragColor.rgb = ACESFilmicToneMapping( gl_FragColor.rgb );
  27. #endif
  28. // color space
  29. gl_FragColor = LinearTosRGB( gl_FragColor );
  30. }`
  31. };
  32. export { OutputShader };