# Thin films layers

I have made the script “thin films” to simulate the effect of thin layers on a material.
This script node can handle till 16 layers ,plus 2 additional layers. (18 layers)
These 2 layers are: the first,generally air or void and the last,the base material.
So,if you want ,for example, 7 layer,you’ll have totally 9 consecutive layers

• the first initial layer (air,layer 0)
• your 7 layers (layer 1 to 7)
• the last layer (base layer,layer 8)

There must be at least one layer.

Every layer has a complex index of refraction (n,k) and it is identified by 2 vector inputs.
The first vector input is the real part of IOR for red,green,blue channels and the
the second vector input is the imaginary part of IOR for red,green,blue channels.
By default ,every layer has this ior inputs: ior_n = (1,1,1) and ior_k = (0,0,0)

Insert ior values starting from ior0_n,ior0_k and then go on until you have reached the desired number
of layers,then insert the last base layer.
The other following aand consecutive layers remain unused.

The other inputs are the thicknesses of the layers.
d0 is the thickness of layer1.Note that layer1 is not the first layers (air).It is the real first material layer
d1 is the thickness of layer2
d2 is the thickness of layer3

d15 is the thickness of layer16
Layer0 and the base layer have no thickness,but have ior.

At the end,layers_numb input is the number of layers 1 to 16
The output are the red,green,blue reflectance and transmittance.
Output values are automatically calculated,but obviously it does not always make sense to use transmittance values
for a base opaque material,for example.You decide how to use the outputs.

To facilitate the insertion of the ior values,i have included a “IOR Stack” node with 9 (nr,ng,nb) (kr,kg,kb) entries,so you can plug
vector output into the ior_n,ior_k vectors of the script node.
You can use 2 nodes to fill all ior_n,ior_k vectors of the script node.

In the script there are complex number functions.
I found formulas and thin films layers theory here:
http://pages.physics.cornell.edu/p510/w/images/p510/1/14/Ss14_heavens.pdf

http://unicorn.ps.uci.edu/249/Handouts/HansenPaperV2.pdf

These are examples of iridescence,a beetle with real values found on internet,and the same beetle with bumped surface,opals,
and a soap bubble with background texture.
@Prutser posts gave me the idea to make this.Thanks!
I have created 2 nodes “Transparent Translucent Material 2” and “Opaque Material 2”,which are a modified versions of my previous nodes, in order to use reflectance /transmittance from then “thin film” node.
The explanation of their input values is described in my post

RGB reflection and transmittance inputs of my new version of the nodes,match the output of the script node.

This is the blend file for theese materials:

### Attachments

ThinFilm.zip (11.6 MB)

1 Like