The OSL shaders used in the above examples can be found here.

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.

More information about using OSL shaders can be found here. A video that shows how to use the OSL shader can be found here.

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


  • 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.
  • The name of the output attribute is not the same as the shader code.
  • Unable to do #includes in OSL shader code.


Write the shader code here. This is just a simple text edit field for quick editing. Open the dedicated OSL Editor for dedicated script editing features.


When the code compiles, the input parameters are displayed on the Parameters tab and shaders can be linked to them in the network editor.

OSL Editor

The OSL Editor offers a user-friendly interface to edit OSL scripts. It lists all OSL shaders available in the scene and displays the code of the selected shader. The code is automatically compiled when the editor loses its focus. The result of the compilation is displayed in the console window under the text editor. In case of errors, the error message and line number (where the error happened) are listed. 

The C4D SDK does not allow to specify custom syntax highlight, therefore the editor uses the built-in python syntax highlight.

File menu


Sets the code of the selected shader using a basic template which can be a starting point of a new shader.


Loads the code from a .osl script file.


Writes the shader code to a .osl script file.


Compiles the OSL shader.

  • No labels