# OSL goodness in Vray

**URL:** <https://forums.chaos.com/t/osl-goodness-in-vray/54533>\
**Category:** General\
**Created:** [July 11, 2015, 6:18pm UTC](https://forums.chaos.com/t/osl-goodness-in-vray/54533 "2015-07-11T18:18:30Z")\
**Posts on this page:** 20\
**Page:** 2

<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:** [July 20, 2015, 7:28am UTC](https://forums.chaos.com/t/osl-goodness-in-vray/54533/21 "2015-07-20T07:28:39Z")

</div>

Can you post an image of the OSLTex in the attribute editor? Do you get an error message when you load the OSL?

---

<div class="post-metadata">

**Author:** ![mayanic](https://avatars.discourse-cdn.com/v4/letter/m/e495f1/32.png) [@mayanic](https://forums.chaos.com/u/mayanic)\
**Post date:** [July 20, 2015, 7:34am UTC](https://forums.chaos.com/t/osl-goodness-in-vray/54533/22 "2015-07-20T07:34:23Z")

</div>

i already posted a pics of my node editor / ae …

i just connected the osl-texture to my reflection color and plugged a osl-file in there  
but nothing happened 🙂

---

<div class="post-metadata">

**Author:** ![doark](https://avatars.discourse-cdn.com/v4/letter/d/54ee81/32.png) [@doark](https://forums.chaos.com/u/doark)\
**Post date:** [July 20, 2015, 6:55pm UTC](https://forums.chaos.com/t/osl-goodness-in-vray/54533/23 "2015-07-20T18:55:42Z")

</div>

> [@mayanic](#):
>
> i already posted a pics of my node editor / ae …
> 
> i just connected the osl-texture to my reflection color and plugged a osl-file in there  
> but nothing happened 🙂

You need to turn off the **Use Fresnel** button and change in VRayTexOSL in **Color Output** of result for **Col\_Out**. The same as this:

I hope this helps. 🙂

 ![TexOSL.png](https://europe1.discourse-cdn.com/chaosprd/original/3X/d/f/df46a3ec9ff31e65d01227ca5bca17dd96ceb1a7.png)

---

<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:** [July 21, 2015, 3:09am UTC](https://forums.chaos.com/t/osl-goodness-in-vray/54533/24 "2015-07-21T03:09:09Z")

</div>

> [@doark](#):
>
> You need to turn off the **Use Fresnel** button and change in VRayTexOSL in **Color Output** of result for **Col\_Out**. The same as this:
> 
> I hope this helps. 🙂

Right. It would probably be good to update the shader from this:

output color **Col\_Out** = color(0.5))  
{  
&nbsp;&nbsp;&nbsp;&nbsp;float thetaCos = abs(dot(-I,N));  
&nbsp;&nbsp;&nbsp;&nbsp;float red=fresnel(n[0], k[0], thetaCos);  
&nbsp;&nbsp;&nbsp;&nbsp;float green=fresnel(n[1], k[1], thetaCos);  
&nbsp;&nbsp;&nbsp;&nbsp;float blue=fresnel(n[2], k[2], thetaCos);  
**Col\_Out** =color(red, green, blue);  
}

to this:

output color **result** = color(0.5))  
{  
&nbsp;&nbsp;&nbsp;&nbsp;float thetaCos = abs(dot(-I,N));  
&nbsp;&nbsp;&nbsp;&nbsp;float red=fresnel(n[0], k[0], thetaCos);  
&nbsp;&nbsp;&nbsp;&nbsp;float green=fresnel(n[1], k[1], thetaCos);  
&nbsp;&nbsp;&nbsp;&nbsp;float blue=fresnel(n[2], k[2], thetaCos);  
**result** =color(red, green, blue);

}

that way it will work by default in Maya.

---

<div class="post-metadata">

**Author:** ![hsz](https://avatars.discourse-cdn.com/v4/letter/h/e495f1/32.png) [@hsz](https://forums.chaos.com/u/hsz)\
**Post date:** [July 21, 2015, 11:38pm UTC](https://forums.chaos.com/t/osl-goodness-in-vray/54533/25 "2015-07-21T23:38:35Z")

</div>

what about if you want to use the fabric one where will you connect it?  
thx

---

<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:** [July 22, 2015, 6:43am UTC](https://forums.chaos.com/t/osl-goodness-in-vray/54533/26 "2015-07-22T06:43:02Z")

</div>

> [@hsz](#):
>
> what about if you want to use the fabric one where will you connect it?  
> thx

just follow the instructions here:

> **[OSL Shaders](https://documentation.chaos.com/space/OSLShaders)**

---

<div class="post-metadata">

**Author:** ![hsz](https://avatars.discourse-cdn.com/v4/letter/h/e495f1/32.png) [@hsz](https://forums.chaos.com/u/hsz)\
**Post date:** [July 22, 2015, 10:11pm UTC](https://forums.chaos.com/t/osl-goodness-in-vray/54533/27 "2015-07-22T22:11:08Z")

</div>

Im getting this error, where do I set up the path?

// Error: OSL shader error: OSL include path not set

---

<div class="post-metadata">

**Author:** ![R2J2](https://dub1.discourse-cdn.com/chaosprd/user_avatar/forums.chaos.com/r2j2/32/61464_2.png) [@R2J2](https://forums.chaos.com/u/R2J2)\
**Post date:** [July 23, 2015, 2:06am UTC](https://forums.chaos.com/t/osl-goodness-in-vray/54533/28 "2015-07-23T02:06:13Z")

</div>

> [@sharktacos](#):
>
> I tweaked it so it would work in Maya

hmm I did test it in maya 2014 and an older version of VRay, nightly pre 3.2.  
do you know what it was that was causing problems in maya?  
I’ll test again later when we are all up to date here.

---

<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:** [July 24, 2015, 4:21am UTC](https://forums.chaos.com/t/osl-goodness-in-vray/54533/29 "2015-07-24T04:21:19Z")

</div>

> [@R2J2](#):
>
> hmm I did test it in maya 2014 and an older version of VRay, nightly pre 3.2.  
> do you know what it was that was causing problems in maya?  
> I’ll test again later when we are all up to date here.

“Col\_Out” needs to be called “result”

---

<div class="post-metadata">

**Author:** ![t.petrov](https://avatars.discourse-cdn.com/v4/letter/t/c68b51/32.png) [@t.petrov](https://forums.chaos.com/u/t.petrov)\
**Post date:** [July 28, 2015, 9:53am UTC](https://forums.chaos.com/t/osl-goodness-in-vray/54533/30 "2015-07-28T09:53:53Z")

</div>

@mayanic:  
Your problem is that you’re using the wrong node type - VRayPluginNodeTex:TexOSL instead of VRayTexOSL.  
If you create the correct node it will work as expected. After you change the output as mentioned by others.

---

<div class="post-metadata">

**Author:** ![oliver.sullivan](https://avatars.discourse-cdn.com/v4/letter/o/7ab992/32.png) [@oliver.sullivan](https://forums.chaos.com/u/oliver.sullivan)\
**Post date:** [July 28, 2015, 11:08am UTC](https://forums.chaos.com/t/osl-goodness-in-vray/54533/31 "2015-07-28T11:08:16Z")

</div>

> [@hsz](#):
>
> Im getting this error, where do I set up the path?
> 
> // Error: OSL shader error: OSL include path not set

Did you work out why this was happening? Same thing here, can’t find any info on it…

---

<div class="post-metadata">

**Author:** ![t.petrov](https://avatars.discourse-cdn.com/v4/letter/t/c68b51/32.png) [@t.petrov](https://forums.chaos.com/u/t.petrov)\
**Post date:** [July 28, 2015, 11:21am UTC](https://forums.chaos.com/t/osl-goodness-in-vray/54533/32 "2015-07-28T11:21:18Z")

</div>

Are you both using the installer or are you using V-Ray from a network location?

Do you have a variable like VRAY\_OSL\_PATH\_MAYA2014\_x64 set?  
It should point to the folder that contains oslutil.h and stdosl.h files.

---

<div class="post-metadata">

**Author:** ![oliver.sullivan](https://avatars.discourse-cdn.com/v4/letter/o/7ab992/32.png) [@oliver.sullivan](https://forums.chaos.com/u/oliver.sullivan)\
**Post date:** [July 28, 2015, 11:58am UTC](https://forums.chaos.com/t/osl-goodness-in-vray/54533/33 "2015-07-28T11:58:31Z")

</div>

> [@Ideas on making V-Ray's sampling UI more intuitive.](https://forums.chaos.com/t/ideas-on-making-v-rays-sampling-ui-more-intuitive/47987/7):
>
> Are you both using the installer or are you using V-Ray from a network location?
> 
> Do you have a variable like VRAY\_OSL\_PATH\_MAYA2014\_x64 set?  
> It should point to the folder that contains oslutil.h and stdosl.h files.

Network location here - that explains it..! Thx

---

<div class="post-metadata">

**Author:** ![hsz](https://avatars.discourse-cdn.com/v4/letter/h/e495f1/32.png) [@hsz](https://forums.chaos.com/u/hsz)\
**Post date:** [July 28, 2015, 2:28pm UTC](https://forums.chaos.com/t/osl-goodness-in-vray/54533/34 "2015-07-28T14:28:09Z")

</div>

Network locations as well. Thank you for your response!

---

<div class="post-metadata">

**Author:** ![mayanic](https://avatars.discourse-cdn.com/v4/letter/m/e495f1/32.png) [@mayanic](https://forums.chaos.com/u/mayanic)\
**Post date:** [August 9, 2015, 9:43pm UTC](https://forums.chaos.com/t/osl-goodness-in-vray/54533/35 "2015-08-09T21:43:27Z")

</div>

> [@Global Bump map for VrayBlend](https://forums.chaos.com/t/global-bump-map-for-vrayblend/47978/5):
>
> @mayanic:  
> Your problem is that you’re using the wrong node type - VRayPluginNodeTex:TexOSL instead of VRayTexOSL.  
> If you create the correct node it will work as expected. After you change the output as mentioned by others.

sorry for the delay  
i still don’t get the k value to show up

there is a node (Create \> V-Ray \> Create form V-Ray Plugin) called OSLTex. should i use that one?

---

<div class="post-metadata">

**Author:** ![t.petrov](https://avatars.discourse-cdn.com/v4/letter/t/c68b51/32.png) [@t.petrov](https://forums.chaos.com/u/t.petrov)\
**Post date:** [August 10, 2015, 8:47am UTC](https://forums.chaos.com/t/osl-goodness-in-vray/54533/36 "2015-08-10T08:47:04Z")

</div>

> [@Sprawl](#):
>
> there is a node (Create \> V-Ray \> Create form V-Ray Plugin) called OSLTex. should i use that one?

Nope, just used the VRayTexOSL node that is available in the HyperShade windows.  
The menu ‘Create \> V-Ray \> Create form V-Ray Plugin’ should be used to create nodes very rarely and for very special purposes.  
Creating OSL nodes is not one of them.

---

<div class="post-metadata">

**Author:** ![mayanic](https://avatars.discourse-cdn.com/v4/letter/m/e495f1/32.png) [@mayanic](https://forums.chaos.com/u/mayanic)\
**Post date:** [August 14, 2015, 6:41pm UTC](https://forums.chaos.com/t/osl-goodness-in-vray/54533/37 "2015-08-14T18:41:20Z")

</div>

haha - that was easy 🙂  
THANKS

one more question - i don’t get n1, n2 and n3 values from websites like refractive index? so one has to guess what green and blue values to choose?

---

<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:** [August 15, 2015, 1:24am UTC](https://forums.chaos.com/t/osl-goodness-in-vray/54533/38 "2015-08-15T01:24:11Z")

</div>

> [@Dariusz\_Makowski\_Dadal](#):
>
> haha - that was easy 🙂  
> THANKS
> 
> one more question - i don’t get n1, n2 and n3 values from websites like refractive index? so one has to guess what green and blue values to choose?

It should reference the website [refractiveindex.com](http://refractiveindex.com), but the process for colored metals like gold is quite complex, so I made a little tutorial about it: [http://docs.sharktacos.com/misc.php?action=help&hid=66](http://docs.sharktacos.com/misc.php?action=help&hid=66)

If you scroll down to the section **Artist Friendly Metal reflections (texture)** you’ll get an explanation of how to set it up, and why (at east as far as my non-physicist brain was able to comprehend from the info I’ve learned on these forums). Here’s the relevant part of the tutorial:

> The visible spectrum of light is measured in wavelengths. The human eye can see wavelengths from about 390 to 700 nanometers (nm). Because metals such as gold have colored reflections, we need to input the wavelength values for red, green, and blue to get the corresponding IOR values. Using this [Wavelength to RGB calculator](http://academo.org/demos/wavelength-to-colour-relationship/) we can see that red is 645, green is 510, and blue is 440. Next we go to [http://refractiveindex.info](http://refractiveindex.info), choose the measured data we want (for example gold) and enter the wavelength we got for red, green and blue. These are in nanometers (nm), but _refractiveindex.info_ wants micrometers (µm) which would be red 0.645, green is 0.51, and blue is 0.44. From this we will get the n and k values for the red, green, and blue wavelengths which we can then input into our complex\_ior shader. For example, here are the values for gold:
> 
> **n:** 0.18627, 0.75314, 1.4324  
> **k:** 3.3758, 1.9238, 1.7915

---

<div class="post-metadata">

**Author:** ![Lapaev](https://avatars.discourse-cdn.com/v4/letter/l/7ab992/32.png) [@Lapaev](https://forums.chaos.com/u/Lapaev)\
**Post date:** [August 21, 2015, 8:43pm UTC](https://forums.chaos.com/t/osl-goodness-in-vray/54533/39 "2015-08-21T20:43:40Z")

</div>

The OSL’s seem to transfer with DR on to nodes as an asset, but blackout during rendering, have anyone tried using those shaders with DR on?

---

<div class="post-metadata">

**Author:** ![Zdravko.Keremidchiev](https://dub1.discourse-cdn.com/chaosprd/user_avatar/forums.chaos.com/zdravko.keremidchiev/32/48745_2.png) [@Zdravko.Keremidchiev](https://forums.chaos.com/u/Zdravko.Keremidchiev)\
**Post date:** [August 24, 2015, 2:43pm UTC](https://forums.chaos.com/t/osl-goodness-in-vray/54533/40 "2015-08-24T14:43:44Z")

</div>

The OSL shaders transfer and render fine on our side.  
Which V-Ray for Maya version are you using? Make sure that you are using identical V-Ray version on all nodes.

[Previous page](https://forums.chaos.com/t/osl-goodness-in-vray/54533.md?page=1)

[Next page](https://forums.chaos.com/t/osl-goodness-in-vray/54533.md?page=3)
