SColor.h contains many functions which are unused and/or perform linear
operations on non-linear 8 bit sRGB color values, such as the plus operator and
`SColor::getInterpolated()`, and there is no documentation about missing gamma
correction.
Some of these functions are not called or called only once:
* `getAverage(s16 color)`: Unused
* `SColor::getLightness()`: Unused
* `SColor::getAverage()`: Claims to determine a color's average intensity but
calculates something significantly different since SColor represents
non-linear sRGB values.
* `SColor::getInterpolated_quadratic()`: Claims to interpolate between colors
but uses the sRGB color space, which is neither physically nor perceptually
linear.
* `SColorf::getInterpolated_quadratic()`: Unused
* `SColorf::setColorComponentValue()`: Unused
Removing or inlining these functions can simplify the code and documenting
gamma-incorrect operations can reduce confusion about what the functions do.
This commit does the following:
* Remove the above-mentioned unused functions
* Inline `SColor::getAverage()` into
`CIrrDeviceLinux::TextureToMonochromeCursor()`
* Rename `SColor::getLuminance()` into `SColor::getBrightness()` since it does
not determine a color's luminance but calculates something which differs
significantly from physical luminance since SColor represents non-linear sRGB
values.
* Inline `SColor::getInterpolated_quadratic()` into `GameUI::update()`,
where it is only used for the alpha value calculation for fading
* Document gamma-incorrect behaviour in docstrings
I originally wanted to get of the legacy IVideoDriver::setRenderTarget altogether,
but that ended up being too much work.
The remaining usage is in "dynamicshadowsrender.cpp".
Here's a comment I wrote about the workaround:
----------------------------------------
Use legacy call when there's single texture without depth texture
This means Irrlicht creates a depth texture for us and binds it to the FBO
This is currently necessary for a working depth buffer in the following cases:
- post-processing disabled, undersampling enabled
(addUpscaling specifies no depth texture)
- post-processing disabled, 3d_mode = sidebyside / topbottom / crossview
(populateSideBySidePipeline specifies no depth texture)
- post-processing disabled, 3d_mode = interlaced
(probably, can't test since it's broken)
(populateInterlacedPipeline specifies no depth texture)
With post-processing disabled, the world is rendered to the TextureBufferOutput
created in the functions listed above, so a depth buffer is needed
(-> this workaround is needed).
With post-processing enabled, only a fullscreen rectangle is rendered to
this TextureBufferOutput, so a depth buffer isn't actually needed.
But: These pipeline steps shouldn't rely on what ends up being rendered to
the TextureBufferOutput they provide, since that may change.
This workaround was added in 1e9640395468beb53f70303ef6b7aa72e395b7b4 /
https://irc.minetest.net/minetest-dev/2022-10-04#i_6021940
This workaround should be replaced by explicitly configuring depth
textures where needed.
----------------------------------------