QuiltiX icon indicating copy to clipboard operation
QuiltiX copied to clipboard

Suggestion: Hide / template nodegraph implementations

Open kwokcb opened this issue 5 months ago • 1 comments

Issue

If a file has a nodegraph definition included in the file it is loaded in and is editable. This can be "dangerous" as the graph implements a definition so it can cause instances to mismatch with the definition.

Here is the reference OpenPBR implementation that has the definition included which folks are using to test this new shading model. Embedding definitions with instances is also one possible suggested MaterialX mechanism to use custom definitions. ( Note that this renders properly with OpenUSD HDStorm delegate )

<?xml version="1.0"?>
<materialx version="1.38">
  <!--
    OpenPBR Surface node definition
  -->
  <nodedef name="ND_open_pbr_surface_surfaceshader" node="open_pbr_surface" nodegroup="pbr" version="0.2" isdefaultversion="true"
           doc="OpenPBR Surface Shading Model">
    <input name="base_weight" type="float" value="1.0" uimin="0.0" uimax="1.0" uiname="Base Weight" uifolder="Base"
           doc="Multiplier on the intensity of the reflection from the diffuse and metallic base." />
    <input name="base_color" type="color3" value="0.8, 0.8, 0.8" uimin="0,0,0" uimax="1,1,1" uiname="Base Color" uifolder="Base"
           doc="Color of the reflection from the diffuse and metallic base." />
    <input name="base_roughness" type="float" value="0.0" uimin="0.0" uimax="1.0" uiname="Base Roughness" uifolder="Base" uiadvanced="true"
           doc="Roughness of the diffuse reflection. Higher values cause the surface to appear flatter." />
    <input name="base_metalness" type="float" value="0.0" uimin="0.0" uimax="1.0" uiname="Base Metalness" uifolder="Base"
           doc="Specifies how metallic the base material appears (dials the base from pure dielectric to pure metal)." />
    <input name="specular_weight" type="float" value="1.0" uimin="0.0" uimax="1.0" uiname="Specular Weight" uifolder="Specular"
           doc="Multiplier on the intensity of the specular reflection." />
    <input name="specular_color" type="color3" value="1, 1, 1" uimin="0,0,0" uimax="1,1,1" uiname="Specular Color" uifolder="Specular"
           doc="Color of the specular reflection (controls the physical edge-tint for metals, and a non-physical overall tint for dielectrics)." />
    <input name="specular_roughness" type="float" value="0.3" uimin="0.0" uimax="1.0" uiname="Specular Roughness" uifolder="Specular"
           doc="The roughness of the specular reflection. Lower numbers produce sharper reflections, higher numbers produce blurrier reflections." />
    <input name="specular_ior" type="float" value="1.5" uimin="0.0" uisoftmin="1.0" uisoftmax="3.0" uiname="Specular Index of Refraction" uifolder="Specular"
           doc="Index of refraction of the dielectric base." />
    <input name="specular_ior_level" type="float" value="0.5" uimin="0.0" uimax="1.0" uiname="Specular IOR Level" uifolder="Specular"
           doc="Modulates the dielectric reflectivity at normal incidence between zero and double the original." />
    <input name="specular_anisotropy" type="float" value="0.0" uimin="0.0" uimax="1.0" uiname="Specular Anisotropy" uifolder="Specular" uiadvanced="true"
           doc="The directional bias of the roughness of the metal/dielectric base, resulting in increasingly stretched highlights along the tangent direction." />
    <input name="specular_rotation" type="float" value="0.0" uimin="0.0" uimax="1.0" uiname="Specular Rotation" uifolder="Specular" uiadvanced="true"
           doc="Rotation of the axis of specular roughness anisotropy around the surface normal." />
    <input name="transmission_weight" type="float" value="0.0" uimin="0.0" uimax="1.0" uiname="Transmission Weight" uifolder="Transmission" uiadvanced="true"
           doc="Mixture weight between the transparent and opaque dielectric base. The greater the value the more transparent the material." />
    <input name="transmission_color" type="color3" value="1, 1, 1" uimin="0,0,0" uimax="1,1,1" uiname="Transmission Color" uifolder="Transmission" uiadvanced="true"
           doc="Controls color of the transparent base due to Beer's law volumetric absorption under the surface (reverts to a non-physical tint when transmission_depth is zero)." />
    <input name="transmission_depth" type="float" value="0.0" uimin="0.0" uisoftmax="1.0" uiname="Transmission Depth" uifolder="Transmission" uiadvanced="true"
           doc="Specifies the distance light travels inside the transparent base before it becomes exactly the transmission_color according to Beer's law." />
    <input name="transmission_scatter" type="color3" value="0, 0, 0" uimin="0,0,0" uimax="1,1,1" uiname="Transmission Scatter" uifolder="Transmission" uiadvanced="true"
           doc="Controls the color of light volumetrically scattered inside the transparent base. Suitable for materials with visually significant scattering such as honey, fruit juice, murky water, opalescent glass, or milky glass." />
    <input name="transmission_scatter_anisotropy" type="float" value="0.0" uimin="0.0" uimax="1.0" uiname="Transmission Anisotropy" uifolder="Transmission" uiadvanced="true"
           doc="The amount of directional bias, or anisotropy, of the volumetric scattering in the transparent base." />
    <input name="transmission_dispersion" type="float" value="0.0" uimin="0.0" uisoftmax="100.0" uiname="Transmission Dispersion" uifolder="Transmission" uiadvanced="true"
           doc="Dispersion amount, describing how much the dielectric index of refraction varies across wavelengths." />
    <input name="subsurface_weight" type="float" value="0" uimin="0.0" uimax="1.0" uiname="Subsurface" uifolder="Subsurface Weight" uiadvanced="true"
           doc="Mixture weight which dials the opaque dielectric base between diffuse reflection and subsurface scattering. A value of 1.0 indicates full subsurface scattering and a value 0 for diffuse reflection only." />
    <input name="subsurface_color" type="color3" value="0.8, 0.8, 0.8" uimin="0,0,0" uimax="1,1,1" uiname="Subsurface Color" uifolder="Subsurface" uiadvanced="true"
           doc="The overall reflected color of the subsurface scattering effect." />
    <input name="subsurface_radius" type="float" value="1.0" uimin="0.0" uisoftmax="1.0" uiname="Subsurface Radius" uifolder="Subsurface" uiadvanced="true"
           doc="Length scale of the subsurface diffusion blur profile on the surface." />
    <input name="subsurface_radius_scale" type="color3" value="1.0, 0.5, 0.25" uimin="0,0,0" uimax="1,1,1" uiname="Subsurface Radius Scale" uifolder="Subsurface" uiadvanced="true"
           doc="RGB multiplier to subsurface_radius, giving the per-channel diffusion blur profile size." />
    <input name="subsurface_anisotropy" type="float" value="0.0" uimin="-1.0" uimax="1.0" uiname="Subsurface Anisotropy" uifolder="Subsurface" uiadvanced="true"
           doc="Controls the phase-function of subsurface scattering, where zero scatters light evenly, positive values scatter forward, and negative values scatter backward." />
    <input name="fuzz_weight" type="float" value="0.0" uimin="0.0" uimax="1.0" uiname="Fuzz Weight" uifolder="Fuzz" uiadvanced="true"
           doc="The weight of a fuzz layer that can be used to approximate microfibers, for fabrics such as velvet and satin as well as dust grains." />
    <input name="fuzz_color" type="color3" value="1, 1, 1" uimin="0,0,0" uimax="1,1,1" uiname="Fuzz Color" uifolder="Fuzz" uiadvanced="true"
           doc="The color of the fuzz layer." />
    <input name="fuzz_roughness" type="float" value="0.5" uimin="0.0" uimax="1.0" uiname="Fuzz Roughness" uifolder="Fuzz" uiadvanced="true"
           doc="The roughness of the fuzz layer." />
    <input name="coat_weight" type="float" value="0.0" uimin="0.0" uimax="1.0" uiname="Coat Weight" uifolder="Coat"
           doc="The weight of a reflective clear-coat layer on top of the material. Use for materials such as car paint or an oily layer." />
    <input name="coat_color" type="color3" value="1, 1, 1" uimin="0,0,0" uimax="1,1,1" uiname="Coat Color" uifolder="Coat"
           doc="The color of the clear-coat layer's transparency, due to absorption in the coat." />
    <input name="coat_roughness" type="float" value="0.0" uimin="0.0" uimax="1.0" uiname="Coat Roughness" uifolder="Coat"
           doc="The roughness of the clear-coat reflections. The lower the value, the sharper the reflection." />
    <input name="coat_anisotropy" type="float" value="0.0" uimin="0.0" uimax="1.0" uiname="Coat Anisotropy" uifolder="Coat" uiadvanced="true"
           doc="The directional bias of the roughness of the clear-coat layer, resulting in increasingly stretched highlights along the coat tangent direction." />
    <input name="coat_rotation" type="float" value="0.0" uimin="0.0" uimax="1.0" uiname="Coat Rotation" uifolder="Coat" uiadvanced="true"
           doc="Rotation of the axis of clear-coat roughness anisotropy around the coat normal." />
    <input name="coat_ior" type="float" value="1.6" uimin="0.0" uisoftmin="1.0" uisoftmax="3.0" uiname="Coat Index of Refraction" uifolder="Coat"
           doc="The index of refraction of the clear-coat layer." />
    <input name="coat_ior_level" type="float" value="0.5" uimin="0.0" uimax="1.0" uiname="Coat IOR Level" uifolder="Specular"
           doc="Modulates the clear-coat reflectivity at normal incidence between zero and double the original." />
    <input name="thin_film_thickness" type="float" value="0" uimin="0.0" uisoftmax="2000.0" uiname="Thin Film Thickness" uifolder="Thin Film" uiadvanced="true"
           doc="The thickness of the thin film layer on the base (in nanometers). Use for materials such as multi-tone car paint or soap bubbles." />
    <input name="thin_film_ior" type="float" value="1.5" uimin="0.0" uisoftmin="1.0" uisoftmax="3.0" uiname="Thin Film Index of Refraction" uifolder="Thin Film" uiadvanced="true"
           doc="The index of refraction of the thin-film." />
    <input name="emission_luminance" type="float" value="0.0" uimin="0.0" uisoftmax="1000.0" uiname="Emission Luminance" uifolder="Emission"
           doc="The amount of emitted light, as a luminance in nits." />
    <input name="emission_color" type="color3" value="1, 1, 1" uimin="0,0,0" uimax="1,1,1" uiname="Emission Color" uifolder="Emission"
           doc="The color of the emitted light." />
    <input name="geometry_opacity" type="color3" value="1, 1, 1" uimin="0,0,0" uimax="1,1,1" uiname="Opacity" uifolder="Geometry"
           doc="The opacity of the entire material." />
    <input name="geometry_thin_walled" type="boolean" value="false" uiname="Thin Walled" uifolder="Geometry" uiadvanced="true"
           doc="If true the surface is double-sided and represents an infinitesimally thin shell. Suitable for extremely geometrically thin objects such as leaves or paper." />
    <input name="geometry_normal" type="vector3" defaultgeomprop="Nworld" uiname="Normal" uifolder="Geometry"
           doc="Input geometric normal" />
    <input name="geometry_coat_normal" type="vector3" defaultgeomprop="Nworld" uiname="Coat Normal" uifolder="Geometry"
           doc="Input normal for clear-coat layer" />
    <input name="geometry_tangent" type="vector3" defaultgeomprop="Tworld" uiname="Tangent Input" uifolder="Geometry"
           doc="Input geometric tangent" />
    <output name="out" type="surfaceshader" />
  </nodedef>

  <!--
    OpenPBR Surface graph definition
  -->
  <nodegraph name="NG_open_pbr_surface_surfaceshader" nodedef="ND_open_pbr_surface_surfaceshader">

    <!-- Roughness influence by coat-->
    <!-- Calculate main specular roughness -->
    <multiply name="coat_affect_roughness_multiply1" type="float">
      <input name="in1" type="float" value="1.0" />
      <input name="in2" type="float" interfacename="coat_weight" />
    </multiply>
    <multiply name="coat_affect_roughness_multiply2" type="float">
      <input name="in1" type="float" nodename="coat_affect_roughness_multiply1" />
      <input name="in2" type="float" interfacename="coat_roughness" />
    </multiply>
    <mix name="coat_affected_roughness" type="float">
      <input name="fg" type="float" value="1.0" />
      <input name="bg" type="float" interfacename="specular_roughness" />
      <input name="mix" type="float" nodename="coat_affect_roughness_multiply2" />
    </mix>
    <roughness_anisotropy name="main_roughness" type="vector2">
      <input name="roughness" type="float" nodename="coat_affected_roughness" />
      <input name="anisotropy" type="float" interfacename="specular_anisotropy" />
    </roughness_anisotropy>
    <!-- Calculate transmission roughness -->
    <clamp name="transmission_roughness_clamped" type="float">
      <input name="in" type="float" interfacename="specular_roughness" />
    </clamp>
    <mix name="coat_affected_transmission_roughness" type="float">
      <input name="fg" type="float" value="1.0" />
      <input name="bg" type="float" nodename="transmission_roughness_clamped" />
      <input name="mix" type="float" nodename="coat_affect_roughness_multiply2" />
    </mix>
    <roughness_anisotropy name="transmission_roughness" type="vector2">
      <input name="roughness" type="float" nodename="coat_affected_transmission_roughness" />
      <input name="anisotropy" type="float" interfacename="specular_anisotropy" />
    </roughness_anisotropy>

    <!-- Tangent rotation -->
    <multiply name="tangent_rotate_degree" type="float">
      <input name="in1" type="float" interfacename="specular_rotation" />
      <input name="in2" type="float" value="360" />
    </multiply>
    <rotate3d name="tangent_rotate" type="vector3">
      <input name="in" type="vector3" interfacename="geometry_tangent" />
      <input name="amount" type="float" nodename="tangent_rotate_degree" />
      <input name="axis" type="vector3" interfacename="geometry_normal" />
    </rotate3d>
    <normalize name="tangent_rotate_normalize" type="vector3">
      <input name="in" type="vector3" nodename="tangent_rotate" />
    </normalize>
    <ifgreater name="main_tangent" type="vector3">
      <input name="value1" type="float" interfacename="specular_anisotropy" />
      <input name="value2" type="float" value="0.0" />
      <input name="in1" type="vector3" nodename="tangent_rotate_normalize" />
      <input name="in2" type="vector3" interfacename="geometry_tangent" />
    </ifgreater>

    <!-- Coat tangent rotation -->
    <multiply name="coat_tangent_rotate_degree" type="float">
      <input name="in1" type="float" interfacename="coat_rotation" />
      <input name="in2" type="float" value="360" />
    </multiply>
    <rotate3d name="coat_tangent_rotate" type="vector3">
      <input name="in" type="vector3" interfacename="geometry_tangent" />
      <input name="amount" type="float" nodename="coat_tangent_rotate_degree" />
      <input name="axis" type="vector3" interfacename="geometry_coat_normal" />
    </rotate3d>
    <normalize name="coat_tangent_rotate_normalize" type="vector3">
      <input name="in" type="vector3" nodename="coat_tangent_rotate" />
    </normalize>
    <ifgreater name="coat_tangent" type="vector3">
      <input name="value1" type="float" interfacename="coat_anisotropy" />
      <input name="value2" type="float" value="0.0" />
      <input name="in1" type="vector3" nodename="coat_tangent_rotate_normalize" />
      <input name="in2" type="vector3" interfacename="geometry_tangent" />
    </ifgreater>

    <!-- Subsurface (thin-walled) -->
    <max name="subsurface_color_nonnegative" type="color3">
      <input name="in1" type="color3" interfacename="subsurface_color" />
      <input name="in2" type="float" value="0.0" />
    </max>
    <oren_nayar_diffuse_bsdf name="subsurface_thin_walled_reflection_bsdf" type="BSDF">
      <input name="weight" type="float" value="1.0" />
      <input name="color" type="color3" nodename="subsurface_color_nonnegative" />
      <input name="roughness" type="float" interfacename="base_roughness" />
      <input name="normal" type="vector3" interfacename="geometry_normal" />
    </oren_nayar_diffuse_bsdf>
    <subtract name="one_minus_subsurface_anisotropy" type="float">
      <input name="in1" type="float" value="1.0" />
      <input name="in2" type="float" interfacename="subsurface_anisotropy" />
    </subtract>
    <multiply name="subsurface_thin_walled_brdf_factor" type="color3">
      <input name="in1" type="color3" interfacename="subsurface_color" />
      <input name="in2" type="float" nodename="one_minus_subsurface_anisotropy" />
    </multiply>
    <multiply name="subsurface_thin_walled_reflection" type="BSDF">
      <input name="in1" type="BSDF" nodename="subsurface_thin_walled_reflection_bsdf" />
      <input name="in2" type="color3" nodename="subsurface_thin_walled_brdf_factor" />
    </multiply>
    <translucent_bsdf name="subsurface_thin_walled_transmission_bsdf" type="BSDF">
      <input name="weight" type="float" value="1.0" />
      <input name="color" type="color3" nodename="subsurface_color_nonnegative" />
      <input name="normal" type="vector3" interfacename="geometry_normal" />
    </translucent_bsdf>
    <add name="one_plus_subsurface_anisotropy" type="float">
      <input name="in1" type="float" value="1.0" />
      <input name="in2" type="float" interfacename="subsurface_anisotropy" />
    </add>
    <multiply name="subsurface_thin_walled_btdf_factor" type="color3">
      <input name="in1" type="color3" interfacename="subsurface_color" />
      <input name="in2" type="float" nodename="one_plus_subsurface_anisotropy" />
    </multiply>
    <multiply name="subsurface_thin_walled_transmission" type="BSDF">
      <input name="in1" type="BSDF" nodename="subsurface_thin_walled_transmission_bsdf" />
      <input name="in2" type="color3" nodename="subsurface_thin_walled_btdf_factor" />
    </multiply>
    <mix name="subsurface_thin_walled" type="BSDF">
      <input name="fg" type="BSDF" nodename="subsurface_thin_walled_reflection" />
      <input name="bg" type="BSDF" nodename="subsurface_thin_walled_transmission" />
      <input name="mix" type="float" value="0.5" />
    </mix>

    <!-- Subsurface (non-thin-walled) -->
    <convert name="subsurface_radius_vector" type="vector3">
      <input name="in" type="color3" interfacename="subsurface_radius_scale" />
    </convert>
    <multiply name="subsurface_radius_scaled" type="vector3">
      <input name="in1" type="vector3" nodename="subsurface_radius_vector" />
      <input name="in2" type="float" interfacename="subsurface_radius" />
    </multiply>
    <subsurface_bsdf name="subsurface_bsdf" type="BSDF">
      <input name="weight" type="float" value="1.0" />
      <input name="color" type="color3" nodename="subsurface_color_nonnegative" />
      <input name="radius" type="vector3" nodename="subsurface_radius_scaled" />
      <input name="anisotropy" type="float" interfacename="subsurface_anisotropy" />
      <input name="normal" type="vector3" interfacename="geometry_normal" />
    </subsurface_bsdf>

    <!-- Opaque Dielectric Base -->
    <max name="base_color_nonnegative" type="color3">
      <input name="in1" type="color3" interfacename="base_color" />
      <input name="in2" type="float" value="0.0" />
    </max>
    <oren_nayar_diffuse_bsdf name="diffuse_bsdf" type="BSDF">
      <input name="weight" type="float" interfacename="base_weight" />
      <input name="color" type="color3" nodename="base_color_nonnegative" />
      <input name="roughness" type="float" interfacename="base_roughness" />
      <input name="normal" type="vector3" interfacename="geometry_normal" />
    </oren_nayar_diffuse_bsdf>
    <convert name="subsurface_selector" type="float">
      <input name="in" type="boolean" interfacename="geometry_thin_walled" />
    </convert>
    <mix name="selected_subsurface" type="BSDF">
      <input name="fg" type="BSDF" nodename="subsurface_thin_walled" />
      <input name="bg" type="BSDF" nodename="subsurface_bsdf" />
      <input name="mix" type="float" nodename="subsurface_selector" />
    </mix>
    <mix name="opaque_base" type="BSDF">
      <input name="fg" type="BSDF" nodename="selected_subsurface" />
      <input name="bg" type="BSDF" nodename="diffuse_bsdf" />
      <input name="mix" type="float" interfacename="subsurface_weight" />
    </mix>

    <!-- Dielectric Base -->
    <divide name="specular_to_coat_ior_ratio" type="float">
      <input name="in1" type="float" interfacename="specular_ior" />
      <input name="in2" type="float" nodename="modulated_coat_ior" />
    </divide>
    <subtract name="specular_ior_minus_one" type="float">
      <input name="in1" type="float" nodename="specular_to_coat_ior_ratio" />
      <input name="in2" type="float" value="1.0" />
    </subtract>
    <add name="specular_ior_plus_one" type="float">
      <input name="in1" type="float" value="1.0" />
      <input name="in2" type="float" nodename="specular_to_coat_ior_ratio" />
    </add>
    <divide name="specular_ior_to_F0_sqrt" type="float">
      <input name="in1" type="float" nodename="specular_ior_minus_one" />
      <input name="in2" type="float" nodename="specular_ior_plus_one" />
    </divide>
    <multiply name="specular_ior_to_F0" type="float">
      <input name="in1" type="float" nodename="specular_ior_to_F0_sqrt" />
      <input name="in2" type="float" nodename="specular_ior_to_F0_sqrt" />
    </multiply>
    <divide name="half_over_specular_F0" type="float">
      <input name="in1" type="float" value="0.5" />
      <input name="in2" type="float" nodename="specular_ior_to_F0" />
    </divide>
    <min name="specular_ior_level_upper_bound" type="float">
      <input name="in1" type="float" value="1.0" />
      <input name="in2" type="float" nodename="half_over_specular_F0" />
    </min>
    <clamp name="specular_ior_level_clamped" type="float">
      <input name="in" type="float" interfacename="specular_ior_level" />
      <input name="low" type="float" value="0.0" />
      <input name="high" type="float" nodename="specular_ior_level_upper_bound" />
    </clamp>
    <multiply name="modulated_specular_reflectivity1" type="float">
      <input name="in1" type="float" nodename="specular_ior_level_clamped" />
      <input name="in2" type="float" nodename="specular_ior_to_F0" />
    </multiply>
    <multiply name="modulated_specular_reflectivity2" type="float">
      <input name="in1" type="float" value="2.0" />
      <input name="in2" type="float" nodename="modulated_specular_reflectivity1" />
    </multiply>
    <sqrt name="sqrt_modulated_specular_reflectivity" type="float">
      <input name="in" type="float" nodename="modulated_specular_reflectivity2" />
    </sqrt>
    <sign name="sign_specular_ior_minus_one" type="float">
      <input name="in" type="float" nodename="specular_ior_minus_one" />
    </sign>
    <multiply name="modulated_specular_reflectivity3" type="float">
      <input name="in1" type="float" nodename="sign_specular_ior_minus_one" />
      <input name="in2" type="float" nodename="sqrt_modulated_specular_reflectivity" />
    </multiply>
    <subtract name="one_minus_modulated_specular_reflectivity3" type="float">
      <input name="in1" type="float" value="1.0" />
      <input name="in2" type="float" nodename="modulated_specular_reflectivity3" />
    </subtract>
    <add name="one_plus_modulated_specular_reflectivity3" type="float">
      <input name="in1" type="float" value="1.0" />
      <input name="in2" type="float" nodename="modulated_specular_reflectivity3" />
    </add>
    <divide name="modulated_specular_ior_ratio" type="float">
      <input name="in1" type="float" nodename="one_plus_modulated_specular_reflectivity3" />
      <input name="in2" type="float" nodename="one_minus_modulated_specular_reflectivity3" />
    </divide>
    <dielectric_bsdf name="dielectric_transmission" type="BSDF">
      <input name="weight" type="float" value="1.0" />
      <input name="tint" type="color3" interfacename="transmission_color" />
      <input name="ior" type="float" nodename="modulated_specular_ior_ratio" />
      <input name="roughness" type="vector2" nodename="transmission_roughness" />
      <input name="normal" type="vector3" interfacename="geometry_normal" />
      <input name="tangent" type="vector3" nodename="main_tangent" />
      <input name="distribution" type="string" value="ggx" />
      <input name="scatter_mode" type="string" value="T" />
    </dielectric_bsdf>
    <mix name="dielectric_substrate" type="BSDF">
      <input name="fg" type="BSDF" nodename="dielectric_transmission" />
      <input name="bg" type="BSDF" nodename="opaque_base" />
      <input name="mix" type="float" interfacename="transmission_weight" />
    </mix>
    <dielectric_bsdf name="dielectric_reflection" type="BSDF">
      <input name="weight" type="float" interfacename="specular_weight" />
      <input name="tint" type="color3" interfacename="specular_color" />
      <input name="ior" type="float" nodename="modulated_specular_ior_ratio" />
      <input name="roughness" type="vector2" nodename="main_roughness" />
      <input name="normal" type="vector3" interfacename="geometry_normal" />
      <input name="tangent" type="vector3" nodename="main_tangent" />
      <input name="distribution" type="string" value="ggx" />
      <input name="scatter_mode" type="string" value="R" />
    </dielectric_bsdf>
    <layer name="dielectric_base" type="BSDF">
      <input name="top" type="BSDF" nodename="dielectric_reflection" />
      <input name="base" type="BSDF" nodename="dielectric_substrate" />
    </layer>

    <!-- Metal Layer -->
    <multiply name="metal_reflectivity" type="color3">
      <input name="in1" type="color3" interfacename="base_color" />
      <input name="in2" type="float" interfacename="base_weight" />
    </multiply>
    <multiply name="metal_edgecolor" type="color3">
      <input name="in1" type="color3" interfacename="specular_color" />
      <input name="in2" type="float" interfacename="specular_weight" />
    </multiply>

    <!-- TODO: Add support for a color82 input in generalized_schlick_bsdf -->
    <generalized_schlick_bsdf name="metal_bsdf" type="BSDF">
      <input name="weight" type="float" value="1.0" />
      <input name="color0" type="color3" nodename="metal_reflectivity" />
      <input name="color90" type="color3" nodename="metal_edgecolor" />
      <input name="roughness" type="vector2" nodename="main_roughness" />
      <input name="normal" type="vector3" interfacename="geometry_normal" />
      <input name="tangent" type="vector3" nodename="main_tangent" />
    </generalized_schlick_bsdf>
    <mix name="base_substrate" type="BSDF">
      <input name="fg" type="BSDF" nodename="metal_bsdf" />
      <input name="bg" type="BSDF" nodename="dielectric_base" />
      <input name="mix" type="float" interfacename="base_metalness" />
    </mix>

    <!-- Thin-film Layer -->
    <thin_film_bsdf name="thin_film_bsdf" type="BSDF">
      <input name="thickness" type="float" interfacename="thin_film_thickness" />
      <input name="ior" type="float" interfacename="thin_film_ior" />
    </thin_film_bsdf>
    <layer name="thin_film_layer" type="BSDF">
      <input name="top" type="BSDF" nodename="thin_film_bsdf" />
      <input name="base" type="BSDF" nodename="base_substrate" />
    </layer>

    <!-- Coat Layer -->
    <divide name="half_over_coat_F0" type="float">
      <input name="in1" type="float" value="0.5" />
      <input name="in2" type="float" nodename="coat_ior_to_F0" />
    </divide>
    <min name="coat_ior_level_upper_bound" type="float">
      <input name="in1" type="float" value="1.0" />
      <input name="in2" type="float" nodename="half_over_coat_F0" />
    </min>
    <clamp name="coat_ior_level_clamped" type="float">
      <input name="in" type="float" interfacename="coat_ior_level" />
      <input name="low" type="float" value="0.0" />
      <input name="high" type="float" nodename="coat_ior_level_upper_bound" />
    </clamp>
    <multiply name="modulated_coat_reflectivity1" type="float">
      <input name="in1" type="float" nodename="coat_ior_level_clamped" />
      <input name="in2" type="float" nodename="coat_ior_to_F0" />
    </multiply>
    <multiply name="modulated_coat_reflectivity2" type="float">
      <input name="in1" type="float" value="2.0" />
      <input name="in2" type="float" nodename="modulated_coat_reflectivity1" />
    </multiply>
    <sqrt name="sqrt_modulated_coat_reflectivity" type="float">
      <input name="in" type="float" nodename="modulated_coat_reflectivity2" />
    </sqrt>
    <subtract name="one_minus_sqrt_modulated_coat_reflectivity" type="float">
      <input name="in1" type="float" value="1.0" />
      <input name="in2" type="float" nodename="sqrt_modulated_coat_reflectivity" />
    </subtract>
    <add name="one_plus_sqrt_modulated_coat_reflectivity" type="float">
      <input name="in1" type="float" value="1.0" />
      <input name="in2" type="float" nodename="sqrt_modulated_coat_reflectivity" />
    </add>
    <divide name="modulated_coat_ior_ratio" type="float">
      <input name="in1" type="float" nodename="one_plus_sqrt_modulated_coat_reflectivity" />
      <input name="in2" type="float" nodename="one_minus_sqrt_modulated_coat_reflectivity" />
    </divide>
    <mix name="modulated_coat_ior" type="float">
      <input name="fg" type="float" nodename="modulated_coat_ior_ratio" />
      <input name="bg" type="float" value="1.0" />
      <input name="mix" type="float" interfacename="coat_weight" />
    </mix>
    <mix name="coat_attenuation" type="color3">
      <input name="fg" type="color3" interfacename="coat_color" />
      <input name="bg" type="color3" value="1.0, 1.0, 1.0" />
      <input name="mix" type="float" interfacename="coat_weight" />
    </mix>
    <multiply name="coat_substrate_attenuated" type="BSDF">
      <input name="in1" type="BSDF" nodename="thin_film_layer" />
      <input name="in2" type="color3" nodename="coat_attenuation" />
    </multiply>
    <roughness_anisotropy name="coat_roughness_vector" type="vector2">
      <input name="roughness" type="float" interfacename="coat_roughness" />
      <input name="anisotropy" type="float" interfacename="coat_anisotropy" />
    </roughness_anisotropy>
    <dielectric_bsdf name="coat_bsdf" type="BSDF">
      <input name="weight" type="float" interfacename="coat_weight" />
      <input name="tint" type="color3" value="1.0, 1.0, 1.0" />
      <input name="ior" type="float" nodename="modulated_coat_ior" />
      <input name="roughness" type="vector2" nodename="coat_roughness_vector" />
      <input name="normal" type="vector3" interfacename="geometry_coat_normal" />
      <input name="tangent" type="vector3" nodename="coat_tangent" />
      <input name="distribution" type="string" value="ggx" />
      <input name="scatter_mode" type="string" value="R" />
    </dielectric_bsdf>
    <layer name="coat_layer" type="BSDF">
      <input name="top" type="BSDF" nodename="coat_bsdf" />
      <input name="base" type="BSDF" nodename="coat_substrate_attenuated" />
    </layer>

    <!-- Fuzz Layer -->
    <!-- TODO: Add a new BSDF node for the selected fuzz model in OpenPBR -->
    <sheen_bsdf name="fuzz_bsdf" type="BSDF">
      <input name="weight" type="float" interfacename="fuzz_weight" />
      <input name="color" type="color3" interfacename="fuzz_color" />
      <input name="roughness" type="float" interfacename="fuzz_roughness" />
      <input name="normal" type="vector3" interfacename="geometry_normal" />
    </sheen_bsdf>
    <layer name="fuzz_layer" type="BSDF">
      <input name="top" type="BSDF" nodename="fuzz_bsdf" />
      <input name="base" type="BSDF" nodename="coat_layer" />
    </layer>

    <!-- Emission Layer -->
    <subtract name="coat_ior_minus_one" type="float">
      <input name="in1" type="float" interfacename="coat_ior" />
      <input name="in2" type="float" value="1.0" />
    </subtract>
    <add name="coat_ior_plus_one" type="float">
      <input name="in1" type="float" value="1.0" />
      <input name="in2" type="float" interfacename="coat_ior" />
    </add>
    <divide name="coat_ior_to_F0_sqrt" type="float">
      <input name="in1" type="float" nodename="coat_ior_minus_one" />
      <input name="in2" type="float" nodename="coat_ior_plus_one" />
    </divide>
    <multiply name="coat_ior_to_F0" type="float">
      <input name="in1" type="float" nodename="coat_ior_to_F0_sqrt" />
      <input name="in2" type="float" nodename="coat_ior_to_F0_sqrt" />
    </multiply>
    <multiply name="emission_weight" type="color3">
      <input name="in1" type="color3" interfacename="emission_color" />
      <input name="in2" type="float" interfacename="emission_luminance" />
    </multiply>
    <uniform_edf name="uncoated_emission_edf" type="EDF">
      <input name="color" type="color3" nodename="emission_weight" />
    </uniform_edf>
    <multiply name="coat_tinted_emission_edf" type="EDF">
      <input name="in1" type="EDF" nodename="uncoated_emission_edf" />
      <input name="in2" type="color3" interfacename="coat_color" />
    </multiply>
    <subtract name="one_minus_coat_F0" type="float">
      <input name="in1" type="float" value="1.0" />
      <input name="in2" type="float" nodename="coat_ior_to_F0" />
    </subtract>
    <generalized_schlick_edf name="coated_emission_edf" type="EDF">
      <input name="color0" type="color3" nodename="one_minus_coat_F0" channels="rrr" />
      <input name="color90" type="color3" value="0.0, 0.0, 0.0" />
      <input name="exponent" type="float" value="5.0" />
      <input name="base" type="EDF" nodename="coat_tinted_emission_edf" />
    </generalized_schlick_edf>
    <mix name="emission_edf" type="EDF">
      <input name="fg" type="EDF" nodename="coated_emission_edf" />
      <input name="bg" type="EDF" nodename="uncoated_emission_edf" />
      <input name="mix" type="float" interfacename="coat_weight" />
    </mix>

    <!-- Surface construction with opacity -->
    <!-- Node <surface> only supports monochromatic opacity so use the luminance of input opacity color -->
    <luminance name="opacity_luminance" type="color3">
      <input name="in" type="color3" interfacename="geometry_opacity" />
    </luminance>
    <surface name="shader_constructor" type="surfaceshader">
      <input name="bsdf" type="BSDF" nodename="fuzz_layer" />
      <input name="edf" type="EDF" nodename="emission_edf" />
      <input name="opacity" type="float" nodename="opacity_luminance" channels="r" />
    </surface>

    <!-- Output -->
    <output name="out" type="surfaceshader" nodename="shader_constructor" />

  </nodegraph>

  <!--
    OpenPBR Display Material
  -->
  <surfacematerial name="Default" type="material">
    <input name="surfaceshader" type="surfaceshader" nodename="open_pbr_surface_surfaceshader" />
    <input name="displacementshader" type="displacementshader" value="" />
  </surfacematerial>
  <open_pbr_surface name="open_pbr_surface_surfaceshader" type="surfaceshader">
    <input name="base_weight" type="float" value="1.0" />
    <input name="base_color" type="color3" value="0.8, 0.8, 0.8" />
    <input name="base_roughness" type="float" value="0.0" />
    <input name="base_metalness" type="float" value="0.0" />
    <input name="specular_weight" type="float" value="1.0" />
    <input name="specular_color" type="color3" value="1, 1, 1" />
    <input name="specular_roughness" type="float" value="0.3" />
    <input name="specular_ior" type="float" value="1.5" />
    <input name="specular_ior_level" type="float" value="0.5" />
    <input name="specular_anisotropy" type="float" value="0.0" />
    <input name="specular_rotation" type="float" value="0.0" />
    <input name="transmission_weight" type="float" value="0.0" />
    <input name="transmission_color" type="color3" value="1, 1, 1" />
    <input name="transmission_depth" type="float" value="0.0" />
    <input name="transmission_scatter" type="color3" value="0, 0, 0" />
    <input name="transmission_scatter_anisotropy" type="float" value="0.0" />
    <input name="transmission_dispersion" type="float" value="0.0" />
    <input name="subsurface_weight" type="float" value="0" />
    <input name="subsurface_color" type="color3" value="0.8, 0.8, 0.8" />
    <input name="subsurface_radius" type="float" value="1.0" />
    <input name="subsurface_radius_scale" type="color3" value="1.0, 0.5, 0.25" />
    <input name="subsurface_anisotropy" type="float" value="0.0" />
    <input name="fuzz_weight" type="float" value="0.0" />
    <input name="fuzz_color" type="color3" value="1, 1, 1" />
    <input name="fuzz_roughness" type="float" value="0.5" />
    <input name="coat_weight" type="float" value="0.0" />
    <input name="coat_color" type="color3" value="1, 1, 1" />
    <input name="coat_roughness" type="float" value="0.0" />
    <input name="coat_anisotropy" type="float" value="0.0" />
    <input name="coat_rotation" type="float" value="0.0" />
    <input name="coat_ior" type="float" value="1.6" />
    <input name="coat_ior_level" type="float" value="0.5" />
    <input name="thin_film_thickness" type="float" value="0" />
    <input name="thin_film_ior" type="float" value="1.5" />
    <input name="emission_luminance" type="float" value="0.0" />
    <input name="emission_color" type="color3" value="1, 1, 1" />
    <input name="geometry_opacity" type="color3" value="1, 1, 1" />
    <input name="geometry_thin_walled" type="boolean" value="false" />
  </open_pbr_surface>

</materialx>

Suggestion

Either hide these nodegraphs (or template them / make them read-only). Here is OpenPBR implementation graph (circled) is shown.

image

kwokcb avatar Jan 16 '24 14:01 kwokcb