All files / engine/Source/Shaders/Builtin/Functions sphericalHarmonics.js

0% Statements 0/0
0% Branches 0/0
0% Functions 0/0
0% Lines 0/0

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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