Thin film OSL shader

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

Attached is the shader and some sample scene.

Best regards,
Vlado
thinfilm.zip (30.8 KB)

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

What can we use it for?

I hate to use this as a reference, but here are some examples:

Best regards,
Vlado

Hehehe thank you :- )

Hehe thank’S Vlado good stuff again :slight_smile:

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

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

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

Very useful little shader :slight_smile: Thanks Vlado!

Niiiiiicee!

Stan

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 - 380 to 750 nm?

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

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…

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 :slight_smile: 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

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)










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

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 ;).