Thin Film Interference Shader

For a while now, I’ve needed an accurate and easy to use thin film interference node.

I noticed not many exist for blender, and the few that do are incredibly complex or inaccurate.

So, using a paper I found from 2013: https://www.gamedev.net/tutorials/_/technical/graphics-programming-and-theory/thin-film-interference-for-computer-graphics-r2962/

I was able to implement it in shader nodes. Here’s a video of me previewing it in the viewport:
YouTube - Experimenting with Thin Film Interference

The final node group actually wasn’t too bad.

This particular technique allows you to control various parts of the film, including all 3 layers, as well as the total thickness (in nanometers)

It also allows you to specify a 3-dimensional Lambda value for the the RGB Channels.

You can also manipulate the thickness and other values with textures. I’ve tested this setup with Jocafa’s Fancy Glass, as well as some other materials, and it really works quite well. Its very customizable.

The only issue right now is finding the right Lambda and Thickness values for specific materials. I dont know if they’re documented anywhere, but you can more or less find good values through trial and error.

The final result of this is quite pretty: (I gave the film roughness with some FBM noise)

You can download this node and the sample scene here:
Gumroad - Simulated Thin Film Interference Node
(its free but Id always appreciate a tip, dont feel obligated though lol)

12 Likes

Wow, this is incredible! I’ve seen a few attempts to make this effect in Blender but I’ve never seen results anywhere near this good. Amazing work!!!

1 Like

Thanks, that was my goal. No one had anything that was this simple yet accurate, so I wanted to implement it in nodes.

Also, on a side note, if you want iridescent glass… This shader goes AMAZINGLY well with jocafa’s fancy glass (simulates true dispersion using Cauchy’s formula)
Gumroad - JCF Fancy Glass (Its free)

5 Likes

What a thing of absolute beauty, but maybe it is simply due to me not knowing how to use it.
I simple open the file in Blender 3.2 and “computer says no” to thin film effect.


I didn’t change anything, I just open the file and go to render mode.
Nothing…:frowning: No Thin Film…

1 Like

Wow… That is strange… Can you go inside the node group hierarchy and make sure all the nodes are there. If it says “Missing Data-Block” on one of the nodes: (like this) then delete the project and redownload it. I tested it on another device, and it worked fine.

I reuploaded the file and made sure all the resources were packed… I dont see any other reason it would fail. Its on gumroad to download.

Its self contained, it grabs the info for the geometry from within, so its definitely not a reference issue.

Only thing I can think of, is that somehow a node wasnt included or was disconnected.

First of all, don’t worry about it, there are so many changes because of how fast Blender is improving that I am surprised any developer can keep up existing add-on and or nodes.


I redownloaded the file, double click, Blender 3.2 opened, go to render mode.
Nothing.

strange, well this is extra weird because this is just math. It just uses incoming and normals… Theres no special behavior here that relies on something from a specific update.

I just tested this on another machine, both 3.0, 3.2, and 3.3 alpha. All worked.

Did you check the inside of the node group?

Downloaded from one of my alternate machines:

How do you check from inside the node group ? What do you press to go into the inside ? Thanks.
I will post a screenshot when I get into it :smiley:

Hello, it doesn’t work for me nether (Blender 3.20), looking inside the “True Thin Film” group node there are three red “Undefined” nodes:

Select the node group and hit TAB to get in and out of node group.

OH you guys arent using the new color separation and combining nodes

NOW everything makes total sense, brb

@EnV @anon62435837 Its fixed, turns out my versions were using the new “Combine Color” nodes… 3.0 stable versions are still using “Conbine RGB / HSV” and whatnot… hence why it wasnt working.

it should be fixed now. https://mistersircode.gumroad.com/l/thinfilm

Tested on lower versions, works fine now. Make sure to download the file that says legacy

Heaven forbid blender devs just decide to change the color logic nodes… breaks my shaders for everyone.

Finally… phew… if youre still having issues, please wait a bit for gumroad to update the files.

image

2 Likes

Wow, now I am thinking half of all my purchased add on will fail after 3.3… :frowning:
After using 3.2 for two days I have NO CHOICE but to downgrade to version 3.1.2 again because Eevee was SO SLOW, slower than Cycles (yes !!! Even with GPU ticked, GTX 2060 !!!) that I have decided not to tolerate such shenanigan nonsense and got back to 3.1.2 where Eevee is fast and stable again.

First congrats to rebuild the code to a shader.I have rebuild the same code to a shader years before.
However,i wonder why you dont have any references to thinfilm while rebuilding such shader.

Here is one of many reference papers,with the beetle and bubble example.
https://hal.archives-ouvertes.fr/hal-01518344/document

and way more reference examples

edit

Here a screen from my old thin film shader with the same settings from your render.I dont have loaded your shader,but i think yours was rendered with the skytexture.Btw render with AgX in CM.

1 Like

3.3 and above should convert all old nodes to new replacements.

But it doesnt work in reverse, hence why my project broke for you guys.

1 Like

I just made the shader itself, I dont typically make art or use references. Not sure what else to say.

Someone asked me for an accurate thin film, so I made it.

Besides, some shaders and effects perform differently in specific engines / renderers, so its better to leave it up to the user to test it themselves and find what works.

You are amazing, I could never do what you did.

1 Like

Thanks, I appreciate that

1 Like

Always good to have more options, nice work!

For reference, here’s another one right here on blender artists: GPU Compatible Thin-Film Interference v2.1: Glass Within Glass + Absorption - #2 by prutser

Original osl script; UPDATE v1.6: Cycles PBR thin film interference and metals

:slight_smile: