How to correctly render visible spectrum with uniform intensity? I'm trying to get the correct representation of visible spectrum to render on the screen. My current progress is with using CIE 1931 standard observer color matching functions analytically approximated by the equations given in this paper. Current image is like this:



Here the background is not ideally black to make it possible to introduce the negative contributions from the color matching functions:



But the problem with it is that the image seems to have a dip in intensity somewhere around 490 nm. I guess that this is related to the sum of the three functions having a minimum there. See the sum plotted against wavelength:



So my question is now: how do I fix the intensity of the image? Is there any standard for taking spectral sensitivity into account when converting wavelength to RGB/XYZ representation?
I guess that this is related to the sum of the three functions having a minimum there. See the sum plotted against wavelength


This is actually a wrong way to sum these functions: sRGB model specifies that to get luminosity one must weigh the RGB components with appropriate weights. Then luminosity, unsurprisingly, will become equal to the Y component of the XYZ representation.


  the problem with it is that the image seems to have a dip in intensity somewhere around 490 nm


I can actually see the dip not only near 490 nm, but also a smaller one near 570 nm.

Anyway, I think I've found the reason for this. First of all, let's plot the desaturated colors used in the rendering on the chromaticity diagram:



The dashed triangle is the sRGB gamut, and the cusp formed by the lower two lines of the green curve corresponds to the D65 white (gray) point. Notice that there are three "bumps" away from the white point, corresponding to violet, bluish-green and red. Or, that there is a large dip in saturation in the direction of 490 nm and a moderate decrease in the direction of around 570 nm. Let's characterize this graphically, plotting the norm of difference of the rendered points from white point:



This is exactly what I perceive visually in the image in terms of saturation and thus blending with the background.

Where does this strange shape come from, you may wonder. And the answer is, from the spectral locus in full XYZ space. See the following figure: the blue curve is the spectral locus, and the orange is its projection onto a plane normal to vector {1,1,1}.



So, the shape we got on the chromaticity diagram is something like a planar unfolding of the spectral locus.

As to realism of this rendering, I'm reasonably sure that if we try projecting real spectrum onto a gray non-fluorescent surface, we'll also see these two "strange" dips. And they will become less noticeable as you increase brightness of the spectrum relative to the brightness of the surface.