Thin-film interference and metals with complex refractive index

  • July 24, 2016
  • 3,135 Downloads
  • 16 Likes
  • Blender 2.7x
  • Render: Cycles
  • Creator: prutser
  • License: CC-BY-NC-SA
You must be logged in to download.

Description:

2018-01-12: GPU users, please see here for a GPU compatible version including all materials.

This Open Shading Language script implements a calculation of the Fresnel reflectance for metals and dielectrics, which may have complex indices of refraction (also known as n and k values, see complex refractive index). Here, n stands for the 'classic' index of refraction and k stands for the extinction coefficient, which describes absorption. This combination accurately describes the interaction of light with many types of materials, including glass-like materials, metals and car paints.

The main feature, next to true Fresnel calculations for metals, is that the base layer of the material may be coated with one or two thin, possibly absorbing, layers in which interference can occur. Light can interfere with itself, leading to a variety of rainbow-colored phenomena seen in for example oil spills on the street and soap bubbles. See the images for examples rendered with the script (bubbles lit by and background part of free HDR image pack by www.hdrlabs.com [not included]). The previews of single materials are rendered with the provided .blend file.

The script implements the calculation, whereas the blend file contains 31 materials that I have made with the script. It's just a small selection of the possibilities, and intended to get the user started. For example, refractiveindex.info lists combinations of n and k for many materials, which allows one to recreate all those materials listed.

To clarify the license: the code is CC BY-NC-SA 4.0. Feel free to use the output of the code for any purpose.

Some helpful hints:

Choosing values for n and k

The shader allows you to enter the values to use for the refractive index (n) and the extinction coefficient (k) for the red, green and blue channels. These values are often listed as a function of the wavelength of the light, for example at refractiveindex.info. Wavelengths that are perceived as red run from something like 625 nm to 670 nm, green is about 520 nm to 550 nm and blue is about 440 nm to 470 nm. Which wavelength you choose to use for red, green and blue depends on your own preference; there is no wrong choice, and the shader will behave physically correct regardless. Of course for different choices of n and k at slightly different wavelengths, the material is likely to change appearance slightly.

Optimized values of n and k for metals

So-called spectral renderers use the tabulated n and k values for each wavelength in the visible light spectrum to calculate what a material should look like. Cycles on the other hand only uses three color channels, one for red, one for green and one for blue. You might wonder what n and k values would best approximate the results of a spectral renderer. I have optimized the values of n and k for the metals that are included in the blend file to look as close as possible to the output from a spectral renderer, when the metal is illuminated with white light.

Documentation See the original thread here.

Comments:

  • CaptainRex profile picture
    CaptainRex

    WOW, that looks amazing man! Looking forward to digging into it :)

    Cheers, Rex

    Edited August 03, 2016
  • prutser profile picture
    prutser

    Glad to hear! I'm curious to know what you come up with :)

    Edited August 03, 2016
  • MiguelNacero profile picture
    MiguelNacero

    Excelente!

    Written August 09, 2016
  • prutser profile picture
    prutser

    Gracias!

    Written August 10, 2016
  • georgesd profile picture
    georgesd

    This is awesome! Thanks!!

    Written August 22, 2016
  • prutser profile picture
    prutser

    Thanks! And you're welcome :)

    Written August 22, 2016
  • ubi_laptop profile picture
    ubi_laptop

    more than awesome !

    Written August 22, 2016
  • prutser profile picture
    prutser

    Thanks!

    Written August 22, 2016
  • Comotempera profile picture
    Comotempera

    This is awesome! Thanks!

    Written August 22, 2016
  • prutser profile picture
    prutser

    Great :) You're welcome

    Written August 23, 2016
  • ChameleonScales profile picture
    ChameleonScales

    No way. I've been wanting this forever !

    Written September 15, 2016
  • prutser profile picture
    prutser

    And now you have it! :) Cheers and have fun with it!

    Written September 21, 2016
  • vhcros profile picture
    vhcros

    Amazing.. i´ll make a lot of render with this. Thanks

    Edited September 20, 2016
  • prutser profile picture
    prutser

    You're welcome! I'd be happy to see what you do with it :)

    Written September 21, 2016
  • kfbreauty profile picture
    kfbreauty

    Misleading image. How is anyone supposed to parse through this blend file? where are the models? Heres an idea: Why not include all the models AS SHOWN IN THE THUMBNAIL?????? geez.

    Edited June 23, 2017
  • prutser profile picture
    prutser

    How far does this attitude get you in the real world?

    Edited July 11, 2017
  • SuperChango profile picture
    SuperChango

    Hey man ! awesome !.. im wondering if the same method could be used to portray an accurate prims effect ? i working on a car model with xenon reflectors and trying to get the chromatic variation on the edges.. currently getting somewhere using 3 different nodes with R glass, G glass and B glass combined with add shaders and then mixed to a white glass.. but it's not very convincing..

    Written October 24, 2017
  • prutser profile picture
    prutser

    Unfortunately that's as close to prism effects you'll get without faking it in Cycles

    Written January 12, 2018