Open Shading Language in Cycles

SVM (Shader Virtual Machine) is the default shader system but the engine also has support for OSL (Open Shading Language).

The OSL shader system was working on a basic level back in April 2011 when Cycles got released, but afterwards it was not updated as Cycles itself was very young and needed to mature still. There would have been no benefit in supporting both backends from the very beginning.

Lukas Tönne and myself updated the OSL backend in Cycles for the last couple of weeks and brought it up to speed again. We had to fix a bunch of compiler errors first, as the OSL API itself changed as well over the past year.

1) What is OSL?

OSL is an open source shader system, developed by Sony Pictures Imageworks (SPI). They developed it for their in-house renderer (which is a modified version of Arnold) and it was the exclusive shading system for big VFX films such as “Men in Black 3″ and “The Amazing Spider-Man”.

OSL is available unter the “New BSD” licence and can be integrated into commercial and free software applications.The source code is available on github.

Make sure to read the “Physical Production Shaders with OSL” presentation from the Siggraph 2012 Shading Course to get a detailed overview of OSL.

2) OSL in Cycles

You will be able to use either the SVM or the OSL backend. The reason for that: OSL is only available when you render with the CPU, a limitation of OSL itself which might change in the future, but for now it’s CPU only and therefore we keep both backends.

Every shader node in Blender is implemented in both backends, so you can switch back and forth here without worrying about your material setup.

3) Custom shaders

The real strength of OSL is the ability to write your own shaders. You can create materials, lights, displacement or patterns in the OSL language itself.

Lukas added a “OSL Script” node to Blender. You can load a .osl text file, press the compile button inside the node and it will automatically create the input and output sockets for the custom shader. Now you can use the new shader in combination with the other nodes in Blender as usual. Watch the following video to see the system in action:

These shaders can also be exchanged with other OSL Render engines. Each renderer can add custom features and closure types, but the basic shaders and functions should be available in every OSL renderer. Chaosgroup confirmed that V-Ray is going to support OSL in their next major release as well.

4) Where do I get Blender with OSL?

OSL is not included in official builds yet, if you want to give it a try you have to compile the OSL library yourselfand enable “WITH_CYCLES_OSL” in cmake. The updated OSL code is in trunk, except the OSL script node. A patch for that will be released soon.

It probably won’t make it into the upcoming Blender 2.64 release, as we still have to fix a few bugs and polish it, but 2.65 will most likely include it.

If you want to test it or even better help developing it, you can find compile instructions and ToDos here.

In the OSL language there is a function called get attribute(). In Blender 2.67 the use of this function simply crash blender. Does anyone have any more documenteatioin on how to use this? I have just been reading here:http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Nodes/OSL
and the OSL document.
The real use of such function would be to access the light/camera vectors to implement special shaders. Does anyone know any good resource for this?

[...] got a nifty little lightning/electricity shader setup from Omori-san (Ekakiya) written in OSL for Cycles. He’s also produced some awesome camera-mapped crane shots over Shibuya and Shinjuku that [...]

Cheers tons intended for discussing this effortlessly people you know very well what you will be chatting close to! Bookmarked. I implore you to furthermore go to my website Implies). We will have a very website link exchange set up between you

whereas why many people do not have a blender Turkish Turkish language Turkish language support but do not want to use your blender producers are forced to appeal to many of us, please use the Turkish language option teşekürler

I will admit that math has always been my Achilles heel. However, wriokng through the tree graph at Khan Academy (which most resembles a skill tree in an mmo game)has brought me to new heights which I never thought I would meet given the fact that I’m a very visually oriented learner. In conjunction with FINALLY building a solid foundation in math, I have been slowly reading the book called, Code: The Hidden Language of Hardware and Software. In my view, it can best be summarized as a broad view to the evolution of coding. I figure if I’m going to take programming seriously, I should at least have solid historical understanding of its roots and this book most definitely delivers! =]

I’m going to be very honest here so plaese don’t take it personally.But this was a terrible introduction to OSL and I will explain why:1. You need to provide outside resources on learning the language.2. No mathematical learning path is provided. (khan Academy is great place to learn math very quickly and for free)3. There is no explanations or examples as to why anyone should learn OSL.I think you need to spend a moment to reflect on what it took for you to become attuned’ to programming and then share what you think what would be the most efficient way for others to get to where you are today before diving right in. =]