Skip to content

Conversation

ld-kerley
Copy link
Contributor

@ld-kerley ld-kerley commented Jun 11, 2025

This work is a continuation of the work in #2362. Please be sure to refer to the valuable discussion in that PR for more context around this work.

This PR contains three separate, but very interconnected pieces of work.

  • Named Constants (rebranded from Named Values - credit @bernardkwok).
  • Template Elements - which can now be nested and replace multiple variables simultaneously.
  • Template expansion tools
  • Specification build tools - which has been a collaborative effort with @anderslanglands.

Both the template expansion tools and the specification build tools are still very much work-in-progress, and have not been cleaned up too much, in anticipation of possible updates to the new grammar.

The hope here is that we can merge this PR soon to allow people to iterate and experiment - as well as to avoid this working going stale and needing to be rebased (yet again). Everything in this PR should be disabled/optional and should not affect the existing functionality of the code, or understanding of the data library. The MaterialX data library contained in the "libraries" folder remains untouched by this PR.

Named Constants and Template Elements

The proposed formal specification for these elements is outlined in #2553.

Briefly the changes from the prior proposal are:

  • "Named Values" are now "Named Constants" and defined as child <constant> elements of their associated <typedef>.
  • <template> elements can now be nested inside each other and evaluated from outer to inner scope. Examples of this are now in the stdlib_defs.mtlx in the templates directory.
  • <template> elements can now substitute multiple name variables simultaneously.

There is a build tool that will expand the templates.

Specification Build Tools

Building on top of the named constant and template work outlined above, we add tools to programmatically build the parameter tables for the new style MaterialX node specification (the designs for these tables has been contributed by the AoUSD).
These tools are important to include as part of this work, as they have been the proving ground, and have both extended the original proposed grammar and validated that both the system and the tools are functioning correctly.

The build tools are guarded behind the CMake argument MATERIALX_BUILD_SPECIFICATION_DOCS, which is disabled by default. When enabled the markdown template files in documents/SpecificationTemplates will be expanded to a documents/SpecificationBuild folder along side - while this is still work-in-progress - ultimately we could build directly to documents/Specification.

Through the process of building this a number of inconsistencies were discovered, highlighting the benefits of generating the documents though an automatic system.

Additional attribute the documentation system uses during the build, but are stripped out while building the data library itself are:

  • spec_desc to store the description field
  • spec_acceptedvalues to store the accepted values field

Allowing for significant reduction in the size of the source for the standard library
Templates can be nested and replace multiple variables simultaneously
Templates can be expanded and diff in cmake stage - allowing for easy validation of appropriate template expansion
Leaves the libraries folder untouched for now, to facilitate easier hands on experimentation with the new grammar

Also includes documentation building tools - which have been the proving ground for the new template grammar.
Builds specification docs to a temporary folder (for now) from a new template location - again for easy validation that
the expansion is correct.
The documentation work was critical to ensuring this initial template system is fully featured enough to
be useful, and uncovered a number of discrepancies with the human edited specification. This is one of the
strong advantages of using a template expansion based system.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant