OSL Workflows

There are two fundamental workflows for using OSL in 3ds Max, one for using a pre-created map from the OSL category, and one for using the OSL map itself.

Using a map from the OSL category

The workflow to use a map from the OSL category is quite simple. Effectively, nothing is any different from any other 3ds Max map.
  1. Open the Slate Material Editor.
  2. In the Material/Map Browser, expand the OSL category.
  3. Select a map and drop it into the Slate Material Editor.
  4. Edit the map parameters as required.
  5. Render or use ActiveShade in a supported renderer.
All the OSL maps found in the OSL category come from the 3ds Max plugin folder. This includes approximately 100 OSL shaders; however, you can also add more.
Note: In this workflow, all shader code is hosted in files within the plugin folders, and in general they behave like any other plugin. If an updated version is dropped in the appropriate folder, the new version will be used when rendering.

Using the OSL map

The OSL map is an empty, unpopulated map with editing features. As with other maps, you simply need to drop it into the Slate Material Editor. However, editing the parameters is where this maps becomes interesting.

You can select the . . . . button to load in OSL shaders from disk that aren't necessarily in the plugins folder hierarchy, they could be anywhere. The OSL map dynamically morphs to the new parameters, spawns additional inputs and outputs as needed, and starts rendering based on the loaded OSL file.

In this workflow, the OSL code is actually loaded into the OSL map. It only uses the file when loading, and from that point on the code lives as a string parameter inside the OSL map.

Click Edit to open the OSL source editor. It's a simple, dockable syntax-coloring text editor, in which OSL code can be edited live. Press Compile Shader, or use the shortcut F7, to update the shader to whatever the latest code is, even while rendering in ActiveShade.

This turns the OSL map into a complete shader development environment. You can work interactively with the code as multiple editors can be open at once.

Edited files can be saved using Save OSL File or the shortcut Ctrl+S. However, since the code is inside the OSL map, they can also be stored in scenes or dropped in material libraries. No external dependencies to any files exist; it is completely self-contained. A scene sent to a render farm across the world will never be missing a shader - they are in the scene itself.

If you save the OSL file in one of the Plugins/OSL folders, the shader will appear automatically in the Material/Map browser.

Tip: The OSL source editor highlights matching brackets for ease of use, and you can scale the font size using Ctrl+Scroll Wheel.

OSL category maps and OSL Map are the same

The OSL maps that run the shaders preloaded in the map browser, and the OSL Map found in the General section are one and the same. As a matter of fact, dragging in something from the OSL section differs only in one aspect: the OSL Map comes in in the linked mode by default, and its file is preloaded to the appropriate OSL file.

The chain icons state indicates the "linked" mode.

When this mode is on, shaders are read from disk, from the file named on the file button.

When it is off, shader code is stored embedded inside the OSL Map itself.

The best part is that you can switch.

If you want to change an aspect of one of the preloaded shaders - you can! Just unlink it, and edit it to your hearts content. You will only be editing a copy that is living in your scene, never the original file on disk. All other shaders that are still in the linked state, will keep the plugin-like behavior. Those that are unlinked will allow local editing within that OSL Map.

If you attempt to re-link a modified map, it will revert back to the version in the file, and your edits will be discarded.

This makes simple one-off modifications, or even simple experimentation very easy. Tinker with something, if you break it, link it again, and it goes back to the way it was.