Community
Arnold General Rendering Forum
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

OSL vs Arnold API

1 REPLY 1
SOLVED
Reply
Message 1 of 2
Shawn_Kearney1
793 Views, 1 Reply

OSL vs Arnold API

I'm needing to learn a shading language at work and I was wondering what the Arnold Shader API would offer that OSL wouldn't, aside from performance.

Tags (2)
Labels (2)
1 REPLY 1
Message 2 of 2

There are definitely differences between the C++ shader API and OSL, although they are closer together than they have been in the past.

OSL pros over C++ shaders:

  • Simpler to learn
  • More compact code; there's much less boilerplate required compared to C++ shaders
  • Automatic variable derivatives (hidden from the shader writer most of the time)
  • OSL shader networks at runtime get coalesced down into pretty efficient code
  • Straightforward to know what you can and can't do; stdosl.h and oslutil.h have all of the built-in functions and closures you can use.
  • OSL knowledge is helpful when dealing with shaders from other renderers.

C++ pros over OSL shaders:

  • You can do almost anything in a C++ shader (although from Arnold's perspective, this can be bad, making it difficult for Arnold to use alternate rendering algorithms)
  • You can trace rays directly (although again, from Arnold's perspective, this can be bad, for the same reasons)
  • Some additional functionality is available (see ai_shader_*.h header files)
  • You can leverage existing C++ code and libraries

I would say that it's best to learn OSL. We suspect the C++ shader API will be available for quite some time, but it doesn't make sense to use it unless you need it for a particular feature that isn't available in OSL. In many cases, sending us an note when you find there's something you'd like to do in OSL that would force you to use C++ instead will result in us just adding that functionality to OSL for you.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report