/**
 * TODO unverified
 * Decode RGBE (RGB + exponent) UINT32 value
 * @param {number[]|Float32Array} out
 * @param {number} out_offset
 * @param {number} rgbe
 */
export function rgbe9995_to_rgb(out, out_offset, rgbe) {
    // see https://github.com/godotengine/godot/blob/4c4e67334412f73c9deba5e5d29afa8651418af2/core/math/color.cpp#L471

    const r = rgbe & 0x1ff;
    const g = (rgbe >> 9) & 0x1ff;
    const b = (rgbe >> 18) & 0x1ff;
    const e = (rgbe >> 27);

    const scale = Math.pow(2.0, e - 15.0 - 9.0);

    const _r = r * scale;
    const _g = g * scale;
    const _b = b * scale;

    out[out_offset] = _r;
    out[out_offset + 1] = _g;
    out[out_offset + 2] = _b;
}