Source code for Oren-Nayer BRDF

Hi all, I am trying to define a custom BRDF by using the OSL language to generate rendered images of planetary surfaces. To get started, I would like to understand the source code of some BRDF functions already implemented in Blender, such as the Oren-Nayer.
I have found the source code of the “node_diffuse_bsdf” (at this link https://github.com/blender/blender/blob/main/intern/cycles/kernel/osl/shaders/node_diffuse_bsdf.osl), where the function “oren_nayar” is called, but I was not able to find the associated source code. Could you please tell me where I can find the source code for the function “oren_nayar”?
Thank you!

When a built in closure is called through OSL, all the inputs from the OSL script are mapped onto a built in closure here: blender/closures_setup.h at d76263de96f43308a16968b7f3f122e83bfa42d6 - blender - Blender Projects

From there, most/all of the shading code follows the same code path as “SVM” Cycles (SVM is what Cycles uses for shaders when not using OSL). So you’ll find most/all of the Oren Nayar code here: blender/bsdf_oren_nayar.h at main - blender - Blender Projects

1 Like