If you have to do spectral rendering (so light wavelengths and not just RGB internal computations) I am a big fan of making your life simpler by doing two lazy moves:
1. Each ray gets its own wavelength
2. Use a 3 element piece-wise constant approximation for most of the spectra, and make all the XYZ tristimulous stuff implicit
First, here's how to do it "right". You can skip this part-- I'll put it in brown so it's easy to skip. We want some file of RGB pixels like sRGB. Look up the precise definition of sRGB in terms of XYZ. Look up the precise definition of XYZ (if you must do that because you are doing some serious appearance modeling use Chris Wyman's approximation). You will have three functions of wavelength x(), y(), and z(). X is for example:
X = k*INTEGRAL x(lambda) L(lambda) d-lambda
If you use one wavelength per ray, do it randomly and do Monte Carlo: lambda = 400 + 300*r01(), so pdf(lambda) = 1/300
X =approx= k*300*x(lambda) L(lambda)
You can use the same rays to approximate Y and Z because x(), y(), and z() partially overlap.
Now read in your model and convert all RGB triples to spectral curves. How? Don't ask me. Seems like overkill so let's be lazy.
OK now let's be lazier than that. This is a trick we used to use at the U of Utah in the 1990s. I have no idea what its origins are. Do this:
R =approx= L(lambda)
where lambda is a random wavelength in [600,700]nm
Do the same for G, B with random wavelengths in [500,600] and [400,500] respectively.
When you hit an RGB texture or material, just assume that it's a piecewise constant spectrum with the same spectral regions as above. If you have a formula or real spectral data (for example, Rayleigh scattering or an approximation to the refractive index of a prism) then use that.
This will have wildly bad behavior in the worst case. But in practice I have always found it to work well. As an empirical test in an NVIDIA project I tested it on a simple case, the Macbeth Color Checker spectra under flat white light. Here's the full spectral rendering using the real spectral curves of the checker and XYZ->RGB conversion and all that done "right":
And here it is with the hack using just 3 piece-wise constant spectra for the colors and the RGB integrals above.
That is different, but my belief is that is no bigger than the intrinsic errors in input data, tone mapping, and display variation in 99% of situations. One nice thing is it's pretty easy to convert an RGB renderer to a spectral renderer this way.