Skip to content

Commit

Permalink
Add versioning for the changes to standard_surface
Browse files Browse the repository at this point in the history
  • Loading branch information
niklasharrysson committed Mar 1, 2023
1 parent 8df6338 commit 1cd76f5
Show file tree
Hide file tree
Showing 2 changed files with 345 additions and 5 deletions.
320 changes: 315 additions & 5 deletions libraries/bxdf/standard_surface.mtlx
Original file line number Diff line number Diff line change
@@ -1,16 +1,28 @@
<?xml version="1.0"?>
<materialx version="1.38">
<!--
Autodesk Standard Surface node definition.
Autodesk Standard Surface node definition 1.0.2.
Changes: Improves implementation of emission under coat, accounting for the coat's Fresnel effect.
-->
<nodedef name="ND_standard_surface_surfaceshader" node="standard_surface" nodegroup="pbr" version="1.0.1" isdefaultversion="true" inherit="ND_standard_surface_surfaceshader_100"
<nodedef name="ND_standard_surface_surfaceshader" node="standard_surface" nodegroup="pbr" version="1.0.2" isdefaultversion="true" inherit="ND_standard_surface_surfaceshader_101"
doc="Autodesk standard surface shader">
</nodedef>

<!--
Autodesk Standard Surface node definition 1.0.1.
Changes: Some updates to default values.
-->
<nodedef name="ND_standard_surface_surfaceshader_101" node="standard_surface" nodegroup="pbr" version="1.0.1" inherit="ND_standard_surface_surfaceshader_100"
doc="Autodesk standard surface shader">
<input name="base" type="float" value="1.0" uimin="0.0" uimax="1.0" uiname="Base" uifolder="Base"
doc="Multiplier on the intensity of the diffuse reflection." />
<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 diffuse reflection." />
</nodedef>

<!--
Autodesk Standard Surface node definition 1.0.0.
-->
<nodedef name="ND_standard_surface_surfaceshader_100" node="standard_surface" nodegroup="pbr" version="1.0.0" doc="Autodesk standard surface shader">
<input name="base" type="float" value="0.8" uimin="0.0" uimax="1.0" uiname="Base" uifolder="Base"
doc="Multiplier on the intensity of the diffuse reflection." />
Expand Down Expand Up @@ -103,13 +115,14 @@
Association between implementation and definition.
Note that version 1.0.1 only changes default values and thus reuses the same 1.0.0 nodegraph implementation.
-->
<implementation name="IMPL_standard_surface_surfaceshader_101" nodedef="ND_standard_surface_surfaceshader" nodegraph="NG_standard_surface_surfaceshader_100" />
<implementation name="IMPL_standard_surface_surfaceshader_102" nodedef="ND_standard_surface_surfaceshader" nodegraph="NG_standard_surface_surfaceshader_102" />
<implementation name="IMPL_standard_surface_surfaceshader_101" nodedef="ND_standard_surface_surfaceshader_101" nodegraph="NG_standard_surface_surfaceshader_100" />
<implementation name="IMPL_standard_surface_surfaceshader_100" nodedef="ND_standard_surface_surfaceshader_100" nodegraph="NG_standard_surface_surfaceshader_100" />

<!--
Autodesk Standard Surface nodegraph implementation.
Autodesk Standard Surface nodegraph implementation 1.0.2.
-->
<nodegraph name="NG_standard_surface_surfaceshader_100">
<nodegraph name="NG_standard_surface_surfaceshader_102">

<!-- Roughness influence by coat-->
<!-- Calculate main specular roughness -->
Expand Down Expand Up @@ -425,4 +438,301 @@

</nodegraph>

<!--
Autodesk Standard Surface nodegraph implementation 1.0.0.
-->
<nodegraph name="NG_standard_surface_surfaceshader_100">

<!-- Roughness influence by coat-->
<!-- Calculate main specular roughness -->
<multiply name="coat_affect_roughness_multiply1" type="float">
<input name="in1" type="float" interfacename="coat_affect_roughness" />
<input name="in2" type="float" interfacename="coat" />
</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 -->
<add name="transmission_roughness_add" type="float">
<input name="in1" type="float" interfacename="specular_roughness" />
<input name="in2" type="float" interfacename="transmission_extra_roughness" />
</add>
<clamp name="transmission_roughness_clamped" type="float">
<input name="in" type="float" nodename="transmission_roughness_add" />
</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="tangent" />
<input name="amount" type="float" nodename="tangent_rotate_degree" />
<input name="axis" type="vector3" interfacename="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="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="tangent" />
<input name="amount" type="float" nodename="coat_tangent_rotate_degree" />
<input name="axis" type="vector3" interfacename="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="tangent" />
</ifgreater>

<!-- Colors influenced by coat ("coat gamma") -->
<clamp name="coat_clamped" type="float">
<input name="in" type="float" interfacename="coat" />
</clamp>
<multiply name="coat_gamma_multiply" type="float">
<input name="in1" type="float" nodename="coat_clamped" />
<input name="in2" type="float" interfacename="coat_affect_color" />
</multiply>
<add name="coat_gamma" type="float">
<input name="in1" type="float" nodename="coat_gamma_multiply" />
<input name="in2" type="float" value="1.0" />
</add>
<max name="base_color_nonnegative" type="color3">
<input name="in1" type="color3" interfacename="base_color" />
<input name="in2" type="float" value="0.0" />
</max>
<power name="coat_affected_diffuse_color" type="color3">
<input name="in1" type="color3" nodename="base_color_nonnegative" />
<input name="in2" type="float" nodename="coat_gamma" />
</power>
<max name="subsurface_color_nonnegative" type="color3">
<input name="in1" type="color3" interfacename="subsurface_color" />
<input name="in2" type="float" value="0.0" />
</max>
<power name="coat_affected_subsurface_color" type="color3">
<input name="in1" type="color3" nodename="subsurface_color_nonnegative" />
<input name="in2" type="float" nodename="coat_gamma" />
</power>

<!-- Diffuse/Subsurface Layer -->
<oren_nayar_diffuse_bsdf name="diffuse_bsdf" type="BSDF">
<input name="weight" type="float" interfacename="base" />
<input name="color" type="color3" nodename="coat_affected_diffuse_color" />
<input name="roughness" type="float" interfacename="diffuse_roughness" />
<input name="normal" type="vector3" interfacename="normal" />
</oren_nayar_diffuse_bsdf>
<translucent_bsdf name="translucent_bsdf" type="BSDF">
<input name="weight" type="float" value="1.0" />
<input name="color" type="color3" nodename="coat_affected_subsurface_color" />
<input name="normal" type="vector3" interfacename="normal" />
</translucent_bsdf>
<convert name="subsurface_radius_vector" type="vector3">
<input name="in" type="color3" interfacename="subsurface_radius" />
</convert>
<multiply name="subsurface_radius_scaled" type="vector3">
<input name="in1" type="vector3" nodename="subsurface_radius_vector" />
<input name="in2" type="float" interfacename="subsurface_scale" />
</multiply>
<subsurface_bsdf name="subsurface_bsdf" type="BSDF">
<input name="weight" type="float" value="1.0" />
<input name="color" type="color3" nodename="coat_affected_subsurface_color" />
<input name="radius" type="vector3" nodename="subsurface_radius_scaled" />
<input name="anisotropy" type="float" interfacename="subsurface_anisotropy" />
<input name="normal" type="vector3" interfacename="normal" />
</subsurface_bsdf>
<convert name="subsurface_selector" type="float">
<input name="in" type="boolean" interfacename="thin_walled" />
</convert>
<mix name="selected_subsurface_bsdf" type="BSDF">
<input name="fg" type="BSDF" nodename="translucent_bsdf" />
<input name="bg" type="BSDF" nodename="subsurface_bsdf" />
<input name="mix" type="float" nodename="subsurface_selector" />
</mix>
<mix name="subsurface_mix" type="BSDF">
<input name="fg" type="BSDF" nodename="selected_subsurface_bsdf" />
<input name="bg" type="BSDF" nodename="diffuse_bsdf" />
<input name="mix" type="float" interfacename="subsurface" />
</mix>

<!-- Sheen Layer -->
<sheen_bsdf name="sheen_bsdf" type="BSDF">
<input name="weight" type="float" interfacename="sheen" />
<input name="color" type="color3" interfacename="sheen_color" />
<input name="roughness" type="float" interfacename="sheen_roughness" />
<input name="normal" type="vector3" interfacename="normal" />
</sheen_bsdf>
<layer name="sheen_layer" type="BSDF">
<input name="top" type="BSDF" nodename="sheen_bsdf" />
<input name="base" type="BSDF" nodename="subsurface_mix" />
</layer>

<!-- Transmission Layer -->
<dielectric_bsdf name="transmission_bsdf" type="BSDF">
<input name="weight" type="float" value="1.0" />
<input name="tint" type="color3" interfacename="transmission_color" />
<input name="ior" type="float" interfacename="specular_IOR" />
<input name="roughness" type="vector2" nodename="transmission_roughness" />
<input name="normal" type="vector3" interfacename="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="transmission_mix" type="BSDF">
<input name="fg" type="BSDF" nodename="transmission_bsdf" />
<input name="bg" type="BSDF" nodename="sheen_layer" />
<input name="mix" type="float" interfacename="transmission" />
</mix>

<!-- Specular Layer -->
<dielectric_bsdf name="specular_bsdf" type="BSDF">
<input name="weight" type="float" interfacename="specular" />
<input name="tint" type="color3" interfacename="specular_color" />
<input name="ior" type="float" interfacename="specular_IOR" />
<input name="roughness" type="vector2" nodename="main_roughness" />
<input name="normal" type="vector3" interfacename="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="specular_layer" type="BSDF">
<input name="top" type="BSDF" nodename="specular_bsdf" />
<input name="base" type="BSDF" nodename="transmission_mix" />
</layer>

<!-- Metal Layer -->
<multiply name="metal_reflectivity" type="color3">
<input name="in1" type="color3" interfacename="base_color" />
<input name="in2" type="float" interfacename="base" />
</multiply>
<multiply name="metal_edgecolor" type="color3">
<input name="in1" type="color3" interfacename="specular_color" />
<input name="in2" type="float" interfacename="specular" />
</multiply>
<artistic_ior name="artistic_ior" type="multioutput">
<input name="reflectivity" type="color3" nodename="metal_reflectivity" />
<input name="edge_color" type="color3" nodename="metal_edgecolor" />
</artistic_ior>
<conductor_bsdf name="metal_bsdf" type="BSDF">
<input name="weight" type="float" value="1.0" />
<input name="ior" type="color3" nodename="artistic_ior" output="ior" />
<input name="extinction" type="color3" nodename="artistic_ior" output="extinction" />
<input name="roughness" type="vector2" nodename="main_roughness" />
<input name="normal" type="vector3" interfacename="normal" />
<input name="tangent" type="vector3" nodename="main_tangent" />
<input name="distribution" type="string" value="ggx" />
</conductor_bsdf>
<mix name="metalness_mix" type="BSDF">
<input name="fg" type="BSDF" nodename="metal_bsdf" />
<input name="bg" type="BSDF" nodename="specular_layer" />
<input name="mix" type="float" interfacename="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="metalness_mix" />
</layer>

<!-- Coat Layer -->
<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" />
</mix>
<multiply name="thin_film_layer_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" />
<input name="tint" type="color3" value="1.0, 1.0, 1.0" />
<input name="ior" type="float" interfacename="coat_IOR" />
<input name="roughness" type="vector2" nodename="coat_roughness_vector" />
<input name="normal" type="vector3" interfacename="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="thin_film_layer_attenuated" />
</layer>

<!-- Emission Layer -->
<multiply name="emission_weight" type="color3">
<input name="in1" type="color3" interfacename="emission_color" />
<input name="in2" type="float" interfacename="emission" />
</multiply>
<mix name="coat_emission_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" />
</mix>
<multiply name="emission_weight_attenuated" type="color3">
<input name="in1" type="color3" nodename="emission_weight" />
<input name="in2" type="color3" nodename="coat_emission_attenuation" />
</multiply>
<uniform_edf name="emission_edf" type="EDF">
<input name="color" type="color3" nodename="emission_weight_attenuated" />
</uniform_edf>

<!-- 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="opacity" />
</luminance>
<surface name="shader_constructor" type="surfaceshader">
<input name="bsdf" type="BSDF" nodename="coat_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>

</materialx>
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0"?>
<materialx version="1.38" colorspace="lin_rec709">

<standard_surface name="SR_emission" type="surfaceshader">
<input name="base" type="float" value="0.0" />
<input name="specular" type="float" value="0.0" />
<input name="coat" type="float" value="1.0" />
<input name="coat_color" type="color3" value="1, 1, 1" />
<input name="coat_IOR" type="float" value="1.3" />
<input name="emission" type="float" value="1" />
<input name="emission_color" type="color3" value="1, 0, 0" />
</standard_surface>
<surfacematerial name="Emission" type="material">
<input name="surfaceshader" type="surfaceshader" nodename="SR_emission" />
</surfacematerial>

<standard_surface name="SR_emission_old" type="surfaceshader" version="1.0.1">
<input name="base" type="float" value="0.0" />
<input name="specular" type="float" value="0.0" />
<input name="coat" type="float" value="1.0" />
<input name="coat_color" type="color3" value="1, 1, 1" />
<input name="coat_IOR" type="float" value="1.3" />
<input name="emission" type="float" value="1" />
<input name="emission_color" type="color3" value="1, 0, 0" />
</standard_surface>
<surfacematerial name="EmissionOld" type="material">
<input name="surfaceshader" type="surfaceshader" nodename="SR_emission_old" />
</surfacematerial>

</materialx>

0 comments on commit 1cd76f5

Please sign in to comment.