Open shading language (OSL) lets you use a new OSL Map, an entire category of various OSL maps, and you can create your own OSL maps using development tools for use with any renderer.
Open shading language (OSL) is an open source shading language that is fairly simple to understand. It can be used in several different ways. You can use the OSL Map, which is an execution environment for OSL shaders inside of 3ds Max, and it works like any regular built-in 3ds Max map. There is also a category of pre-loaded OSL maps that you can easily use. In addition, you can use any OSL maps you download from the internet. Finally, you can creating a shader or map in OSL using our development tools. This is a much simpler method to create custom maps than developing the equivalent functionality as a 3ds Max C++ map.
OSL works in any renderer supporting the regular 3ds Max shading API (Scanline, vRay, Corona, etc.). It also works outside of renderers, anywhere in 3ds Max where a regular map is requested, such as in the Displacement modifier. It also works with renderers that support OSL natively, such as Arnold. In those cases, the execution environment inside the OSL map is not sued, instead, the OSL source code, the parameter values and shader bindings are sent to the renderer, which executes the OSL code. More renderers supporting OSL natively are appearing daily.
OSL uses "just-in-time" compilation and optimization of entire shade trees at once, as long as all the shaders in the shade tree are OSL shaders. You can mix OSL shaders and regular shaders, but the optimizations will suffer.
The OSL map has a few limitations in 3ds Max.
Limitation | Description |
---|---|
Only supports maps, not materials |
A shader written in OSL can have multiple outputs returning different data types like colors, floating point values, integers, strings, and so on. This is all supported. However, OSL also supports a special type known as a closure. You can think of closures as being materials. This is not supported. In practice, this means, the OSL map can only be used to build procedural textures (maps), and not to build materials. Therefore, the recommended workflow is to build your procedural texture maps in OSL, but connect the outputs to a standardized, well-defined, renderer-independent material such as the Physical Material. If an OSL shader you find online doesn't appear to do anything, or doesn't appear to have any outputs, it might be an OSL material. |
Only supports plain data types |
The OSL Map in 3ds Max only support the plain data types: colors, vectors, floats, integers, and strings. It does not support arrays or structs as inputs. This is rarely a problem in practice, because very few OSL shaders actually use arrays or structs as inputs. The limitation only applies to parameters, arrays and structs still work fine inside the OSL code. |
Many OSL maps now use their actual shader for viewport display, resulting in better performance and vastly improving their visual representation. To do this, run the viewport in "Realistic Mode with Maps." OSL maps that use the shader will show the notification Viewport: shader used above their parameters in the Material Editor. OSL maps that still use baking however will show Viewport: baked texture used.
Note that the following OSL shaders currently still use baked textures:
UVW
Root
Scene
Values