AcademySoftwareFoundation / AcademySoftwareFoundation/OpenShadingLanguage

remap function included in the std library

Open
#1,899 9 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
2.3k
Forks
414
Avg merge
3d 1h
Merged PRs (30d)
10

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:

```c
vector vectorRemap(vector input, vector minIn, vector maxIn, vector minOut, vector maxOut) {
return minOut + (input - minIn) * (maxOut - minOut) / (maxIn - minIn);
}
```

```c
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:

```c
type remap(type input, type minIn, type maxIn, type minOut, type maxOut)
```

Contributor guide

Open the contributing guide

Research direction

No files, tests, or entry points are identified in the issue, so begin by locating the standard-library implementation and existing scalar/vector utility tests. Define the supported types and edge-case behavior for remap(), then add coverage showing that the function is available and produces the expected mapped values.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers, computer-graphics
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.