Open Shading Language (OSL)


Open Shading Language (OSL) is an Academy Award-winning shading language, with C-like syntax, for describing materials, textures, camera and pattern generation, originally developed by Sony Pictures Imageworks (Technical Achievement, 2017). OSL was released as open source so it could be used by other visual effects and animation studios and rendering software vendors. It is a proven programming language used in many films.

OctaneRender® has implemented OSL throughout the application, with OSL Displacement, OSL textures and OSL cameras. This topic is meant to add background information to those topics.

With Octane you can create highly detailed textures using Open Shading Language. If you only have a little patience and can bear the learning curve, you have a very advanced tool for creating textures. If you are interested in programming or if you are a programmer, you can produce almost endless variety of textures using OSL. Moreover, OSL is not limited to texture creation — there are also Camera and Projection options. It is worth spending time to learn OSL if you want to push beyond standard materials and texturing.

The following information is summarized from the OSL Introduction found in the Imageworks Github. Follow the link at the end of this article for the entire resource.

OSL INTRODUCTION

OSL is similar to the C programming language. That said, OSL is very specifically designed for computer image rendering. The broad implementation of OSL across many products makes OSL very appealing and very portable, application to application, limited by implementations of each host application, of course.

If you are familiar with other shading languages, you will note that OSL has some specific concepts that differ from the others. These concepts involve a perspective derived from being physically based and supporting ray tracing and global illumination, as opposed to approximation of those features.

Units of Radiance, not Final Colors
OSL does not function like a “black box” that spits out a final color when invoked for shading a pixel. Instead, OSL’s volume and surface shaders compute the way a volume or surface actually scatters light. The result is a unit of radiance and stored in a data structure called a “closure.” The closures are very flexible and allow for evaluations of a given direction, preferred directions and can be saved for later evaluation or re-evaluation as needed. This helps OSL to conform properly to physically-based shading.

No Light Loops for Surface or Volume Shaders
No explicitly traced illumination rays are created within OSL surface shaders, as a radiance closure describing how a given surface will scatter light is evaluated by an “integrator” for specified lights which is used to determine which direction rays should be traced. Explicit rays are part of the radiance closure. This allows for the integration and sampling functions to be batched or re-ordered to increase ray coherence, ray budgets for optimal BSDF samples, bi-directional ray tracing/Metropolis light transport, and rapid evaluation of new lighting scenarios without forcing a revaluation of shaders.

No Separate Light Shaders Needed
In OSL, there are no separate surface or light shaders. Instead, all lights are treated as area lights and as emissive surfaces.

No Transparency Attribute Definition
Transparency is not explicitly defined as an attribute. Instead, it is just another light interaction included in the main radiance closure.

No Need for AOVs; Light Path Expressions are used instead
Light path expressions are used instead of AOVs; just tell the renderer what is required as an output via a light path expression.

Networks, not Monolithic Shaders
OSL shaders are actually networks, and can be dynamically connected and reconnected, without the need for subsequent compilation. This happens are render time and outputs are only pulled from downstream nodes that depend on them. This all happens in the dynamically allocated graph (DAG) — shader writers do not need to bother with these details.)

For more information on OSL and to get started on writing your own OSL shaders, follow this link.