RGBToXYZ.js 984 B

1234567891011121314151617181920212223242526272829303132
  1. //This file is automatically rebuilt by the Cesium build process.
  2. export default "/**\n\
  3. * Converts an RGB color to CIE Yxy.\n\
  4. * <p>The conversion is described in\n\
  5. * {@link http://content.gpwiki.org/index.php/D3DBook:High-Dynamic_Range_Rendering#Luminance_Transform|Luminance Transform}\n\
  6. * </p>\n\
  7. * \n\
  8. * @name czm_RGBToXYZ\n\
  9. * @glslFunction\n\
  10. * \n\
  11. * @param {vec3} rgb The color in RGB.\n\
  12. *\n\
  13. * @returns {vec3} The color in CIE Yxy.\n\
  14. *\n\
  15. * @example\n\
  16. * vec3 xyz = czm_RGBToXYZ(rgb);\n\
  17. * xyz.x = max(xyz.x - luminanceThreshold, 0.0);\n\
  18. * rgb = czm_XYZToRGB(xyz);\n\
  19. */\n\
  20. vec3 czm_RGBToXYZ(vec3 rgb)\n\
  21. {\n\
  22. const mat3 RGB2XYZ = mat3(0.4124, 0.2126, 0.0193,\n\
  23. 0.3576, 0.7152, 0.1192,\n\
  24. 0.1805, 0.0722, 0.9505);\n\
  25. vec3 xyz = RGB2XYZ * rgb;\n\
  26. vec3 Yxy;\n\
  27. Yxy.r = xyz.g;\n\
  28. float temp = dot(vec3(1.0), xyz);\n\
  29. Yxy.gb = xyz.rg / temp;\n\
  30. return Yxy;\n\
  31. }\n\
  32. ";