I was wandering today on how to make a more accurate iridescence effect. I know that using the layer weight and a rainbow ramp can produce some acceptable look, but not quite accurate.
The big problem, is that cycles will color all the scattered rays with the same color at the point being rendered and not each ray by their own direction.
So i was thinking how to overcome this, and have something more real. And then i remembered that the samples for each pixel don’t hit everytime in the same precise position (using a sobol pattern if i’m not mistaken) and… Eureka!!
With this in mind, we can use a very tiny normal map in a glossy shader with 0 roughness, and because we can determine in which angle the reflected ray will be thrown, based on the incoming and the normal that is being calculated in that particular sample, we can have a specific color just for that direction, but still having more rays with other colors in other directions, all together in the same pixel.
The results I’m presenting here are still a bit far from the reality, but making a frequency to rgb node, and a bit more math for scaling the dimentions correctly, i think it’s possible to get there.
In fact, with this trick, it seems possible to create materials like holograms, maybe even with 3d objects inside… (maybe i’m looking to much ahead :o)
The only disadvantage is that we need lots of samples to get a clean result, and ‘branched path tracing’ doesn’t help.
here’s the setup… the value inputs are the main controls so if you want to make a node group, those are the most important. (and of course, some of the math can be improved :))
and here a sample render of the shader alone with different values… Take in consideration that this shader is supposed to work in conjunction with others.