XYZToRGB.js 997 B

1234567891011121314151617181920212223242526272829303132
  1. //This file is automatically rebuilt by the Cesium build process.
  2. export default "/**\n\
  3. * Converts a CIE Yxy color to RGB.\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_XYZToRGB\n\
  9. * @glslFunction\n\
  10. * \n\
  11. * @param {vec3} Yxy The color in CIE Yxy.\n\
  12. *\n\
  13. * @returns {vec3} The color in RGB.\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_XYZToRGB(vec3 Yxy)\n\
  21. {\n\
  22. const mat3 XYZ2RGB = mat3( 3.2405, -0.9693, 0.0556,\n\
  23. -1.5371, 1.8760, -0.2040,\n\
  24. -0.4985, 0.0416, 1.0572);\n\
  25. vec3 xyz;\n\
  26. xyz.r = Yxy.r * Yxy.g / Yxy.b;\n\
  27. xyz.g = Yxy.r;\n\
  28. xyz.b = Yxy.r * (1.0 - Yxy.g - Yxy.b) / Yxy.b;\n\
  29. \n\
  30. return XYZ2RGB * xyz;\n\
  31. }\n\
  32. ";