# An assortment of OSL shaders for your perusal

**URL:** <https://forums.chaos.com/t/an-assortment-of-osl-shaders-for-your-perusal/58619>\
**Category:** General\
**Tags:** fresnel, osl\
**Created:** [May 23, 2016, 5:14pm UTC](https://forums.chaos.com/t/an-assortment-of-osl-shaders-for-your-perusal/58619 "2016-05-23T17:14:40Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rens](https://dub1.discourse-cdn.com/chaosprd/user_avatar/forums.chaos.com/rens/32/16004_2.png) [@Rens](https://forums.chaos.com/u/Rens)\
**Post date:** [May 23, 2016, 5:14pm UTC](https://forums.chaos.com/t/an-assortment-of-osl-shaders-for-your-perusal/58619/1 "2016-05-23T17:14:40Z")

</div>

Hi everybody!

I have some OSL shaders lined up for you which I’ll post here one by one as soon as the page for the shader is done.

To kick this off I present to you…  
**The Reflector!**

**Links**  
Page:

> **[OSL – Reflector – Rens Heeren](https://www.rensheeren.com/blog/osl-reflector/)**

Download:  
[http://www.rensheeren.com/osl/reflector\_tex\_v002.osl](http://www.rensheeren.com/osl/reflector%5C_tex%5C_v002.osl)  
[http://www.rensheeren.com/osl/rhfunctions.h](http://www.rensheeren.com/osl/rhfunctions.h)  
Save both in the same folder, both are needed for the shader to work. Overwrite rhfunctions.h if asked.

**Features**  
- Metals and non-metals. Uses complex Fresnel for metals and switches to non-complex for non-metals for quicker rendering.  
- Polarisation for both, should you want to play around with that.  
- Outside medium IOR, for example for objects under water.  
- Aaaand… **rough Fresnel!**

------ **EDIT** ------

I’ve moved this post [**here**](http://forums.chaosgroup.com/showthread.php?88138-An-assortment-of-OSL-shaders-for-your-perusal&p=696928#post696928)!

Here’s a list of all the shaders posted in this thread instead. 🙂

Overview page on my site [**here**](http://www.rensheeren.com/blog/osl/).

[**Reflector**](http://forums.chaosgroup.com/showthread.php?88138-An-assortment-of-OSL-shaders-for-your-perusal&p=696928#post696928)  
Advanced reflections.

[**ShowUDIM**](http://forums.chaosgroup.com/showthread.php?88138-An-assortment-of-OSL-shaders-for-your-perusal&p=693793#post693793)  
Shows where you are in UV/UDIM space! In text!

[**Merge2**](http://forums.chaosgroup.com/showthread.php?88138-An-assortment-of-OSL-shaders-for-your-perusal&p=694280#post694280)  
Merge or blend two inputs using several different operations.

[**CamMapScale**](http://forums.chaosgroup.com/showthread.php?88138-An-assortment-of-OSL-shaders-for-your-perusal&p=694446#post694446)  
A fix for the annoying CamMapPerPixel scaling feature in max.

[**MixNormalMaps**](http://forums.chaosgroup.com/showthread.php?88138-An-assortment-of-OSL-shaders-for-your-perusal&p=694492#post694492)  
Blend normal maps together… correctly.

[**ChannelSwitcher**](http://forums.chaosgroup.com/showthread.php?88138-An-assortment-of-OSL-shaders-for-your-perusal&p=694493#post694493)  
Shuffle or mix channels.

[**UVTransform**](http://forums.chaosgroup.com/showthread.php?88138-An-assortment-of-OSL-shaders-for-your-perusal&p=694763#post694763)  
Transform textures by moving the UV space around.

[**ArchGlass**](http://forums.chaosgroup.com/showthread.php?88138-An-assortment-of-OSL-shaders-for-your-perusal&p=696925#post696925)  
Simulate multi-paned window glass with only a single-sided plane object.

 ![reflector_nodescreen.JPG](https://europe1.discourse-cdn.com/chaosprd/original/3X/7/9/79eef3360c0e22c7ada9926b7adeed9b9d9faefb.jpeg)  
 ![reflector_screen.JPG](https://europe1.discourse-cdn.com/chaosprd/original/3X/9/e/9ef97162deac5cf937f3286e8034a13c7d1893e7.jpeg)  
 ![reflector_sphere1.jpg](https://europe1.discourse-cdn.com/chaosprd/original/3X/9/8/988de213003f62824f8b6c2cf6e61583d65c3654.jpeg)  
 ![reflector_sphere2.jpg](https://europe1.discourse-cdn.com/chaosprd/original/3X/0/7/07c21f3bb1e11956e6668ff844e112e230c4f95e.jpeg)  
 ![reflector_sphere1_flt.jpg](https://europe1.discourse-cdn.com/chaosprd/original/3X/8/8/8815622ae6e1baadd5235a6d21c727acb820f43e.jpeg)

---

<div class="post-metadata">

**Author:** ![Morbid\_Angel](https://dub1.discourse-cdn.com/chaosprd/user_avatar/forums.chaos.com/morbid_angel/32/21272_2.png) [@Morbid\_Angel](https://forums.chaos.com/u/Morbid_Angel)\
**Post date:** [May 23, 2016, 7:47pm UTC](https://forums.chaos.com/t/an-assortment-of-osl-shaders-for-your-perusal/58619/2 "2016-05-23T19:47:26Z")

</div>

That does look nice. I wonder why vray mtl does not have this by default?

---

<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:** [May 23, 2016, 9:15pm UTC](https://forums.chaos.com/t/an-assortment-of-osl-shaders-for-your-perusal/58619/3 "2016-05-23T21:15:58Z")

</div>

> [@VRayDomeLight primary visibility bug?](https://forums.chaos.com/t/vraydomelight-primary-visibility-bug/50978/5):
>
> That does look nice. I wonder why vray mtl does not have this by default?

Because there are only 24 hours in a day? Because we have also 100 other things to do? Like a denoiser, to take an example at random… Or ftupid Maya 2016.5 stuff… Will get to it, but in the meantime, this is exactly why you have OSL.

Keep in mind that implementing glossy Fresnel properly is not possible with OSL, it must be done in the BRDF implementation itself. You can only get an approximation with OSL.

Best regards,  
Vlado

---

<div class="post-metadata">

**Author:** ![joconnell](https://dub1.discourse-cdn.com/chaosprd/user_avatar/forums.chaos.com/joconnell/32/36063_2.png) [@joconnell](https://forums.chaos.com/u/joconnell)\
**Post date:** [May 23, 2016, 9:31pm UTC](https://forums.chaos.com/t/an-assortment-of-osl-shaders-for-your-perusal/58619/4 "2016-05-23T21:31:24Z")

</div>

Great work Rens, stuck in Clarisse land at the minute but gonna have a dig through this in July - osl seems really useful. Also just finished some film shots with Jan Volckmann - he’s great fun to be around and does really subtle comp work.

---

<div class="post-metadata">

**Author:** ![Ihno](https://avatars.discourse-cdn.com/v4/letter/i/c0e974/32.png) [@Ihno](https://forums.chaos.com/u/Ihno)\
**Post date:** [May 23, 2016, 11:20pm UTC](https://forums.chaos.com/t/an-assortment-of-osl-shaders-for-your-perusal/58619/5 "2016-05-23T23:20:20Z")

</div>

Very cool Rens.  
I’m using your mixNormalMaps map allmost every day. You really deserve your entry;)  
Looking forward to try this one and see your library grow.

---

<div class="post-metadata">

**Author:** ![Rens](https://dub1.discourse-cdn.com/chaosprd/user_avatar/forums.chaos.com/rens/32/16004_2.png) [@Rens](https://forums.chaos.com/u/Rens)\
**Post date:** [May 23, 2016, 11:33pm UTC](https://forums.chaos.com/t/an-assortment-of-osl-shaders-for-your-perusal/58619/6 "2016-05-23T23:33:33Z")

</div>

Thanks!

> [@Autodesk Generic Materials to V-Ray?](https://forums.chaos.com/t/autodesk-generic-materials-to-v-ray/50747/10):
>
> Keep in mind that implementing glossy Fresnel properly is not possible with OSL, it must be done in the BRDF implementation itself. You can only get an approximation with OSL.

True! It’s just a blend between the front facing (0 deg) reflection amount and the Fresnel curve, but it holds up surprisingly well.

> [@disabling multithreading](https://forums.chaos.com/t/disabling-multithreading/50977/7):
>
> Great work Rens, stuck in Clarisse land at the minute but gonna have a dig through this in July - osl seems really useful. Also just finished some film shots with Jan Volckmann - he’s great fun to be around and does really subtle comp work.

Hey John! How are things? This should work in Clarisse. Oh nice haha, say hi from me. : )

---

<div class="post-metadata">

**Author:** ![Rens](https://dub1.discourse-cdn.com/chaosprd/user_avatar/forums.chaos.com/rens/32/16004_2.png) [@Rens](https://forums.chaos.com/u/Rens)\
**Post date:** [May 24, 2016, 12:57am UTC](https://forums.chaos.com/t/an-assortment-of-osl-shaders-for-your-perusal/58619/7 "2016-05-24T00:57:17Z")

</div>

> [@House in Antwerp](https://forums.chaos.com/t/house-in-antwerp/50975/16):
>
> Very cool Rens.  
> I’m using your mixNormalMaps map allmost every day. You really deserve your entry;)  
> Looking forward to try this one and see your library grow.

Hehe thanks, glad to be in there. : )  
Oh yeah that reminds me, I’ll post that one here as well.

---

<div class="post-metadata">

**Author:** ![Rens](https://dub1.discourse-cdn.com/chaosprd/user_avatar/forums.chaos.com/rens/32/16004_2.png) [@Rens](https://forums.chaos.com/u/Rens)\
**Post date:** [May 24, 2016, 1:04am UTC](https://forums.chaos.com/t/an-assortment-of-osl-shaders-for-your-perusal/58619/8 "2016-05-24T01:04:47Z")

</div>

And the second one!

**ShowUDIM**  
For displaying the current UDIM tile number, very handy when working with UDIMs!

**Links**  
Page:

> **[OSL – Show UDIM – Rens Heeren](https://www.rensheeren.com/blog/osl-show-udim/)**

Download links:  
[http://www.rensheeren.com/osl/showUDIM\_tex\_v001.osl](http://www.rensheeren.com/osl/showUDIM%5C_tex%5C_v001.osl)  
[http://www.rensheeren.com/osl/rhfunctions.h](http://www.rensheeren.com/osl/rhfunctions.h)  
Save both in the same folder (right click, save as), both are needed for the shader to work. Overwrite rhfunctions.h if asked.

**Features**  
- Displays the UDIM tile number as text or as a colour value.

**How to use**  
– Create a VRay OSL Texture map.  
– Load in the downloaded .osl shader.  
– Create a VRayLightMtl.  
– Plug the OSL map into the color.  
– Disable ‘wrap texture coordinates’ in the OSL tex!

 ![showudim_rndr2.jpg](https://europe1.discourse-cdn.com/chaosprd/original/3X/2/b/2b039a79550e1369f3ed7d248352b3f85b025bd2.jpeg)  
 ![showudim_node.JPG](https://europe1.discourse-cdn.com/chaosprd/original/3X/a/5/a543c0b1d0d59bc2c39ef0c026dc4dee1cd1d157.jpeg)  
 ![showudim_ui.JPG](https://europe1.discourse-cdn.com/chaosprd/original/3X/b/a/ba8bd1bf6594f7d89b8c68f835d7745f931171ca.jpeg)  
 ![showudim_wrapdisable.JPG](https://europe1.discourse-cdn.com/chaosprd/original/3X/4/a/4a89bf828c77e3bedf921421a955364816486452.jpeg)

---

<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:** [May 24, 2016, 12:28pm UTC](https://forums.chaos.com/t/an-assortment-of-osl-shaders-for-your-perusal/58619/9 "2016-05-24T12:28:56Z")

</div>

> [@How to add Irrmap to saved Irrmap?](https://forums.chaos.com/t/how-to-add-irrmap-to-saved-irrmap/50986/3):
>
> Displays the UDIM tile number as text or as a colour value.

That’s very cool 🙂

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:** [May 24, 2016, 12:43pm UTC](https://forums.chaos.com/t/an-assortment-of-osl-shaders-for-your-perusal/58619/10 "2016-05-24T12:43:12Z")

</div>

> [@VRayDomeLight primary visibility bug?](https://forums.chaos.com/t/vraydomelight-primary-visibility-bug/50978/5):
>
> That does look nice. I wonder why vray mtl does not have this by default?

Well we have OSL. So we do have it. You can’t implement all the things into the VRayMtl. I mean sure it would make sense but as I see it it is not a high priority issue since we are able to achieve it with OSL to a certain extend.

---

<div class="post-metadata">

**Author:** ![Dave\_Wortley](https://avatars.discourse-cdn.com/v4/letter/d/ecae2f/32.png) [@Dave\_Wortley](https://forums.chaos.com/u/Dave_Wortley)\
**Post date:** [May 24, 2016, 2:40pm UTC](https://forums.chaos.com/t/an-assortment-of-osl-shaders-for-your-perusal/58619/11 "2016-05-24T14:40:23Z")

</div>

Both very cool Rens!

---

<div class="post-metadata">

**Author:** ![jasonhuang1115](https://avatars.discourse-cdn.com/v4/letter/j/a88e4f/32.png) [@jasonhuang1115](https://forums.chaos.com/u/jasonhuang1115)\
**Post date:** [May 24, 2016, 8:55pm UTC](https://forums.chaos.com/t/an-assortment-of-osl-shaders-for-your-perusal/58619/12 "2016-05-24T20:55:52Z")

</div>

Hi Rens,

Are these VRay OSL Texture maps compatible with Maya?

---

<div class="post-metadata">

**Author:** ![Morbid\_Angel](https://dub1.discourse-cdn.com/chaosprd/user_avatar/forums.chaos.com/morbid_angel/32/21272_2.png) [@Morbid\_Angel](https://forums.chaos.com/u/Morbid_Angel)\
**Post date:** [May 24, 2016, 11:07pm UTC](https://forums.chaos.com/t/an-assortment-of-osl-shaders-for-your-perusal/58619/13 "2016-05-24T23:07:28Z")

</div>

yes they should be compatible 🙂 I haven’t checked these, but the iridescence.osl worked.

---

<div class="post-metadata">

**Author:** ![jasonhuang1115](https://avatars.discourse-cdn.com/v4/letter/j/a88e4f/32.png) [@jasonhuang1115](https://forums.chaos.com/u/jasonhuang1115)\
**Post date:** [May 24, 2016, 11:42pm UTC](https://forums.chaos.com/t/an-assortment-of-osl-shaders-for-your-perusal/58619/14 "2016-05-24T23:42:52Z")

</div>

> [@Polyline/spline-like drawing in 3DSmax as in Autocad/SketchUp](https://forums.chaos.com/t/polyline-spline-like-drawing-in-3dsmax-as-in-autocad-sketchup/50983/2):
>
> yes they should be compatible 🙂 I haven’t checked these, but the iridescence.osl worked.

Sweet…thanks Dmitry.

---

<div class="post-metadata">

**Author:** ![Rens](https://dub1.discourse-cdn.com/chaosprd/user_avatar/forums.chaos.com/rens/32/16004_2.png) [@Rens](https://forums.chaos.com/u/Rens)\
**Post date:** [May 25, 2016, 12:12am UTC](https://forums.chaos.com/t/an-assortment-of-osl-shaders-for-your-perusal/58619/15 "2016-05-25T00:12:57Z")

</div>

> [@Replace lights with VRay Lights](https://forums.chaos.com/t/replace-lights-with-vray-lights/50993/2):
>
> That’s very cool 🙂

Thanks! With this it shouldn’t be hard to make some 8-bit adventure game in activeshade mode. No need for a boss key hehehe : )

> [@Mihail.Djurev](#):
>
> Both very cool Rens!

Thanks! I have a couple more ready to go in the next few days!

> [@Light/surface flicker](https://forums.chaos.com/t/light-surface-flicker/50991/5):
>
> Are these VRay OSL Texture maps compatible with Maya?

I haven’t tested it yet, but if thin film works in Maya as Dmitry said then this should hopefully work as well. Texture/colour inputs are different in Max and other applications. The reflector shader just checks to see if VRay is used and then switches the input type, so if it works in Maya with VRay it should work everywhere. : )

---

<div class="post-metadata">

**Author:** ![Rens](https://dub1.discourse-cdn.com/chaosprd/user_avatar/forums.chaos.com/rens/32/16004_2.png) [@Rens](https://forums.chaos.com/u/Rens)\
**Post date:** [May 26, 2016, 3:21pm UTC](https://forums.chaos.com/t/an-assortment-of-osl-shaders-for-your-perusal/58619/16 "2016-05-26T15:21:20Z")

</div>

And the third!

**Merge2**  
Merge two inputs using Nuke-style operations.

**Links**  
Page:

> **[OSL – Merge2 – Rens Heeren](https://www.rensheeren.com/blog/osl-merge2/)**

Download link:  
[http://www.rensheeren.com/osl/merge2\_tex\_v001.osl](http://www.rensheeren.com/osl/merge2%5C_tex%5C_v001.osl)

**Features**  
- Merge two inputs.  
- Takes alpha channels into account.

**How to use**  
– Create a VRay OSL Texture map.  
– Load in the downloaded .osl shader.  
– Connect the inputs to merge.  
– Set the mode.

 ![merge2_node.JPG](https://europe1.discourse-cdn.com/chaosprd/original/3X/a/c/ac9b4b657c1047e647236861576612d5b7fc8d37.jpeg)  
 ![merge2_ui.JPG](https://europe1.discourse-cdn.com/chaosprd/original/3X/c/6/c6fb06821717ff2600e9fa9fc4b1a083b5febd5c.jpeg)  
 ![merge2_rndr1.jpg](https://europe1.discourse-cdn.com/chaosprd/original/3X/b/c/bc6e496f6fe8ea5b6b4dbd105913780a25ab4e27.jpeg)

---

<div class="post-metadata">

**Author:** ![Rens](https://dub1.discourse-cdn.com/chaosprd/user_avatar/forums.chaos.com/rens/32/16004_2.png) [@Rens](https://forums.chaos.com/u/Rens)\
**Post date:** [May 28, 2016, 4:24am UTC](https://forums.chaos.com/t/an-assortment-of-osl-shaders-for-your-perusal/58619/17 "2016-05-28T04:24:57Z")

</div>

I think you’ll like this one. 🙂

**CamMapScale**  
Scales an image to the original image ratio when using Camera Map Per Pixel, instead of the annoying ‘feature’ where it scales the image to the render output size.  
So if you have a square image, you can project a square image!

**Links**  
Page:

> **[OSL – CamMapScale – Rens Heeren](https://www.rensheeren.com/blog/osl-cammapscale/)**

Download link:  
[http://www.rensheeren.com/osl/camMapScale\_tex\_v001.osl](http://www.rensheeren.com/osl/camMapScale%5C_tex%5C_v001.osl)

**Features**  
– Scales the input image back to its original aspect ratio when using Camera Map Per Pixel.

**How to use**  
– Create a VRay OSL Texture map.  
– Load in the download OSL shader.  
– Plug in the map and set your render and map resolution. The shader will scale the image back to the map resolution.  
– Make sure ‘wrap texture coordinates’ (General tab) is **disabled** in the OSL shader!

 ![cammapscale_rndr.jpg](https://europe1.discourse-cdn.com/chaosprd/original/3X/7/3/73348d7492955969db60a5d849b3b0356585746f.jpeg)  
 ![cammapscale_node.JPG](https://europe1.discourse-cdn.com/chaosprd/original/3X/0/1/0193d089f2a1bce2841db4bc5757802631dfc76a.jpeg)  
 ![cammapscale_ui.JPG](https://europe1.discourse-cdn.com/chaosprd/original/3X/9/4/94b421ba358d5334956c251f3571b5173d85c33b.jpeg)

---

<div class="post-metadata">

**Author:** ![sharktacos](https://avatars.discourse-cdn.com/v4/letter/s/f0a364/32.png) [@sharktacos](https://forums.chaos.com/u/sharktacos)\
**Post date:** [May 28, 2016, 8:16pm UTC](https://forums.chaos.com/t/an-assortment-of-osl-shaders-for-your-perusal/58619/18 "2016-05-28T20:16:52Z")

</div>

This is great Rens! So glad I found it this thread!

Vlado, would it be possible to make a forum board for OSL? Typing “OSL” in the search results in _“Sorry - no matches. Please try some different terms.”_ It would be awesome to have a central place where we can all share this OSL goodness (and a place where we could find it too!). I’d suggest that the OSL board be for all applications, not just Max or Maya.

---

<div class="post-metadata">

**Author:** ![sharktacos](https://avatars.discourse-cdn.com/v4/letter/s/f0a364/32.png) [@sharktacos](https://forums.chaos.com/u/sharktacos)\
**Post date:** [May 28, 2016, 8:23pm UTC](https://forums.chaos.com/t/an-assortment-of-osl-shaders-for-your-perusal/58619/19 "2016-05-28T20:23:18Z")

</div>

> [@House in Antwerp](https://forums.chaos.com/t/house-in-antwerp/50975/16):
>
> Very cool Rens.  
> I’m using your mixNormalMaps map allmost every day. You really deserve your entry;)  
> Looking forward to try this one and see your library grow.

Has this been posted yet? Maybe I missed it…

---

<div class="post-metadata">

**Author:** ![Ihno](https://avatars.discourse-cdn.com/v4/letter/i/c0e974/32.png) [@Ihno](https://forums.chaos.com/u/Ihno)\
**Post date:** [May 28, 2016, 8:53pm UTC](https://forums.chaos.com/t/an-assortment-of-osl-shaders-for-your-perusal/58619/20 "2016-05-28T20:53:25Z")

</div>

@sharktacos  
You can find it here:  
[http://forums.chaosgroup.com/showthread.php?86115-Mixing-Normal-Maps&highlight=mixing+normal+maps](http://forums.chaosgroup.com/showthread.php?86115-Mixing-Normal-Maps&highlight=mixing+normal+maps)

@Rens:  
Cool stuff, keep it up. 😄

[Next page](https://forums.chaos.com/t/an-assortment-of-osl-shaders-for-your-perusal/58619.md?page=2)
