A complex approach - Iridescence in cycles

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. :frowning:

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.


Looks gorgeous. I’ll take a try, thanks for sharing.

Hi Secrop,

There are a problem with the link, please:
vBulletin Message

Invalid Attachment specified. If you followed a valid link, please notify the administrator

thanks Spirou4D, it’s now solved.

Could you utilise the wavelength node to achieve the same effect?

So that’s what I got attempting to create a wavelength node based setup.

The wavelenght node!!! Big thanks Microno… I totally forgot that blender has this!!!
I must experiment more :smiley:

And nice shader there… :wink:
what value did you use in the wavelength?
did you scaled the output from the Sine node to fit between 380-780nm?

What if you use HSV combine, pluging the input into Hue (and perhaps some ramp into Value) with Saturation at max?

@TiagoTiago that works, but is not very realistic.

The wavelength may be a better solution. The purpose of this setup is to give us the distance that a ray would be dephased from its original phase, and the wavelength fits good in this approach.
I haven’t figured out how to put everything together, but it looks that all the pieces of the puzzle are already here… I must study a bit more about diffraction…:spin:

The whole iridescence thing is caused by thin-film diffraction (or at least for most things). To mimic the way that works I sort of recreated an incident ray based on the incoming ray and the surface normal which I obtained using your method of using the bump node. That gave me a whole bundle of useful things. Shall I post the .blend file here for you to take a look?

you can post a snapshot of the shader, or just the normal+incoming to color part, if you like. the .blend is also ok. :wink:

this is what i’m trying to implement: http://www-users.cs.umn.edu/~meyer/papers/33005.pdf
but my math is a bit rusty, so it will take more time :slight_smile:

anyway, i’m getting some interesting effects, with some variations i’ve been testing… and finding some artifacts with the normals, so still don’t know the best relation between the noise size and the bump strengh/distance, it’s has been a bit trial and error…

I was going to post a screenshot and then noticed that I couldn’t get enough of the nodes in in a legible way so here’s the .blend. :smiley:

iridescence.blend (631 KB)

Basically I butchered the thin film constructive interference equation and spliced in the phase shift condition.


iridescence.blend (635 KB)


Maybe I’m dumb, but what about a Combine-RGB with a different facing/fresnel in each input and tweaking their vector inputs a bit?

I did some odd thing where I have this:

Not sure if completely related, but it’s interesting. Not something I’d consider scientifically accurate though.

Yeah, that’s not gonna be very realistic mostly because the colours on your colour ramp are not spaced according to the light spectrum. If you did that and used the correct ior values for each wavelength of light you’d end up with a reasonably accurate setup I think?

Can you show some results/tests with your setup? I’m curious as to how it is.

I’m watching this thread with great interest…might download the blends when I get a chance.

Yep - and unfortunately you cannot plug the wavelength node into the colour ramp. There are online wavelength to RGB converters though. You could take say intervals of 10nm and convert them to RGB - spacing them appropriately on the colour ramp.


I did something similar when I created a colour ramp for my colour temperature converter node setup - which has a wider range than the inbuilt colour temperature node.

There is an easier method, for every colour you need you create a new slider thing and set its position to the wavelength. For example, 480nm is a saturated blue so you create a saturated blue slider and set its position to 0.48 and you repeat that for the other wavelengths.

That’s a pretty accurate approximation since you don’t really care about the colours below ~400nm and above ~800nm because they’re outside the spectrum of visible light. :smiley:

Oh and you put one black slider just as the colour falls into ultraviolet and one just as the colour falls into infrared. Boom, you got a nice colour ramp. :smiley:

I did some experimentation where it’s in a bigger node group. (Screengrab of nodes with test render image.) I tend to do Blendering more artistically rather than scientifically, so I’m not too worried about accuracy. (And on some project rather than a test I’ll keep shifting stuff until it’s the way I like it.) But part of sharing nodes is so that those inclined to do different things may be able to build upon them or come up with new ideas.


The color shift is a bit different than Secrop’s or yours Microno, and perhaps a little fakey in handling light. (Color shift doesn’t entirely move with light sources afaik.) Still it’s a neat effect that may work well in stills. I also noticed this node setup achieved something interesting with the light bloom on the highlight (it’s subtle though, source light is default colored point emitter), even though that wasn’t exactly one of the goals.

I’m also contemplating if it’s possible to achieve any prismatic effects via materials with separated handling of RGB, even though Cycles isn’t supposed to simulate that kind of thing with light on it’s own.

Yep - that’s pretty much what I was suggesting. The link I gave above gives RGB values for wavelengths between 380 and 780nm - so you could set these on the slider plus all wavelengths at 10nm intervals in between - then set values at 370 and 790 to black.