37
$\begingroup$

Is it possible to create an iridescence shader in Cycles?
Specifically for something like DVDs, soap bubbles, engine oil, etc..

I know about this technique for a DVD material, but it doesn't properly disperse light that is not anisotropically reflected.

$\endgroup$
30
$\begingroup$

From your linked definition of iridescence:

Iridescence [is] the property of certain surfaces that appear to change color as the angle of view or the angle of illumination changes.

Thus, the following node setup should suffice:

Iridescence node setup

If you're not familiar with node groups, this will create a new "node" called Iridescence that takes a base color parameter (you probably want white) and a factor parameter (which determines how strong the iridescence is; you probably want about 0.4) to output a color that you can put into a shader. You can see examples of how this works before.

The setup simply takes the dot product of the view vector and the surface normal and maps it to a spectrum. If you're not familiar with vector math, you can basically think of a dot product as a measure of how parallel two vectors are: the dot product of two perpendicular vectors is 0, while the dot product of two normalized parallel (or anti-parallel) vectors is 1.

You can put this node group in any shader and get a nice result. I tried it in a Diffuse BSDF, but putting it in a Glass BSDF might yield some nice bubble renders.

Here's an image of Suzanne wearing her iridescent cloak (the factor is set to 1.0 to exaggerate the effect):

Iridescence on Suzanne head, fac=1.0

Here's the factor turned down to 40% (lower works in better lighting setups, but my sky texture is blowing it out):

Iridescence on Suzanne head, fac=0.4

$\endgroup$
  • 1
    $\begingroup$ It's sometimes also nice to Add a magic or distorted noise texture to the Normal or Reflection coordinates $\endgroup$ – Greg Zaal Aug 13 '13 at 8:37
  • $\begingroup$ Could you post an EXPANDED version of the node-setup in your iridescence shader? I can't even guess at what is in "Group Input" and/or "Group Output"...Otherwise it LOOKS like a great shader... TIA... :O) $\endgroup$ – David A. Lewis Aug 20 '13 at 23:06
  • $\begingroup$ @DavidA.Lewis please see my edit. $\endgroup$ – wchargin Aug 20 '13 at 23:09
  • 1
    $\begingroup$ @DavidA.Lewis Node groups were changed a lot in 2.67. That is the expanded form, the nodes "group input" and "group output" are now part of the way node groups work (and can't be expanded). $\endgroup$ – gandalf3 Aug 21 '13 at 2:54
  • $\begingroup$ Why did you use the camera vector? How well would that work with something like a mirror in the scene? Should you perhaps use the incoming vector instead? $\endgroup$ – Segmented Jul 22 '17 at 5:02
23
$\begingroup$

True iridescence is difficult to achieve using Cycles. However, there are ways you can fake the effects of iridescence by shifting the color slightly based on the object normals. This has the advantage of being highly customizable for your particular purpose and much faster than true iridescence would be.

Update: I was able to find an implementation of this using Cycles on this BA thread.

Here is the node setup:

enter image description here

And an example render using the above node setup with different values:

enter image description here

EDIT: Found a better implementation done directly in Cycles. The old BI node setup can be found here.

$\endgroup$
  • $\begingroup$ Noise Scale: 5 Million!?!? Is that necessary for faking some tiny surface geometry that creates iridescence? (Nice answer, btw) $\endgroup$ – Mentalist Mar 14 '16 at 8:14
  • $\begingroup$ The setup posted here is far from correct (I know because I'm the author of the mentioned thread). The noise scale only serves for sampling purposes, as we need different seeds for each sample, but as I mentioned in that same thread, the output values are not normalized, and create a strange bias in the wavelength distribution. For diffraction grating (CDs, DVDs, etc), I'd advise to use my OSL script (also in the thread), wich is more accurated and physically based. $\endgroup$ – Secrop Feb 23 '18 at 10:05
15
$\begingroup$

This is where OpenShadingLanguage can step in. Using an OSL script you can get an iridescence effect.

Michel J. Anders has already done the hard work on his Small Blender Things blog with his surface iridescence shader. You may find some of his other scripts interesting as well.

For example:

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.