Hi. My name is Sam, and I’m new to Blender Artists. You can call me by the name of my mascot, Sunshade (a bipedal green lizard which I haven’t posted any images of yet).
I’m working on a project where I create virtual renderings of various real materials (in Cycles) using their complex refractive indexes at visible wavelengths. (see refractiveindex.info)
Rendering realistic metals (i.e. based on real optical data, not just colored yellow to look like gold, for example) has been discussed on this site before. The main problem with this kind of thing is that Cycles is an RGB renderer, not a spectral renderer. So, in order to solve this problem and accurately render real metals, the optical spectral data for the metals will have to be converted to RGB colors.
Thankfully, Blender already has an algorithm for this kind of thing: the Wavelength node in Cycles. I am using this node to write a Python script to calculate the RGB color of a metal from its visible (380-780 nm) reflectivity function.
To do this, however, I will need to understand the algorithm behind the Wavelength function. Could you please go into detail about the math and calculations that are used to convert from wavelength to RGB? I know it’s open source, but the code isn’t very comprehensible to me because I’m not very familiar with the language it’s written in.