Open
Description
The need for a remap() function (also called efit() in VEX) is very common in shading, and it would be appreciated if the standard library included it natively.
So far, of course, we can remap vectors or floats by simply defining the function manually:
vector vectorRemap(vector input, vector minIn, vector maxIn, vector minOut, vector maxOut) {
return minOut + (input - minIn) * (maxOut - minOut) / (maxIn - minIn);
}
float floatRemap(float input, float minIn, float maxIn, float minOut, float maxOut) {
return minOut + (input - minIn) * (maxOut - minOut) / (maxIn - minIn);
}
But, having it part of the std would simplify code and ensure a proper implementation:
type remap(type input, type minIn, type maxIn, type minOut, type maxOut)
Metadata
Metadata
Assignees
Labels
No labels