sphericalHarmonics.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. //This file is automatically rebuilt by the Cesium build process.
  2. export default "/**\n\
  3. * Computes a color from the third order spherical harmonic coefficients and a normalized direction vector.\n\
  4. * <p>\n\
  5. * The order of the coefficients is [L00, L1_1, L10, L11, L2_2, L2_1, L20, L21, L22].\n\
  6. * </p>\n\
  7. *\n\
  8. * @name czm_sphericalHarmonics\n\
  9. * @glslFunction\n\
  10. *\n\
  11. * @param {vec3} normal The normalized direction.\n\
  12. * @param {vec3[9]} coefficients The third order spherical harmonic coefficients.\n\
  13. * @returns {vec3} The color at the direction.\n\
  14. *\n\
  15. * @see https://graphics.stanford.edu/papers/envmap/envmap.pdf\n\
  16. */\n\
  17. vec3 czm_sphericalHarmonics(vec3 normal, vec3 coefficients[9])\n\
  18. {\n\
  19. vec3 L00 = coefficients[0];\n\
  20. vec3 L1_1 = coefficients[1];\n\
  21. vec3 L10 = coefficients[2];\n\
  22. vec3 L11 = coefficients[3];\n\
  23. vec3 L2_2 = coefficients[4];\n\
  24. vec3 L2_1 = coefficients[5];\n\
  25. vec3 L20 = coefficients[6];\n\
  26. vec3 L21 = coefficients[7];\n\
  27. vec3 L22 = coefficients[8];\n\
  28. \n\
  29. float x = normal.x;\n\
  30. float y = normal.y;\n\
  31. float z = normal.z;\n\
  32. \n\
  33. return\n\
  34. L00\n\
  35. + L1_1 * y\n\
  36. + L10 * z\n\
  37. + L11 * x\n\
  38. + L2_2 * (y * x)\n\
  39. + L2_1 * (y * z)\n\
  40. + L20 * (3.0 * z * z - 1.0)\n\
  41. + L21 * (z * x)\n\
  42. + L22 * (x * x - y * y);\n\
  43. }\n\
  44. ";