As a response to patch D2003 and my own work in OSL (interference script), I suggest to add the option of interference effects to the glossy and glass shaders natively in cycles. Please note that I'm not familiar with the source code of Cycles, so this task description is based on cursory glancing through the code.
The OSL script suffers from the limitation that the effect of roughness on the surface normal does not influence the reflectance and transmittance factors calculated with the generalized Fresnel equations. Only the macroscale normal is used for the reflectance and transmittance. Patch D2003 handles this in a more appropriate way for metals by applying the correct reflectance to each sample from a distribution of angles in case of rough surfaces.
I propose to build on top of patch D2003, which I expect to have pretty much laid out all the ground work, and to extend it to include one or two additional layers of an arbitrary material that can be described with a complex refractive index.
Things to discuss:
- Implementation: multiple glossy shaders, or a single shader that can handle substrate-only, substrate+1 layer, substrate+2 layers?
- The phase of the reflectance is required for physically-correct behavior (no approximation). I implemented a complex math library in OSL just for this. Is it acceptable to do the same for cycles?
- If for substrate-only the approximate Fresnel reflectances are used, then for 1 or two layers with zero thickness a small color change can occur as in that case the exact solution is used. Is that acceptable? (disregarding a check for zero thickness of course)
- What to show the user? My OSL script has 3 n,k pairs (RGB) for each material (substrate, layer 1, layer 2). Then two thicknesses, one for each layer. I think this is the minimum. I optionally have the wavelengths of the RGB triplet and the refractive index of the outside medium as input via conditional compilation. The latter is perhaps the least useful, but the wavelengths determine the spacing between the interference fringes and therefore have an artistic value.
There are probably more things that I didn't think of, but this is a start. I am familiar with the physics and the equations that calculate such a feature and have experience with coding in C++. I would volunteer to implement interference effects in cycles and am thinking along the lines of co-development with a more senior Cycles developer.