All files / engine/Source/Shaders/Builtin/Functions applyHSBShift.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                                                                     
//This file is automatically rebuilt by the Cesium build process.
export default "/**\n\
 * Apply a HSB color shift to an RGB color.\n\
 *\n\
 * @param {vec3} rgb The color in RGB space.\n\
 * @param {vec3} hsbShift The amount to shift each component. The xyz components correspond to hue, saturation, and brightness. Shifting the hue by +/- 1.0 corresponds to shifting the hue by a full cycle. Saturation and brightness are clamped between 0 and 1 after the adjustment\n\
 * @param {bool} ignoreBlackPixels If true, black pixels will be unchanged. This is necessary in some shaders such as atmosphere-related effects.\n\
 *\n\
 * @return {vec3} The RGB color after shifting in HSB space and clamping saturation and brightness to a valid range.\n\
 */\n\
vec3 czm_applyHSBShift(vec3 rgb, vec3 hsbShift, bool ignoreBlackPixels) {\n\
    // Convert rgb color to hsb\n\
    vec3 hsb = czm_RGBToHSB(rgb);\n\
\n\
    // Perform hsb shift\n\
    // Hue cycles around so no clamp is needed.\n\
    hsb.x += hsbShift.x; // hue\n\
    hsb.y = clamp(hsb.y + hsbShift.y, 0.0, 1.0); // saturation\n\
\n\
    // brightness\n\
    //\n\
    // Some shaders such as atmosphere-related effects need to leave black\n\
    // pixels unchanged\n\
    if (ignoreBlackPixels) {\n\
        hsb.z = hsb.z > czm_epsilon7 ? hsb.z + hsbShift.z : 0.0;\n\
    } else {\n\
        hsb.z = hsb.z + hsbShift.z;\n\
    }\n\
    hsb.z = clamp(hsb.z, 0.0, 1.0);\n\
\n\
    // Convert shifted hsb back to rgb\n\
    return czm_HSBToRGB(hsb);\n\
}\n\
";