Custom Closure Development - Lunar Surface

So I am working on a project to develop a physically realistic lunar surface shader (see Hapke Model), but it seems that I cannot do it directly with OSL as I need information on the angle of incidence, angle of emission, and the phase angle for light. From my reading (I am new to OSL), it appears OSL does not provide access to these so that the renderer can be better optimized.

What do you think the path of least resistance here is? Should I just work on it in GLSL instead? If I do develop a custom closure, is it something that the Blender/cycles community would want to make use of or is the idea here to stick with a small set of well understood/commonly used closures?

We wouldn’t add a specialized closure like this to Cycles (or Eevee for that matter), since there is a maintenance cost, and sometimes a performance cost in making the GPU kernel bigger.

You can modify the Blender code, or write your own software with a GLSL shader, or write an OSL shader that does some basic light integration without interacting with other Cycles shaders or lights.

Makes sense.

It seemed to me that implementing my own BRDF is not possible to do in OSL without adding a new closure; is this incorrect? I am still trying to wrap my head around some of the math involved.

Right, you can’t implement a BRDF in OSL that interacts with other Cycles shaders and lights.

If you don’t care about that interaction, you can of course do arbitrary computations with the given set of parameters.

Got it, I’m beginning to understand. My biggest issue was actually getting the direction/angle of incoming light relative to the surface normal. I’ve realized there are some workarounds possible by driving an input variable from some known light source position, though honestly, it feels like a bit of a hack.

Parts of the Hapke model relates to other well-known models such as the Lambertian, Oren-Nayar, and especially Lommel-Seeliger, so perhaps it’s possible to make use of an existing BSDF and then tack on my equations in a OSL script, but I’m not sure I have the level of understanding needed to do that yet.

Anyway, thanks for your help!