OSL Shaders

 

 

It is possible to create your own shaders using Open Shading Language. OSL shaders can be used to implement anything from simple texture patterns to full materials using closures. They can be placed in the plugin search path, and will then be automatically loaded like other types of shaders. Once loaded, they can be inspected, instantiated and linked in the same way as C++ shaders. The osl node provides an alternate way to load OSL shaders, which can be used to write shader code for a specific material. When setting the shader name or code, the parameters from the OSL shader automatically appear on the node to be set or linked.

A limitation is that only one output parameter is supported at the moment.

Limitations 

  • The shaders must have unique names. If the name conflicts with an existing shader, the OSL shader won't load. You should see a warning in the log in this case.
  • Multiple outputs are not supported at the moment.

More information about using OSL shaders can be found here.

An example .osl shader and .mtd file can be found here.

If you change the shader code in a text editor while rendering, you will need to "update full scene" in the Arnold RenderView.

Installation 

Just like any other third-party shader libraries, OSL shaders placed in the shader search path are automatically registered as Arnold shader nodes. The OSL shader parameters are converted to Arnold parameters. Once loaded, they can be inspected, instantiated and linked in the same way as C++ shaders.


You can render OSL shaders directly in MtoA. You must do the following: 

  • Create a folder where the OSL shader will reside. Add this line to your Maya.env file (location of the .osl shaders):  

 ARNOLD_PLUGIN_PATH=C:\solidangle\mtoadeploy\osl

  • Place the OSL shader (with .mtd metadata file) in the ARNOLD_PLUGIN_PATH folder, and they will automatically be available as shader nodes. Arnold will automatically compile the .osl file and produce a dill (.oso) file.

 

  • The shader should be visible in the Hypershade window.

.osl shader rendered with MtoA

 

 

 

  • No labels