For these particular values the NaN can be avoided by rewriting that line as:
return alpha2 / (M_PI_F * sqr((1.0f - cos_NH2) + alpha2 * cos_NH2));
That looks like an overall improvement to…
Did the rebase to the release branch. Whoever wrote the contributor documentation did a stellar job! ❤️
Thanks for the pointer! It came just at the right time while I was looking into this :)
1e-9 is somewhat arbitrary, but my reasoning was that this is a squared distance. 1e-5 would still consider an offset of 0.001 the same point. I think a reasonable value here is dependent on scale.
Sorry, it took me a while to get back to this. Thanks for the review! All the code comments should be addressed.
Also, OSL support is currently missing. I don't see any issues with adding it…