A simplified method that I use and that you may find useful to replicate gain and gamma in an Evalscript is the following (please note that this is empirical and has no sound scientific basis but may be fun to play around with):

###
Gain

Gain may be seen as a simple amplification of the signal. For that I use multiplication. Example:

```
//VERSION=3
function setup() {
return {
input: ["B05"],
output: { bands: 1}
};
}
// Set gain
const gain = 4
function evaluatePixel(sample) {
var band = sample.B05
return [band * gain]
}
```

###
Gamma

Gamma correction is the process to encode linear values into a non-linear relationship. You can use the HighlightCompressVisualizer function as @william.ray mentioned, or you can keep it simple and use exponentiation in your Evalscript:

```
//VERSION=3
function setup() {
return {
input: ["B05"],
output: { bands: 1}
};
}
// Set gamma
const gamma = 0.6
function evaluatePixel(sample) {
var band = sample.B05
return [Math.pow(band, gamma)]
}
```

And given that gamma correction is exponential, therefore scale sensitive, and is done on the scale of 0-1, we don’t need to normalise (reflectance is generally between 0 and 1).