def lerp(input1, input2, mask):
    """Lerp between two values based on a 0-1 mask value.
    When mask is 0, return input1. When mask is 1, return input2.
    Otherwise blend between the two."""
    return ((1 - mask) * input1) + (mask * input2)