float_to_srgb :: (l: float) -> float {
    if (l <= 0) {
        return 0.0;
    } else if (l < 0.0031308) {
        return 12.92 * l;
    } else if (l < 1) {
        return 1.055 * pow(l, 0.41666) - 0.055;
    } else {
        return 1.0;
    }
}

linear_to_srgb :: (linear: Vector3) -> Vector3 {
    return .{float_to_srgb(linear.x), float_to_srgb(linear.y), float_to_srgb(linear.z)};
}

linear_to_srgb :: (linear: Vector4) -> Vector4 {
    return .{float_to_srgb(linear.x), float_to_srgb(linear.y), float_to_srgb(linear.z), linear.w};
}

srgb_to_linear :: (s: float) -> float {
    if (s <= 0.04045) {
        return s / 12.92;
    } else {
        return pow((s + 0.055) / 1.055, 2.4);
    }
}

srgb_to_linear :: (srgb: Vector3) -> Vector3 {
    return .{srgb_to_linear(srgb.x), srgb_to_linear(srgb.y), srgb_to_linear(srgb.z)};
}

srgb_to_linear :: (srgb: Vector4) -> Vector4 {
    return .{srgb_to_linear(srgb.x), srgb_to_linear(srgb.y), srgb_to_linear(srgb.z), srgb.w};
}

srgb_to_linear :: (srgb: [4]float) -> [4]float {
    return .[srgb_to_linear(srgb[0]), srgb_to_linear(srgb[1]), srgb_to_linear(srgb[2]), srgb[3]];
}
