BrightPass.js 762 B

1234567891011121314151617181920212223
  1. //This file is automatically rebuilt by the Cesium build process.
  2. export default "uniform sampler2D colorTexture;\n\
  3. uniform float avgLuminance;\n\
  4. uniform float threshold;\n\
  5. uniform float offset;\n\
  6. varying vec2 v_textureCoordinates;\n\
  7. float key(float avg)\n\
  8. {\n\
  9. float guess = 1.5 - (1.5 / (avg * 0.1 + 1.0));\n\
  10. return max(0.0, guess) + 0.1;\n\
  11. }\n\
  12. void main()\n\
  13. {\n\
  14. vec4 color = texture2D(colorTexture, v_textureCoordinates);\n\
  15. vec3 xyz = czm_RGBToXYZ(color.rgb);\n\
  16. float luminance = xyz.r;\n\
  17. float scaledLum = key(avgLuminance) * luminance / avgLuminance;\n\
  18. float brightLum = max(scaledLum - threshold, 0.0);\n\
  19. float brightness = brightLum / (offset + brightLum);\n\
  20. xyz.r = brightness;\n\
  21. gl_FragColor = vec4(czm_XYZToRGB(xyz), 1.0);\n\
  22. }\n\
  23. ";