saturation.js 783 B

123456789101112131415161718192021222324
  1. //This file is automatically rebuilt by the Cesium build process.
  2. export default "/**\n\
  3. * Adjusts the saturation of a color.\n\
  4. * \n\
  5. * @name czm_saturation\n\
  6. * @glslFunction\n\
  7. * \n\
  8. * @param {vec3} rgb The color.\n\
  9. * @param {float} adjustment The amount to adjust the saturation of the color.\n\
  10. *\n\
  11. * @returns {float} The color with the saturation adjusted.\n\
  12. *\n\
  13. * @example\n\
  14. * vec3 greyScale = czm_saturation(color, 0.0);\n\
  15. * vec3 doubleSaturation = czm_saturation(color, 2.0);\n\
  16. */\n\
  17. vec3 czm_saturation(vec3 rgb, float adjustment)\n\
  18. {\n\
  19. // Algorithm from Chapter 16 of OpenGL Shading Language\n\
  20. const vec3 W = vec3(0.2125, 0.7154, 0.0721);\n\
  21. vec3 intensity = vec3(dot(rgb, W));\n\
  22. return mix(intensity, rgb, adjustment);\n\
  23. }\n\
  24. ";