2
$\begingroup$

What language are the shaders in Blender written in? Like the Principled BSDF and the rest.

$\endgroup$

1 Answer 1

3
$\begingroup$

Most of them are written in OSL, OpenShadingLanguage, a language specifically designed for shaders. It's similar to C and can be compiled, so that it's fast.

You can find it in the Blender sources at

intern\cycles\kernel\shaders\node_principled_bsdf.osl

OSL is comparable to RSL, Renderman Shading Language and GLSL, OpenGL Shader Language.

$\endgroup$
3
  • $\begingroup$ I found some in source\blender\nodes\shader\nodes and they are written in C. Are those shaders? $\endgroup$ Commented Sep 19, 2017 at 22:59
  • $\begingroup$ Cycles is written in C++ (mainly because it's easier for custom operators). Shaders are also C++, but they have an OSL implementation when you are using OSL. $\endgroup$
    – Secrop
    Commented Sep 20, 2017 at 8:04
  • 1
    $\begingroup$ I also thought that OSL compiles to CPU code only. But the Principled BSDF is available for GPU computing as well. I'll look that up. Possibly it's available in OSL and C++. $\endgroup$ Commented Sep 20, 2017 at 10:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .