Requesting a function for facetracking parameter behaviors to simplify mapping a tracking key from one range to another.
Arity-5 version allows specifying both the input and output ranges:
map(key, in_start, in_stop, out_start, out_stop)
Arity-3 version assumes
0
and
1
as the input range (basically the same as
lerp
):
map(key, out_start, out_stop)
Performs this equivalent operation:
out_start + (out_stop - out_start) * ((key - in_start) / (in_stop - in_start))
I'd also suggest providing a version which additionally clamps the result to the output range, maybe called
cmap
.
One use-case for this is to be able to easily remap tracking keys to bias them in certain ways while allowing the user's facial movements to still contribute to the expression's livliness. For instance, in a "Sad" blendshape set, you might want to remap the "BrowInnerUp*" tracking keys to the range of
0.7
to
1.0
to force a sadder look.
How this function would be used to accomplish this example:
Apply to Blendshape, "BrowInnerUpRight", Custom
Blendshapes Set: "Sad"
Expression:
map(BrowInnerUpRight, 0.7, 1)
It reads a lot better than
(BrowInnerUpRight * 0.3) + 0.7
to get the same result and I don't have to work out the math for each range I'm trying to target. I foresee this also being used a lot to bias eye dilation/constriction for a lot of different emotions.