Skip to content

Commit

Permalink
Improvements to 1.37 upgrade (AcademySoftwareFoundation#1555)
Browse files Browse the repository at this point in the history
- Add an example shading model graph using MaterialX 1.37 syntax, allowing improved coverage of version upgrade logic in unit tests.
- Simplify the logic for 1.37 upgrades in Document::upgradeVersion, removing legacy code that was dedicated to upgrading the MaterialX standard libraries.
  • Loading branch information
jstone-lucasfilm authored Oct 7, 2023
1 parent 2dc7408 commit 1f930a7
Show file tree
Hide file tree
Showing 2 changed files with 144 additions and 173 deletions.
151 changes: 100 additions & 51 deletions resources/Materials/TestSuite/stdlib/upgrade/syntax_1_37.mtlx
Original file line number Diff line number Diff line change
Expand Up @@ -4,61 +4,110 @@
Examples of MaterialX 1.37 syntax
-->

<nodegraph name="atan2_graph">
<atan2 name="atan2_float" type="float">
<input name="in1" type="float" value="0.5" />
<input name="in2" type="float" value="1.0" />
</atan2>
<atan2 name="atan2_vector2" type="vector2">
<input name="in1" type="vector2" value="0.5, 0.5" />
<input name="in2" type="vector2" value="1.0, 1.0" />
</atan2>
<atan2 name="atan2_vector3" type="vector3">
<input name="in1" type="vector3" value="0.5, 0.5, 0.5" />
<input name="in2" type="vector3" value="1.0, 1.0, 1.0" />
</atan2>
<atan2 name="atan2_vector4" type="vector4">
<input name="in1" type="vector4" value="0.5, 0.5, 0.5, 0.5" />
<input name="in2" type="vector4" value="1.0, 1.0, 1.0, 1.0" />
</atan2>
<rotate3d name="rot1" type="vector3">
<input name="in" type="vector3" value="1.0, 0.0, 0.0" />
<input name="amount" type="float" value="10.0" />
<parameter name="axis" type="vector3" value="0.0, 0.0, 1.0" />
</rotate3d>
</nodegraph>

<nodedef name="ND_Test" node="test">
<input name="add" type="float" />
<nodedef name="ND_example_surface" node="example_surface">
<input name="diffuseColor" type="color3" value="0.18, 0.18, 0.18" />
<input name="metalness" type="float" value="0" />
<input name="roughness" type="float" value="0.01" />
<input name="clearcoat" type="float" value="0" />
<input name="clearcoatRoughness" type="float" value="0.01" />
<input name="transmission" type="float" value="0" />
<input name="ior" type="float" value="1.5" />
<input name="emissiveColor" type="color3" value="0, 0, 0" />
<output name="out" type="surfaceshader" />
</nodedef>
<nodegraph name="NG_Test" nodedef="ND_Test">
<add name="add" type="float">
<input name="in1" type="float" interfacename="add" />
<input name="in2" type="float" value="1.0" />
</add>
<add name="add1" type="float">
<input name="in1" type="float" nodename="add" />
<input name="in2" type="float" value="1.0" />
</add>
</nodegraph>

<nodegraph name="NG_aiMixColor31">
<mix name="aiMixColor31" type="color3">
<input name="fg" type="color3" nodename="aiAbsvalColor31" />
<input name="bg" type="color3" nodename="aiAbsvalColor32" />
<input name="mix" type="float" value="0.5" />
<nodegraph name="NG_example_surface" nodedef="ND_example_surface">
<diffuse_brdf name="diffuse_bsdf" type="BSDF">
<input name="weight" type="float" value="1" />
<input name="color" type="color3" interfacename="diffuseColor" />
<input name="roughness" type="float" value="0" />
</diffuse_brdf>
<dielectric_btdf name="transmission_bsdf" type="BSDF">
<input name="weight" type="float" value="1" />
<input name="tint" type="color3" value="1, 1, 1" />
<input name="ior" type="float" interfacename="ior" />
</dielectric_btdf>
<mix name="transmission_mix" type="BSDF">
<input name="fg" type="BSDF" nodename="transmission_bsdf" />
<input name="bg" type="BSDF" nodename="diffuse_bsdf" />
<input name="mix" type="float" interfacename="transmission" />
</mix>
<absval name="aiAbsvalColor31" type="color3">
<input name="in" type="color3" value="1, 0, 0" />
</absval>
<absval name="aiAbsvalColor32" type="color3">
<input name="in" type="color3" value="0.671, 0.671, 0.671" />
</absval>
<output name="out" type="color3" nodename="aiMixColor31" />
<roughness_anisotropy name="specular_roughness" type="vector2">
<input name="roughness" type="float" interfacename="roughness" />
<input name="anisotropy" type="float" value="0" />
</roughness_anisotropy>
<subtract name="one_minus_ior" type="float">
<input name="in1" type="float" value="1" />
<input name="in2" type="float" interfacename="ior" />
</subtract>
<add name="one_plus_ior" type="float">
<input name="in1" type="float" value="1" />
<input name="in2" type="float" interfacename="ior" />
</add>
<divide name="div_ior" type="float">
<input name="in1" type="float" nodename="one_minus_ior" />
<input name="in2" type="float" nodename="one_plus_ior" />
</divide>
<multiply name="F0" type="float">
<input name="in1" type="float" nodename="div_ior" />
<input name="in2" type="float" nodename="div_ior" />
</multiply>
<multiply name="F0_albedo" type="color3">
<input name="in1" type="color3" interfacename="diffuseColor" />
<input name="in2" type="float" nodename="F0" />
</multiply>
<generalized_schlick_brdf name="dielectric_bsdf" type="BSDF">
<input name="weight" type="float" value="1" />
<input name="color0" type="color3" nodename="F0" channels="rrr"/>
<input name="color90" type="color3" value="1, 1, 1" />
<input name="roughness" type="vector2" nodename="specular_roughness" />
<input name="base" type="BSDF" nodename="transmission_mix" />
</generalized_schlick_brdf>
<conductor_brdf name="conductor_bsdf" type="BSDF">
<input name="weight" type="float" value="1" />
<input name="reflectivity" type="color3" nodename="F0_albedo" />
<input name="edge_color" type="color3" interfacename="diffuseColor" />
<input name="roughness" type="vector2" nodename="specular_roughness" />
</conductor_brdf>
<mix name="specular_bsdf" type="BSDF">
<input name="fg" type="BSDF" nodename="conductor_bsdf" />
<input name="bg" type="BSDF" nodename="dielectric_bsdf" />
<input name="mix" type="float" interfacename="metalness" />
</mix>
<roughness_anisotropy name="coat_roughness" type="vector2">
<input name="roughness" type="float" interfacename="clearcoatRoughness" />
<input name="anisotropy" type="float" value="0" />
</roughness_anisotropy>
<dielectric_brdf name="coat_bsdf" type="BSDF">
<input name="weight" type="float" interfacename="clearcoat" />
<input name="tint" type="color3" value="1, 1, 1" />
<input name="ior" type="float" value="1.5" />
<input name="roughness" type="vector2" nodename="coat_roughness" />
<input name="base" type="BSDF" nodename="specular_bsdf" />
</dielectric_brdf>
<uniform_edf name="emission_edf" type="EDF">
<input name="color" type="color3" interfacename="emissiveColor" />
</uniform_edf>
<surface name="surface_constructor" type="surfaceshader">
<input name="bsdf" type="BSDF" nodename="coat_bsdf" />
<input name="edf" type="EDF" nodename="emission_edf" />
</surface>
<output name="out" type="surfaceshader" nodename="surface_constructor" />
</nodegraph>
<material name="my_surface">
<shaderref name="my_surface" node="standard_surface">
<bindinput name="base_color" type="color3" nodegraph="NG_aiMixColor31" output="out" />

<material name="M_example_surface">
<shaderref name="SR_example_surface" node="example_surface">
<bindinput name="diffuseColor" type="color3" value="0.2, 0.2, 0.6" />
</shaderref>
</material>

<atan2 name="atan2" type="float">
<input name="in1" type="float" value="0.5" />
<input name="in2" type="float" value="1.0" />
</atan2>
<rotate3d name="rot1" type="vector3">
<input name="in" type="vector3" value="1.0, 0.0, 0.0" />
<input name="amount" type="float" value="10.0" />
<parameter name="axis" type="vector3" value="0.0, 0.0, 1.0" />
</rotate3d>
</materialx>
Loading

0 comments on commit 1f930a7

Please sign in to comment.