Open Smilebags opened 3 years ago
In order to handle values above 1 with this approach, an additional scaling factor might need to be used; scale the initial XYZ triplet down until the maximum value is 1, put it through the LUT, then scale the resulting spectrum back up. This stops us from needing to create a mapping for values greater than 1.
Values outside of the spectral locus won't have a meaningful mapping so could be mapped to a black spectrum. This feels sensible considering the spectra will become darker and darker as you approach the boundary.
One concern I have is whether there is a continuous transition of the ABC values and corresponding spectra to travel from red or blue into the magenta region. The A term swaps sign in order to describe magentas and I'm not sure how the spectra will behave at the transition point between blue and purple, for example. Requires some investigation.
Partially implemented Jakob and Hanika (2019) spectral reconstruction method in 4cd99a7.
An alternative to summed primaries for spectral upsampling is to use a quadratic sigmoid spectrum.
Any quadratic can be described with 3 coefficients so in that sense they can be considered equivalent to any 3-channel colour space. The process for this upsampling technique is to create a lookup table from XYZ to the quadratic's 3-coefficient space (ABC for now) which is then fed through a sigmoid function which compresses the range into 0-1. This way, any simple (one slope up, one slope down) spectrum can be defined with 3 coefficients.
We can utilise a simple 3D lookup table to take us from XYZ to ABC. Evaluating this spectrum is also efficient, though it might be slightly less efficient than the summed primaries approach. In the following example, A can be considered 'steepness', B is midpoint, and C is width.
https://www.desmos.com/calculator/mh7vofyfmz