# Thin film OSL shader

**URL:** <https://forums.chaos.com/t/thin-film-osl-shader/52567>\
**Category:** Tutorials, Tips & Tricks\
**Created:** [February 5, 2015, 6:18pm UTC](https://forums.chaos.com/t/thin-film-osl-shader/52567 "2015-02-05T18:18:08Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![vlado](https://avatars.discourse-cdn.com/v4/letter/v/779978/32.png) [@vlado](https://forums.chaos.com/u/vlado)\
**Post date:** [February 5, 2015, 6:18pm UTC](https://forums.chaos.com/t/thin-film-osl-shader/52567/1 "2015-02-05T18:18:08Z")

</div>

Hello,

Someone asked for a thin film shader and I wrote one in OSL based on some code I found here:  
[http://www.gamedev.net/page/resources/\_/technical/graphics-programming-and-theory/thin-film-interference-for-computer-graphics-r2962](http://www.gamedev.net/page/resources/%5C_/technical/graphics-programming-and-theory/thin-film-interference-for-computer-graphics-r2962)

Attached is the shader and some sample scene.

Best regards,  
Vlado  
[thinfilm.zip](https://forums.chaos.com/uploads/short-url/hTw8FFrsxn9LoaS891hZvQeW9cf.zip) (30.8 KB)

 ![thinfilm.jpg](https://europe1.discourse-cdn.com/chaosprd/original/3X/1/c/1cf21be6f60bcf008b0d95f09381dab74556a702.jpeg)

---

<div class="post-metadata">

**Author:** ![Mokiki](https://dub1.discourse-cdn.com/chaosprd/user_avatar/forums.chaos.com/mokiki/32/27702_2.png) [@Mokiki](https://forums.chaos.com/u/Mokiki)\
**Post date:** [February 5, 2015, 8:00pm UTC](https://forums.chaos.com/t/thin-film-osl-shader/52567/2 "2015-02-05T20:00:13Z")

</div>

Thanks Vlado! I’m sure this will come in handy someday 🙂

---

<div class="post-metadata">

**Author:** ![Dariusz\_Makowski\_Dadal](https://avatars.discourse-cdn.com/v4/letter/d/c4cdca/32.png) [@Dariusz\_Makowski\_Dadal](https://forums.chaos.com/u/Dariusz_Makowski_Dadal)\
**Post date:** [February 5, 2015, 10:12pm UTC](https://forums.chaos.com/t/thin-film-osl-shader/52567/3 "2015-02-05T22:12:23Z")

</div>

What can we use it for?

---

<div class="post-metadata">

**Author:** ![vlado](https://avatars.discourse-cdn.com/v4/letter/v/779978/32.png) [@vlado](https://forums.chaos.com/u/vlado)\
**Post date:** [February 5, 2015, 10:54pm UTC](https://forums.chaos.com/t/thin-film-osl-shader/52567/4 "2015-02-05T22:54:17Z")

</div>

I hate to use this as a reference, but here are some examples:  
[http://blog.maxwellrender.com/tips/pushing-the-limits-of-realism-of-materials/](http://blog.maxwellrender.com/tips/pushing-the-limits-of-realism-of-materials/)

Best regards,  
Vlado

---

<div class="post-metadata">

**Author:** ![Dariusz\_Makowski\_Dadal](https://avatars.discourse-cdn.com/v4/letter/d/c4cdca/32.png) [@Dariusz\_Makowski\_Dadal](https://forums.chaos.com/u/Dariusz_Makowski_Dadal)\
**Post date:** [February 6, 2015, 1:10am UTC](https://forums.chaos.com/t/thin-film-osl-shader/52567/5 "2015-02-06T01:10:42Z")

</div>

Hehehe thank you :- )

---

<div class="post-metadata">

**Author:** ![Bigguns](https://avatars.discourse-cdn.com/v4/letter/b/7cd45c/32.png) [@Bigguns](https://forums.chaos.com/u/Bigguns)\
**Post date:** [February 6, 2015, 2:31am UTC](https://forums.chaos.com/t/thin-film-osl-shader/52567/6 "2015-02-06T02:31:45Z")

</div>

Hehe thank’S Vlado good stuff again 🙂

---

<div class="post-metadata">

**Author:** ![Art48](https://avatars.discourse-cdn.com/v4/letter/a/ad7895/32.png) [@Art48](https://forums.chaos.com/u/Art48)\
**Post date:** [February 6, 2015, 9:02am UTC](https://forums.chaos.com/t/thin-film-osl-shader/52567/7 "2015-02-06T09:02:42Z")

</div>

How would I use it? VRayBlendMtl? Just on top with \<100% Opacity?

Edit: Nevermind, missed that there is a link with an example scene.

---

<div class="post-metadata">

**Author:** ![vlado](https://avatars.discourse-cdn.com/v4/letter/v/779978/32.png) [@vlado](https://forums.chaos.com/u/vlado)\
**Post date:** [February 6, 2015, 9:08am UTC](https://forums.chaos.com/t/thin-film-osl-shader/52567/8 "2015-02-06T09:08:05Z")

</div>

> [@Art48](#):
>
> How would I use it? VRayBlendMtl? Just on top with \<100% Opacity?

In my example, I just put it as the reflection color in a VRayMtl material with Fresnel off. Using it as blend mask is also possible, though it could get a bit complicated if you want to do bump mapping just for that layer.

Best regards,  
Vlado

---

<div class="post-metadata">

**Author:** ![viscorbel](https://avatars.discourse-cdn.com/v4/letter/v/57b2e6/32.png) [@viscorbel](https://forums.chaos.com/u/viscorbel)\
**Post date:** [February 6, 2015, 10:23am UTC](https://forums.chaos.com/t/thin-film-osl-shader/52567/9 "2015-02-06T10:23:04Z")

</div>

Very useful little shader 🙂 Thanks Vlado!

---

<div class="post-metadata">

**Author:** ![3LP](https://avatars.discourse-cdn.com/v4/letter/3/5f8ce5/32.png) [@3LP](https://forums.chaos.com/u/3LP)\
**Post date:** [February 6, 2015, 12:33pm UTC](https://forums.chaos.com/t/thin-film-osl-shader/52567/10 "2015-02-06T12:33:01Z")

</div>

Niiiiiicee!

Stan

---

<div class="post-metadata">

**Author:** ![Macker](https://avatars.discourse-cdn.com/v4/letter/m/c0e974/32.png) [@Macker](https://forums.chaos.com/u/Macker)\
**Post date:** [February 10, 2015, 12:25pm UTC](https://forums.chaos.com/t/thin-film-osl-shader/52567/11 "2015-02-10T12:25:10Z")

</div>

Could this be incorporated into the standard VRay Material (maybe under an “advanced” tab)? It’s a superb addition.

Also, I assume that to keep realistic you would use [realistic wavelengths](http://en.wikipedia.org/wiki/Visible_spectrum) - 380 to 750 nm?

---

<div class="post-metadata">

**Author:** ![vlado](https://avatars.discourse-cdn.com/v4/letter/v/779978/32.png) [@vlado](https://forums.chaos.com/u/vlado)\
**Post date:** [February 10, 2015, 1:21pm UTC](https://forums.chaos.com/t/thin-film-osl-shader/52567/12 "2015-02-10T13:21:56Z")

</div>

It could be added to the VRayMtl for sure, but I’ve been accused that the UI is incredibly cluttered already. Will think about it anyways.

For the wavelengths yes, they need to be more or less realistic.

Best regards,  
Vlado

---

<div class="post-metadata">

**Author:** ![Art48](https://avatars.discourse-cdn.com/v4/letter/a/ad7895/32.png) [@Art48](https://forums.chaos.com/u/Art48)\
**Post date:** [February 10, 2015, 2:19pm UTC](https://forums.chaos.com/t/thin-film-osl-shader/52567/13 "2015-02-10T14:19:37Z")

</div>

Cluttered UI in the VRayMaterial? Oh, come on, I mean maybe there is much stuff to do but this is professional software. People shouldn’t be afraid when they see some buttons… Jeez…

I’d rather see a cluttered UI than holding back useful features. You shoul dpropably tidy up the UI in 3.2 or even 4.0 with a total overhaul, if required. But until then I see no point in holding back stuff because of cluttering…

---

<div class="post-metadata">

**Author:** ![Macker](https://avatars.discourse-cdn.com/v4/letter/m/c0e974/32.png) [@Macker](https://forums.chaos.com/u/Macker)\
**Post date:** [February 10, 2015, 3:47pm UTC](https://forums.chaos.com/t/thin-film-osl-shader/52567/14 "2015-02-10T15:47:56Z")

</div>

> [@vlado](#):
>
> It could be added to the VRayMtl for sure, but I’ve been accused that the UI is incredibly cluttered already. Will think about it anyways.
> 
> For the wavelengths yes, they need to be more or less realistic.
> 
> Best regards,  
> Vlado

I think the best way to tackle this is the same approach you took with the settings. Have all the basics on show by default, but have an advanced check box that displays additional settings that let “power users” tweak what they need to. I appreciate VRay is used by everyone from absolute amateurs through to VFX pro’s and that catering to everybody’s needs is very difficult but it seems a bit backwards to withhold updated elements of the software to cater for the few that it might scare.

---

<div class="post-metadata">

**Author:** ![vlado](https://avatars.discourse-cdn.com/v4/letter/v/779978/32.png) [@vlado](https://forums.chaos.com/u/vlado)\
**Post date:** [February 10, 2015, 3:55pm UTC](https://forums.chaos.com/t/thin-film-osl-shader/52567/15 "2015-02-10T15:55:27Z")

</div>

> [@Macker](#):
>
> I think the best way to tackle this is the same approach you took with the settings. Have all the basics on show by default, but have an advanced check box that displays additional settings that let “power users” tweak what they need to. I appreciate VRay is used by everyone from absolute amateurs through to VFX pro’s and that catering to everybody’s needs is very difficult but it seems a bit backwards to withhold updated elements of the software to cater for the few that it might scare.

Well I’m not withholding it, there’s still a way to get what you want obviously 🙂 Like I said, will think about it. You are right that if we hide some of the existing params in an advanced view, there will be space for new stuff.

Best regards,  
Vlado

---

<div class="post-metadata">

**Author:** ![\_Lele](https://dub1.discourse-cdn.com/chaosprd/user_avatar/forums.chaos.com/_lele/32/49986_2.png) [@\_Lele](https://forums.chaos.com/u/_Lele)\
**Post date:** [February 10, 2015, 4:45pm UTC](https://forums.chaos.com/t/thin-film-osl-shader/52567/16 "2015-02-10T16:45:08Z")

</div>

for all the samples: black diffuse, map in the reflection slot, GTR BRDF, 0.55 RGlossiness.  
The dome is black and white, so all the colours are from the map.  
Map parameters (fixed across the samples):  
min thickness: 200  
max thickness: 666  
rest as default.  
Changing, by 0.05 increments is the IoR, from 1.15 to 1.65 in the last example (next post)

 ![00.jpg](https://europe1.discourse-cdn.com/chaosprd/original/3X/8/1/81935b83050c8c832dc381541e48012d59b2ce84.jpeg)  
 ![01.jpg](https://europe1.discourse-cdn.com/chaosprd/original/3X/c/4/c48178c02dde74750dc00095ddc7be5d84e20685.jpeg)  
 ![02.jpg](https://europe1.discourse-cdn.com/chaosprd/original/3X/e/5/e5e054913d32807ba4be8e7a31225943d37a7ef3.jpeg)  
 ![03.jpg](https://europe1.discourse-cdn.com/chaosprd/original/3X/e/1/e1a8e0a40be8d4ef3790eb6e37d0518df31663a0.jpeg)  
 ![04.jpg](https://europe1.discourse-cdn.com/chaosprd/original/3X/b/3/b37ad3b03dfd62b8947dab644e13bf376b898fcb.jpeg)

---

<div class="post-metadata">

**Author:** ![\_Lele](https://dub1.discourse-cdn.com/chaosprd/user_avatar/forums.chaos.com/_lele/32/49986_2.png) [@\_Lele](https://forums.chaos.com/u/_Lele)\
**Post date:** [February 10, 2015, 4:46pm UTC](https://forums.chaos.com/t/thin-film-osl-shader/52567/17 "2015-02-10T16:46:45Z")

</div>

![05.jpg](https://europe1.discourse-cdn.com/chaosprd/original/3X/4/a/4ab320cb11d2807989b3418f15b35b932f39bc73.jpeg)  
 ![A.jpg](https://europe1.discourse-cdn.com/chaosprd/original/3X/6/9/691e2b84dff959b16d37689a308a8991e90d41be.jpeg)  
 ![B.jpg](https://europe1.discourse-cdn.com/chaosprd/original/3X/4/2/425a54f110610030c2bcc9bfbcf32770d5c95eaa.jpeg)  
 ![C.jpg](https://europe1.discourse-cdn.com/chaosprd/original/3X/b/8/b88f4c74d16dd117b7fce27bb224cc7662757858.jpeg)  
 ![D.jpg](https://europe1.discourse-cdn.com/chaosprd/original/3X/7/9/79746a4ed0c3b9c24ab9f6ebcf1f6816554074ea.jpeg)

---

<div class="post-metadata">

**Author:** ![\_Lele](https://dub1.discourse-cdn.com/chaosprd/user_avatar/forums.chaos.com/_lele/32/49986_2.png) [@\_Lele](https://forums.chaos.com/u/_Lele)\
**Post date:** [February 10, 2015, 4:47pm UTC](https://forums.chaos.com/t/thin-film-osl-shader/52567/18 "2015-02-10T16:47:57Z")

</div>

![E.jpg](https://europe1.discourse-cdn.com/chaosprd/original/3X/4/b/4b688fa24186f4adc5accc9ed892f5bcf7b3dc95.jpeg)  
 ![F.jpg](https://europe1.discourse-cdn.com/chaosprd/original/3X/6/e/6e7d80b5b5be489123795a21ae2b904a7e76fd2e.jpeg)

---

<div class="post-metadata">

**Author:** ![bigbossfr](https://dub1.discourse-cdn.com/chaosprd/user_avatar/forums.chaos.com/bigbossfr/32/50480_2.png) [@bigbossfr](https://forums.chaos.com/u/bigbossfr)\
**Post date:** [February 11, 2015, 2:55am UTC](https://forums.chaos.com/t/thin-film-osl-shader/52567/19 "2015-02-11T02:55:54Z")

</div>

I have this error in Maya : OSL shader error: Could not compile shader C:/Users/damien.SDC/Downloads/thinfilm/irridescence.osl (OSL to OSO)  
?

---

<div class="post-metadata">

**Author:** ![Vizioen](https://dub1.discourse-cdn.com/chaosprd/user_avatar/forums.chaos.com/vizioen/32/59355_2.png) [@Vizioen](https://forums.chaos.com/u/Vizioen)\
**Post date:** [February 11, 2015, 4:02pm UTC](https://forums.chaos.com/t/thin-film-osl-shader/52567/20 "2015-02-11T16:02:48Z")

</div>

Holy sh…everytime I think I’ve seen everything something new comes up. So the only way to achieve this effect is to use this OSL shader? It would be indeed a great addition to the VrayMTL, and ignore clutter, the more buttons the better ;).

[Next page](https://forums.chaos.com/t/thin-film-osl-shader/52567.md?page=2)
