TLDR: We've developed a method to measure a surface's microfacet distribution, and are looking for a way to integrate this in a Cycles shader. For more info, see this paper.
Together with a fellow student, I have developed a low budget way to get somewhat accurate measurements of the microstructure of a surface that concern the glossyness of a surface for a university course on surface engineering. We've also tried to make a method to integrate this in a cycles shader, which in theory should give a "carbon copy" of the gloss of the original real world sample, or at least a more accurate representation. This would be a nice way to get better previews in product design, but could also be nice in a more general purpose way if you can build up a library of different real world materials to get more convincing shaders.
Right now, the only thing we are struggling with is the actual inplementation. I'm pretty experienced with Blender as a user, but I'm pretty new to coding, and while most aspects of the shaders are easily customizable, the one parameter we need (the microfacet distribution) doesn't allow for options outside of the dropdown menu, and as far as I can tell, it can only be changed by diving into the source code (which seems a bit intimidating, to say the least). What I'm looking for is a way to make something like a plugin or node group which enables me to plug the image that contains the measurement data into the microfacet model as some sort of a lookup table. Does anyone know how to do this?
Thanks in advance!
Since it is all pretty technical, and took us quite some time to figure out, here is some background info:
The gloss of a surface is for a large part determined by the slopes in the surface which distort the reflection. Since these "bumps" or "microfacets" are too small to see individually, they sort of "blend together" to form the blurriness of the reflection you see. Because this blend is the result of lots of these microfacets, the total amount of reflected light is proportional to the (average) presence of these microfacets. This is the microfacet distribution
Since there is some randomness to this distribution, it can be represented as a statistical model, which is what render engines use to emulate the roughness of a surface. There are all kinds of different models with different equations, strengths and weaknesses, like phong, Beckmann and GGX. In Cycles, you can pick a model from the top dropdown of most shader nodes. By changing the roughness parameter, the distribution changes and gives a shinier or rougher surface look.
For our method, the idea is to use a dataset gathered from an actual surface instead of a mathematical approximation. Below are some examples gathered through our method (see paper for more detailed explanation). The position represents a certain microfacet slope, while the brightness indicates the probability density, or the relative presence of that slope.
I hope this info helps to clarify the issue, or at least give some more insight in how realistic rendering works behind the scenes.