Need clarification on the example_distilling.cpp code for "reflection_roughness_texture"

example_files.zip (4.5 MB)

Please excuse this question in case I am mis-interpreting the situation.

The attached MDL shader uses a “reflectionroughness_texture: texture_2d()”.

I have been using a derivative of the example_distilling.cpp code with a “transmissive_pbr” target_model. Based on what’s actually happening, the OmniPBR-based reflection roughness is being baked into a clearcoat normal map at the “DS_INTRINSIC_DF_CUSTOM_CURVE_LAYER” check. Instead, as per the usage of that material, I would expect it to be creating a PBR-based single channel roughness texture map rather than a RGB clearcoat normal map. I may be interpreting the context incorrectly here but I did want to clarify it for my own proper understanding of the correct PBR-centric mappings.

Do you use instance or class compile for distilling?

Distilling does not know about the original semantic of the material but matches bsdf constructs to something that can be mapped to a coated metallic roughness, potentially transmissive(glass). Distilling is also “lazy” in the sense that it does not transform the graph “needlessly”. So there is not a single possible outcome and not a clear semantic for “coat” there are just 1 or 2 dielectric constructs. where 1 is forced to have the same normal as the diffuse and one can have its own normal.

So some possible outcomes are something like (tell me if you can follow my shortened syntax here):
a) diffuse and glossy forced to have the same normal

  custom_curve_layer( // a dielectric
        ggx,
        diffuse
  ))

b) diffuse potentially having a different normal

custom_curve_layer( // a dielectric
        ggx, 
        weighted_layer( //potential separate base normal added to diffuse
                  diffuse,
                  bsdf(),
                  normal ))

The distilling example does only a minimal analysis and might confuse construct b as a “coated diffuse” (ie needlessly assuming glossy has a different normal then the diffuse, rendering should be the same)
You could enhance the analysis by checking for this specific construct and checking if the normal added here is really different then the base normal.

Hello Jan,

Hello Jan

Thank you for your prompt response to my two posted questions.

Do you use instance or class compile for distilling?

I am using the example_distilling.cpp code and the “transmissive_pbr” target model. So, it is based on instance compilation.

The distilling example does only a minimal analysis and might confuse construct b as a “coated diffuse”

Let me return with a simple minded follow up. The “Orange_lead_mat.mdl” file (attached to my prior email) should be considered a generic OmniPBR material and quite straightforward. It just has a diffuse, roughness and normal map set of assigned 2D bitmap textures. It has no concept of a clearcoat layer on it.

I looked into and tested all of the “target models” provided with the current MDL SDK and only the UE4/Transmissive_PBR models generally work and don’t spit out errors when compiling this generic material. However, its output is interpreted (using the example_distilling.cpp code segments) as a clearcoat RGB normal map which clearly is not inline with what the MDL shader defines.

I also did a short review of the various target model distillation rules. However, they are well above my head right now and not something that a generic MDL SDK developer should dive into to create his own set of rules (especially since I don’t know how to review/edit the intermediate compiled MDL material to understand how the layer/node hierarchy is set up):

https://github.com/NVIDIA/MDL-SDK/blob/master/src/shaders/plugin/mdl_distiller

Let me turn the tables by returning to the same question which I had posted two years ago. At that time you said that you would make an example glTF distillation example. That’s what I would really need today as such a properly implemented version would return a roughness channel map and not so much a clearcoat normal map:

https://forums.developer.nvidia.com/t/distillation-of-mdl-over-to-a-generic-pbr-shading-model/262692/2