Bsdf_sample_function not flagging event as specular


I’ve been developing a custom material with the Mdl SDK for my personal Optix-based renderer and encountered a peculiar behavior with the bsdf_sample function.

Specifically, when working with materials that have purely specular properties (metallic-like or glass-like), the function returns an event_type flagged as BSDF_EVENT_GLOSSY, even when the PDF is significantly above 1.0. Based on my tests, it appears the only way to get a BSDF_EVENT_SPECULAR event is to use the df::specular_bsdf function in the MDL material definition.

I’ve confirmed this behavior using the Cuda df example, the MDL examples from Optix’s advanced samples, and with specular materials from the MDL library like ::vMaterials_2::Metal::Aluminum::Alluminium.

I’m reporting this as I found no explicit mention of this behavior in the documentation and I’m unsure if this is the intended behavior or an oversight.

::vMaterials_2::Metal::Aluminum::Aluminium has a roughness !=0.
MDL specifies specular interaction as

Specular reflections and transmissions implement an idealized surface in which light is reflected in the
mirror direction or is transmitted based on the index of refraction of the boundary using Snell’s law.

So for the Aluminum this is not the case and its generating BSDF_EVENT_GLOSSY by design.

Thank you, jjordan!

Yes, you are right. I forgot to mention that when I was testing the aluminum material, I was setting the roughness and smudges parameters to 0 to obtain what at least “perceptually” looks like a perfect mirror-like surface.

My doubt comes from the fact that when I was testing my custom shader in omniverse create to get a reference look when using IRay and setting the Canvas to Specular (LPE = ES.*L), the renderer was displaying the light contribution as specular and not as glossy. I just checked with the aluminum material, and with that, too, if the roughness and smudges are set to zero, the light contribution is visible in the Specular Canvas and not the Glossy one, even though the Bsdf Sample function returns a glossy event with above 1.0 probability.

Depending on the renderer, it might optimize the bsdf tree before rendering. Whether such an optimization is possible also depends on how the renderer uses MDL. Iray does “instance compile”, meaning it can often detect that a bsdf is really set to a constant roughness 0 and then substitutes it with a specular bsdf.
Omniverse RTX on the other hand uses “class compile” (for more interactive parameter tweaking) There the decision whether a bsdf is specular or glossy can not be done globally but usually depends on the parameter setting and is only known at hit, so this simple optimization is not possible.

1 Like