Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multi-language and region support #1183

Open
ashwinbhat opened this issue May 5, 2021 · 0 comments
Open

Multi-language and region support #1183

ashwinbhat opened this issue May 5, 2021 · 0 comments
Assignees
Labels
Core Core change required
Projects
Milestone

Comments

@ashwinbhat
Copy link
Collaborator

Region Support:
While the mtlx file is utf-8, reading of the values is locale dependent.
Consider an value vec3 (1,235.4,1.0) in a xml file. The streambuf reads it in to convert to vec3. The values here are 1, 235.4 and 1.0. If the locale is not set correctly, it will be parsed incorrectly as float 1,235.4 or just fail.

Multi-language
The second issue is utf-16 file paths & file names. This is mainly an issue on Windows and requires enabling MaterialX support for wide versions of Windows API and PugiXML.
The attached zip contains a mtlx file that cannot be loaded on Windows using the readFromXmlFile API.
utf16test.zip

@ashwinbhat ashwinbhat added the Core Core change required label May 5, 2021
@ashwinbhat ashwinbhat added this to To do in Develop via automation May 5, 2021
ashwinbhat added a commit that referenced this issue May 5, 2021
For MaterialX let's assume we have a xml with `<input name="diffColor" type="vector3" value="1,1.5,2.0"/>`
mx:Vector3(1,1.5,2.0) should be interpreted as float[3] = [1.0f, 1.5f, 2.0f]. But based on the locale settings, 1,1.5 will be parsed as a value. By setting the locale on std::stringstream we ensure that input values are correctly read 
Some background reference around this https://stdcxx.apache.org/doc/stdlibug/24-3.html
https://docs.microsoft.com/en-us/globalization/locale/number-formatting
Partially addresses Issue #1183

Other changes:
Basic utility to generate a json and hpp export from MaterialX nodedef
e.g. given a node def e.g. ND_standard_surface_surfaceshader will
     generate a standard_surface.json and standard_surface.hpp
The hpp/json can be used for simple reflection instead of parsing mtlx libraries
bernardkwok pushed a commit that referenced this issue May 31, 2021
For MaterialX let's assume we have a xml with `<input name="diffColor" type="vector3" value="1,1.5,2.0"/>`
mx:Vector3(1,1.5,2.0) should be interpreted as float[3] = [1.0f, 1.5f, 2.0f]. But based on the locale settings, 1,1.5 will be parsed as a value. By setting the locale on std::stringstream we ensure that input values are correctly read 
Some background reference around this https://stdcxx.apache.org/doc/stdlibug/24-3.html
https://docs.microsoft.com/en-us/globalization/locale/number-formatting
Partially addresses Issue #1183

Other changes:
Basic utility to generate a json and hpp export from MaterialX nodedef
e.g. given a node def e.g. ND_standard_surface_surfaceshader will
     generate a standard_surface.json and standard_surface.hpp
The hpp/json can be used for simple reflection instead of parsing mtlx libraries
@bernardkwok bernardkwok added this to the 1.39 milestone Jun 24, 2021
@bernardkwok bernardkwok modified the milestones: 1.39, 1.38.3 Sep 17, 2021
@kwokcb kwokcb modified the milestones: 1.38.3, 1.38.4 Dec 7, 2021
jstone-lucasfilm pushed a commit to AcademySoftwareFoundation/MaterialX that referenced this issue Apr 19, 2022
- Add utilities UnitConverterRegistry::convertToUnit and MaterialX::joinStrings.
- Use C Locale for string stream operations (autodesk-forks#1183).
- Add tests for unit and locale content.
ashwinbhat added a commit that referenced this issue Apr 28, 2022
Main commit hash is 37ccbc55bf1988803d59eb33c5f9aeca31ae3886

* Upgrade shading models to v1.38

- Upgrade all documents in the libraries/bxdf folder to v1.38.
- Adjust uniform attributes in shading model interfaces to match their specifications.
- Rename a node in the implementation of standard_surface to avoid a collision with its interface.

* 1.38 Autodesk Updates (#590)

- Deprecation of nodes: `backfacing`, `fresnel`, `viewdirection`
- Get MDL unit tests to work with 1.38 changes
- Updates for TextureBaker:
  - restore code to prevent unoptimized path from failing.
  - fix `normalmap` node creation code to only copy over contents if the root of the subgraph being baked is also a `normalmap`. (the root may be a downstream node with a normalmap upstream of it).
- Fix for logic to GLSL implementation of `heighttonormal` node to prevent artifacts due to math exceptions. Render test case has been updated to test more configurations.
- Minor fix to image path flattening to prevent empty paths from adding search paths.

* Upgrade PBS library to v1.38

- Upgrade all documents in the libraries/pbrlib folder to v1.38.
- Adjust uniform attributes in node interfaces to match the specification.

* Update standard library to v1.38

- Upgrade all documents in the libraries/stdlib folder to v1.38.
- Adjust uniform attributes in node interfaces to match the specification.

* Add support for comment elements

This changelist adds support for comment elements, allowing document comments to be directly generated through the MaterialX API and preserved when loading and saving content.  The mxupdate.py script has been updated to preserve MTLX comments in document upgrades.

* Upgrade material test suite to v1.38

- Upgrade all documents in the resources/Materials/TestSuite folder to v1.38.
- Update comments and formatting for consistency.

* Streamline port connection methods

- Merge output accessors for Input and PortElement for simplicity.
- Simplify the implementation of Input::getConnectedNode.
- Rename Input::getConnectedInterface to Input::getInterfaceInput for clarity.

* Improvements to Python bindings

- Add default arguments to the Python binding for MaterialX::getShaderNodes.
- Add Python bindings for MATERIAL_TYPE_STRING, SURFACE_MATERIAL_NODE_STRING, and VOLUME_MATERIAL_NODE_STRING.
- Add shader node logic to mxvalidate.py, making this common Python pattern part of the test suite.
- Add missing deprecation warnings for ShaderRef methods.

* Update documentation for v1.38

- Add specification documents for v1.38.
- Minor changelog revisions for v1.38.0.
- Adjust global Doxygen settings for clarity.
- Fix a Doxygen comment in ShaderStage.h.

* Improvements to transparency detection

This changelist updates the transparency detection heuristic in MaterialXGenShader/Util.cpp for v1.38 shader nodes.  There's still plenty of room for future improvement, but this implementation generates correct results for all examples in the MaterialX repository.

* Improvements to search paths

- In the Viewer and TextureBaker, respect input search paths for shader code as well as documents and images, applying the necessary modifications to match the expectations of the code generator.
- Move the getDefaultSearchPath helper function from MaterialXGenShader to MaterialXView, since its assumptions are specific to that application.

* Improvements to viewer builds

- Remove library and resource copies for viewer builds, as they tend to slow down shader development.
- Simplify the logic for viewer search paths, making it more robust in production contexts.

* Document upgrade improvements

- Align parameter-to-input conversion with the specification, now that the standard libraries have been upgraded to v1.38.
- Remove legacy shader nodedefs from v1.36 documents, since they can interfere with code generation.

* Update links to main branch

- Update repository links to match a rename of the default branch from 'master' to 'main' (https://github.com/github/renaming).
- Add support for workflow dispatch jobs in GitHub Actions.

* Update badge to main branch

* Autodesk : minor updates (#607)

### Changes
- Refinement to optional arguments on loading libraries and documents
- TextureBaker: auto-resizing output image and hashing output file names options.
### Unit Tests
[mar1_unit_tests.pdf](https://github.com/materialx/MaterialX/files/6066037/mar1_unit_tests.pdf)

* Documentation updates

- Final updates for the v1.38 specification.
- Minor update to MaterialXTest documentation.

* Finalize changelog for v1.38.0

* Update development build to 1.38.1

* Fix external nanogui build (#611)

9197ee9 re-introduced linking via -lnanogui , which is redundant with the CMake variable NANOGUI_LIBRARIES for a local nano-gui build, and causes errors with an external NanoGUI install. 76a30db is the original merge where it was removed.

* Image handling improvements

- Simplify ImageHandler::acquireImage, making it non-virtual and removing an unused parameter.
- Add protected helper method ImageHandler::loadImage.
- Streamline the implementation of MaterialX::createImageStrip.

* MDL texture lookup code generation updates (#615)

Issues Addressed
- Fixes erroneous generation of a texture_2d() reference with "/" as an argument when no value is specified.
- Make texture_2d() lookups input arguments as opposed to always inlined.

* Add support for UINT16 images in MaterialXRender

This changelist adds support for 16-bit unsigned-integer images in MaterialXRender, allowing 16-bit TIFF files to be loaded and viewed when MaterialX is built with OpenImageIO enabled.

Also:
- Make ImageHandler::clearImageCache a public method.
- Add missing Python bindings for the ImageHandler class.
- Simplify Python bindings for the ImageLoader class.

* Allow building shared libraries on Windows (#618)

These changes allow MaterialX to be built under Windows with MATERIALX_BUILD_SHARED_LIBS set to true. New "MX__API" symbols exist for each library to allow classes and functions to be explicitly exported from the resulting DLLs.

* Updates to GitHub CI

- Upgrade Ubuntu version for GCC 10 builds.
- Add test for shared libraries on Windows.

* Improvements to viewer property editor

This changelist implements improvements to the viewer property editor, updating its display of shading models and ungrouped inputs to v1.38 conventions.

* Added initial draft for OSL closures (#614)

This changelist contains the initial draft and discussion for a set of new OSL closures to represent the MaterialX PBS library.

Discussion and development on this project continues in the OSL repository at https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1371.

* Add brick procedural images (#625)

Attribution: These images have been scanned by Autodesk and contributed to the MaterialX project.

* Added hybrid texture/procedural brick example (#626)

* Remove legacy texture

This changelist removes a legacy texture that was referenced only in unit tests, replacing it with the standard grid texture.

* Fix color asTuple methods

This changelist fixes the asTuple methods for the Color3 and Color4 classes in Python.  These methods are an older mechanism for casting vector/color instances to Python tuples, and the current recommended approach is to directly cast vector/color instances to tuple type.

* Remove invalid interfacename attribute

This changelist removes an invalid interfacename attribute from the nodegraph_nodegraph example, allowing improvements to document validation logic in the future.

* Add Element::getTreeIndex method

This changelist adds the Element::getTreeIndex method, which returns the breadth-first index of an element within the document tree.

* Improved support for compound nodegraphs (#633)

- Update shader code and UI generation to support compound nodegraphs with input bindings.
- Convert the standard_surface_brick_procedural and standard_surface_marble_solid examples to compound nodegraphs with input bindings, giving them an improved UI in the property editor.
- Add viewer option "Show All Inputs", which allows unbound shader inputs to be displayed in the property editor.

* Clarify opacity logic in Standard Surface

This changelist clarifies the opacity logic in the Standard Surface nodegraph, replacing a <swizzle> node containing an unused "param" element with the equivalent channel-specific connection.

* Improvements to shader translation and baking

- Add support for graph outputs with multiple bindings in shader translation.
- Remove extra dot nodes that were created in shader translation, as they're no longer needed in MaterialX v1.38.
- Simplify the handling of world-space nodes in shader translation and texture baking.
- Rename MaterialX::connectsToNodeOfCategory to MaterialX::connectsToWorldSpaceNode for clarity.

* Improvements to viewer commands

- Unify the handling of output folders for all generated data (e.g. GLSL, OSL, MDL, and DOT files), defaulting to the source folder of the current material, and applying the MATERIALX_VIEW_OUTPUT_PATH environment variable if set.
- Add an 'I' hotkey which reloads all images from the file system.
- Change the GLSL shader-generation hotkey from 'S' to 'G' for consistency with OSL and MDL.

* Update changelog for recent work

* Optimizations to shader translation and baking

- Remove unneeded system memory copies of baked textures, reducing the memory overhead for baking operations.
- Generalize the logic for texture resolution detection, moving it from the TextureBaker class to ImageHandler::getReferencedImages and MaterialX;;getMaxDimensions.
- Update getShaderNodes to return nodes in a consistent, platform-independent order.
- Improve the handling of default values in shader translation.
- Add an initial viewer command for shader translation.
- Use texture resolution detection by default in viewer baking.

* Documentation updates

- Update viewer documentation for new features.
- Update changelog for recent work.

* Simplify material examples

- Remove colorspace assignments on scalar images (only color values and images are affected by colorspace assignments).
- Remove input bindings to default values.

* Finalize changelog for v1.38.1

* Update development build to 1.38.2

* Improvements to library documentation

- Fix a default color space name in libraries documentation.
- Clarify doc strings in the Standard Surface nodedef.

* Add support for GCC 11

- Add standard headers required in GCC 11 builds.
- Add GCC 11 to automated testing.

* Improvements to render exceptions

- Rename ExceptionShaderRenderError to ExceptionRenderError, clarifying that it handles non-shading render exceptions as well.
- Make the error log argument of the ExceptionRenderError constructor optional.
- Simplify the use of ExceptionRenderError in GLSL and OSL rendering.

* Add GLSL roughness guards

This changelist adds guards for invalid roughness values in the GLSL implementations of conductor_bsdf, dielectric_bsdf, and generalized_schlick_bsdf, providing more consistent visual behavior for shading models that implement their own roughness computations.

* Improvements to library documentation

- Add initial documentation for the BxDF graph library.
- Note the current status of OSL reference implementations.
- Clarify language and unify formatting.

* Add support for command-line baking in MaterialXView (#651)

* Add initial Lama BxDF node definitions and tests. (#643)

* Fix issue with generation of input metadata in OSL (#656)

This change list fixes an issue with metadata generation for inputs of type Vector2, Vector4 and Color4. These types are custom structs in OSL, and metadata declarations with value assignments for structs are not supported. The OSL compiler raise a syntax error in these cases.

With this change we prevent metadata generation for these types, so it's just a workaround. A proper fix would be to support this on OSL side, and preferably let these data types become first class native data types in OSL.

* Improve transparency heuristic (#657)

- Additional logic for the handling of nodegraph and nodedef configurations including more complete upstream traversal.
- Add in new tests for transparency.

* Initial shader translation graph

This changelist introduces an initial shader translation graph from Standard Surface to UsdPreviewSurface, along with a simple Python script that converts MaterialX documents between shading models.

* Fix real-world unit target inheritance (#663)

Target inheritance for unit system patched. Similar to previous patch for color system.
Inherited targets will properly find ancestor implementations.

* Minor test changes for derived target usage (#665)

- Minor change to OSLC test build option for clarity
- Cleanup html script to allow for named targets to be used vs hard-coded glsl and osl
- Call base whitelist to allow for common items to be set to ignore during test.

* Fix regression that tokens can show up in shadernode interfaces. (#664)

* Fix default value for USD preview surface roughness implementation (#660)

Fix to use correct value for roughness of USD preview surface.

* Fix channel names in OpenImageIO writing

This changelist addresses the assignment of incorrect channel names in OpenImageIO writing, by switching from the default ImageSpec constructor to one that assigns default channel names after the channel count is known.

* GLSL code structure cleanup (#658)

- Add explicit casts for improved compatibility.
- Add support for vertex inputs outside of structures.

* Static analysis fixes

- Remove unused assignments of output pointers.
- Use a standard vector to represent a graph stack.
- Remove an unused variable from isTransparentShaderGraph.
- Clarify the interface of isTransparentShaderGraph.

* Update changelog for recent work

* Update Disney BRDF paper links

* Improvements to shader generation (#677)

- Update color space names and methods to follow ACES 1.2 conventions (e.g. lin_rec709, g22_rec709), while maintaining compatibility with legacy names (e.g. gamma22).
- Improve sharing of code and constants for color transforms (e.g. defining mx_srgb_texture_to_lin_rec709 just once per shading language).  Ultimately, we can improve this sharing further by defining color transforms as graphs.
- Remove unneeded includes in GLSL shader generation (e.g. pbrlib support in pure pattern graphs).

* Optimizations to GLSL generation

- Move PBS-specific code from mx_math to mx_microfacet.
- Remove unused code from mx_math.

* Optimizations to shader generation (#679)

- Merge duplicate shading inputs for filtered importance sampling.
- Merge helper methods for artistic IOR.
- Remove an extra include for lit materials in GLSL.

* Node flattening issue fix (#672)

* uimin/uimax/uisoftmax added to UsdPreviewSurface parameters (#680)

* Move ScopedTimer to MaterialXRender (#681)

This changelist refactors the ScopedTimer class and moves it from MaterialXTest to MaterialXRender, making timing facilities available across rendering implementations.

* Optimization to texture baking

Clear the image cache after each set of shader inputs is baked, in order to reduce the system memory overhead for processing materials with multiple UDIMs.

* Static analysis fixes

- Assign explicitly-defaulted constructors to vector and matrix classes.
- Use std::make_shared in node creation methods.
- Prefer std::array to std::vector for immutable data.
- Add null checks for missing viewer materials.
- Additional minor simplifications to code.

* Additional color space updates

This changelist makes two additional updates to the default color space names, based on feedback from Doug Walker:
- Use the standard "rec709_display" instead of "g24_rec709".
- Use the standard "acescg" as the preferred name, with "lin_ap1" being a supported alias.

* Transfer material attributes in upgrade

This changelist improves the upgrade logic for legacy MaterialX documents, transferring any custom attributes present in a material element to its corresponding material node.

* Fix typo in OSL cm implementation (#687)

* Fix typos in MDL color management

* Update changelog for recent work

* Add rational curve fit for sheen albedo (#690)

* Improvements to sheen rendering (#691)

- Add a ground-truth GPU Monte Carlo mode for sheen albedo.
- Add a GPU-generated table mode for sheen albedo, and make this the default in the viewer.
- Update curve constants for sheen albedo based on newly-generated data.
- Increase the minimum sheen roughness to 0.005, in order to avoid rendering artifacts in Monte Carlo mode.
- Minor clarity improvements to directional albedo functions.

* Add rational curve fit for GGX albedo (#692)

This changelist adds a rational curve fit for GGX directional albedo, as a potential replacement for the classic Karis mobile approximation. The new rational curve is generally more accurate at grazing angles than the Karis approximation, while maintaining comparable shading complexity.

* Fix inconsistency in mix nodes default value (#697)

* Improved rational curve fit for sheen albedo (#698)

This changelist improves the rational curve fit for sheen directional albedo, generating results that are significantly closer to Monte Carlo reference for low roughness values.

Additionally, it increases the size of the directional albedo table to 128, allowing a correct match for sheen direction albedo when table-based rendering is used.

* Update MaterialXView to handle multiple meshes. (#699)

* Improved rational curve fit for GGX albedo (#700)

This changelist improves the visual quality of the rational curve fit for GGX albedo, generating results that are very close to Monte Carlo ground truth.  Since this improvement comes at the cost of additional shader instructions, it's worthwhile to discuss the tradeoffs before moving forward.

* File template naming update for TextureBaker (#702)

Added file template naming and updated naming for baked texture filenames.
* Template variables include: `$ASSET`, `$INPUT`, `$EXTENSION`, `$NAMEPATH`, `$MATERIAL`, `$SHADINGMODEL`, `$UDIM`, `$UDIMPREFIX`
* Variable values are inferred accordingly
  * For example, `$ASSET` is inferred from the output socket's `activeSourceUri`
* Note `$UDIMPREFIX` and `$UDIM` is only added when udims are detected
* Default filename template is `$MATERIAL_$SHADINGMODEL_$INPUT$UDIMPREFIX$UDIM.$EXTENSION`
* Adding `.$EXTENSION` in template is optional (`.$EXTENSION` will be added if not specified)

* Use VNDF sampling for GGX directional albedo (#706)

This changelist updates the Monte Carlo computation for GGX directional albedo to use VNDF sampling (http://jcgt.org/published/0007/04/01/paper.pdf), creating a notable improvement in its accuracy. Additionally, the rational quadratic fit for for GGX directional albedo has been rebuilt from the latest Monte Carlo data, creating a smoother, more accurate fit.

* ESSL code generator addition (#693)

Web merge part 2: ESSL code generator

Previous check-in has modified other GLSL code snippets and shader node code generators to produce ESSL and GLSL compliant code such as avoiding explicit casts. This formally introduces a new generator to which shares existing GLSL code but is injected in into the final shader in a custom manner.

This change includes the following:
1. Refactors some of the underlying code in the GLSL generator to be modularized into virtual methods which can be overridden by the derived ESSL shader class.
2. Some pertinent points including modifying the language directives, and not initializing any uniforms.
3. From a usage perspective:
    - Include Python wrappers for this generator and add in a Python utility to allow arbitrary language output. (`generateshader`)
    -  Add the ability to output ESSL source code from MaterialXView
4. ESSL implementation checking uses `generateshader` as part of CI.
5. `glslang` is setup as part of CI with `glslangValidator` being invoked for ESSL and GLSL syntax checking of vertex and pixel shader stages. (Note: This covers all of the `pbr` library nodes + some stdlib nodes based on usage in the examples materials. 
basic infrastructure is now available.)
(Note: Actual WASM testing is not part of this check-in but will use this generator. ) As part of this CI has been modified a bit to reduce the number of builds for pushes vs PRs.
6. Some minor additional fixes for GLSL / ESSL source code implementation compliance in the pbr library.

* Documentation updates

- Update directional albedo naming conventions for recent work.
- Update changelog for recent work.

* Static analysis fixes

Clarify null checks for ColorManagementSystemPtr and UnitSystemPtr arguments in shader generation.

* Finalize changelog for v1.38.2

* Update development build to 1.38.3

* Add support for Xcode 13

- Suppress NanoGUI warnings for Xcode 13.
- Add Xcode 13 to automated testing.

* Main page updates

- Update project description to align with recent work and collaborations.
- Update links to pre-built binaries.
- Add a link to the ASWF OSD 2021 slide deck.

* Set transmission roughness to zero in UsdPreviewSurface (#718)

* Texture filename template naming variable fix (#721)

* Main page updates

- Minor refinements to the introduction.
- Add the MaterialX logo.

* Initial clang-format file

This changelist adds an initial clang-format file to the MaterialX project, allowing developers to align their code to its conventions on demand.

For now, the use of Clang formatting is optional, and we should consider its integration into automated testing as we gain more experience with its usage.

The new clang-format file requires Clang 13 or newer, as it leverages newly-added formatting options for lambdas (https://clang.llvm.org/docs/ClangFormatStyleOptions.html).

* Clarify interface of getGeometryBindings

This changelist clarifies the interface of the getGeometryBindings function, expressing its first argument more precisely as a ConstNodePtr, and adding a missing default value for its second argument.

* Add version defines to MaterialXCore

This changelist adds preprocessor definitions for the API version to MaterialXCore, allowing applications to detect version details at compile time.

The new preprocessor definitions are accessed through a Version.h file that is generated at MaterialX build time.

* Fix skipped inputs in createUIPropertyGroups

This changelist fixes a bug that caused shader inputs to be skipped in createUIPropertyGroups.

Instead of computing breadth-first indices in a dedicated (and inaccurate) method, we now compute exact depth-first indices by traversing the document tree in advance.

The original inaccurate method has been removed, as it is otherwise unused in the MaterialX codebase.

* Improvements to Linux Clang support

- Add Linux Clang 9, 11, and 12 builds to the GitHub Actions matrix.
- Improve compiler handling in MaterialXRenderGlsl and MaterialXView.
- Minor refinements to generateshader.py testing.

* Upgrade to Xcode 12.5.1

This changelist upgrades GitHub Actions builds to Xcode 12.5.1, as Xcode 12.5 has been removed from the MacOS 11 virtual environment.

* Fix search path for XML stream loading (#707)

The XML stream loading path does not take into consideration search paths.
This affects cases such as when an xinclude is in being loaded from memory.
This makes the functionality orthogonal to the file based XML API.

Note: this in memory xinclude workflow can be used for loading for web browsing.

Additional small API addition to set current file path.

* Add color transforms to Image class

This changelist adds two color transform methods to the Image class in MaterialXRender, Image::applyMatrixTransform and Image::applyGammaTransform.  Additionally, it adds an Image::copy method that supports changes of channel count and base type.

* Apply Clang formatting to MaterialXCore

This changelist applies Clang formatting to the C++ source in MaterialXCore, providing improvements in coding style consistency.  Additionally, a new setting for preprocessor directive formatting has been added to the root clang-format file.

* Fix order of installation settings

This changelist fixes the order of installation settings in the root CMakeLists.txt, making sure that MATERIALX_INSTALL_STDLIB_PATH is defined before it is referenced.

* Apply Clang formatting to MaterialXFormat

This changelist applies Clang formatting to the C++ source in MaterialXFormat, providing improvements in coding style consistency.

* Refactoring of BSDF handling in shader generation (#747)

This change list is a refactor of some concepts for BSDF handling in MaterialX shader generation. The two main changes are:

**1. Propagation of BSDF throughput**

In BSDF evaluation the result has been separated into _response_ and _throughput_. Response is the normal fraction of light reflected, while throughput is the remaining fraction of light transmitted after reflection and absorption. For opaque substances this throughput is always zero, since all light that is not reflected is then absorbed. A typical example is conductors/metals. But for dielectric media light can transmit, possibly through multiple vertical layers, and here the throughput is used to track the fraction of light remaining as it arrives at each interface in a layer stack.

This makes it possible to calculate vertical layering on any two BSDF's or mixtures of BSDF's. This was not possible before when vertical layering was done by transforming the BSDF layer operator graph into a nesting of BSDFs, and only a limited number of BSDFs support such nested layering.

The new changes applies mainly to GLSL codegen. For now it also applies to OSL codegen, since we currently calculate vertical layering in shader code, outside from the closures. For longer term, when the OSL reference closures are implemented, this should be handled inside the closures instead. For MDL only BSDF nesting can be used for layering, so this change does not apply there. Other improvements can be done on MDL side to support more layering configuration, by transforming the layering graphs, but his is future work and not part of this change list. If an unsupported configuration is found MDL will for now just render the top BSDF as if it was opaque.

**2. Propagation of BSDF parameters**

Setting of BSDF parameters for thin-film was previously done by direct assignment from the top thin-film layer to the base BSDF layer it applies to. Hence layering of thin-film could only be done directly on top of an atomic BSDF node.

In this change list we instead propagate these closure parameters through the BSDF network. For example, if the thin-film is applied to a BSDF mix node the parameters will propagate to both BSDF components upstream. If it's applied to a BSDF layer node it will be applied to only the top component upstream. Hence it's possible to apply thin-film to both atomic BSDFs, mixtures and layer stacks. This can be extended to include other layering parameters in the future.

This change also applies mainly to GLSL and OSL. For MDL there is an explicit node handling thin-film so it does not apply there.

**Other changes**

- Some improvements towards supporting VDF's with the BSDF-over-VDF version of the layer operator.
- Cleanup of legacy elements in test suite documents.
- Adding missing class export directives.

* Fix the incorrect package version in CMake file (#749)

* Optimizations to GLSL shading (#748)

- Move filtered importance sampling from world space to tangent space.
- Move NDF and PDF computations from world space to tangent space.
- Pass alpha arguments as vec2, allowing additional SIMD optimizations to be stated explicitly.

* FreeBSD support. (#734)

* Add support for rough nodedef matches

This changelist adds support for rough nodedef matches, where a node contains additional inputs not found in its nodedef declaration.  This matching approach has been applied to shader nodes in code generation, allowing a roughly-matching shader node to render with warnings, rather than completely failing to render.

* Add include statements for PATH_MAX on linux and FreeBSD. (#733)

* Update changelog for recent work

* Update writelooks.py for 1.38.3

This changelist updates Python script 'writelooks.py' for the 1.38.3 API.  Moving forward, we should consider more modern replacements for the Materials/Examples/Syntax folder and its associated Python scripts, but for now we're preserving them and updating this script to the latest API.

* Merge of additional fixes after BSDF refactor (#758)

* Fix issue with getting implementations for nodedefs with inheritance.
* Fix regression with vertex data prefix.

* Build matrix improvements

- Add coverage for Visual Studio 2022
- Add coverage for shared libraries and Python 2 on Linux Clang.
- Add render testing for Linux Clang.
- Simplify shader validations tests for readability.

* Refactor TextureBaker and add support for baking material subsets (#745)

* Removed `createBakeDocuments`. 
* Created function `bakeMaterialToDoc` (contains functionality nested in the loop of `createBakeDocuments` which iterated through each `renderablePath`).
* Moved public facing `bakeMaterial` to protected `generateBakedDocumentFromShader`.

* FreeBSD compatibility patch (#761)

* Install cmake files into lib/cmake, not just cmake. (#762)

cmake files are commonly installed into lib/cmake.

* Update PyBind11 to version 2.7.1 (#760)

* Add Python 3.9 to build matrix

This changelist adds Python 3.9 to the build matrix in GitHub Actions, leveraging support for this version of Python in PyBind11 2.7.1.

* Add material discovery utilities (#743)

* `NodeGraph::getMaterialOutputs` : return any outputs connected to an graph material node
* `Node::getMaterialOutputs` : return any outputs of type material.
* `MaterialAssign::getMaterialOutputs` : return any outputs on assigned nodegraphs which have outputs of type material. Uses the Nodegraph method.
* `Document::getMaterialOutputs` : return any outputs on nodegraphs which have outputs of type material. Uses the Nodegraph method. Note that implementation nodegraphs are ignored.

* Fix viewer performance for multi-UDIM assets (#765)

This changelist fixes a regression in the performance of the MaterialX viewer for multi-UDIM assets, which was caused by unbinding geometries between the rendering of each mesh partition.

Additionally, it adds the helper method GeometryHandler::findParentMesh, which is used to clarify mesh and shader binding logic in Viewer::renderFrame.

* Streamline property binding in GlslProgram

- Merge dual paths for property binding in GlslProgram, removing the older bindInputs/unbindInputs path.
- Clarify the implementation of GlslProgram::unbindGeometry.
- Remove unneeded geometry unbinding steps in the viewer.

* Deterministic codegen (#767)

This change list adds some changes to make codegen deterministic, always producing the same code from the same input data.

* Change connection storage on ShaderOutput from set to vector to make connection ordering deterministic.
* Make ShaderGraph topological sort order independent of std::unorder_map implementation.
* Add test for deterministic codegen.

* Improvements to mesh names

- For improved readability and compactness, use the term 'name' for mesh/partition name strings in MaterialXRender.
- Track the source names of partitions when they are merged or split.
- Add handling for source names in viewer mesh assignment.

* Add Camera class to MaterialXRender

This changelist adds an initial Camera class to the MaterialXRender library, merging the original ViewHandler class with the MaterialXView camera, and adding viewport projection methods previously provided by NanoGUI.

* Update for Vulkan compliance in GLSL codegen (#769)

- Fix usage of keyword "sampler" in code
- Update `generateShader` script to support Vulkan code and uniform layout code generation.
- Add test to CI using `glslValidaitor` with Vulkan option.

* Unify GLSL light handling

- Unify light handling between MaterialXRenderGlsl and MaterialXView, reducing code duplication.
- Align naming conventions for light IDs in GLSL.
- Add input arguments to GlslProgram::bindTimeAndFrame, allowing applications to override its default values.

* Support nodedef/nodegraph associations via implementation elements (#754)

- Add ability to find a nodedef / nodegraph definition via an implementation.
- Update "standard surface" to allow for 2 versions to be specified in the library.

* Improvements to document versioning

- Add an upgradeVersion option to XmlReadOptions, allowing clients to disable version upgrading in utilities.
- Add warnings for unsupported and future document versions in validation.

* Update changelog for recent work

* Update CMake config file (#780)

- Stores shared library state for downstream Windows clients
- Adds utility paths found in legacy FindMaterialX.cmake
- Fixes config file location to follow CMake guidelines

Tested by building USD on Windows using generated config files of a MaterialX built with shared libraries.

* Fix output type of blackbody node

This changelist fixes the output type of the blackbody node, aligning it with the specification.

* Re-expose virtual callback to emit light functions (#784)

This callback was removed in PR #747. We restore it so USD can keep using it in their codegen.

* OSL image structure support (#782)

- Modify code generation to query and pass on colorspace information to top level uniforms. 
- Change OSL filename syntax to be a structure. Current members include `filename` and `colorspace` but more can be added (such as for udim information which is currently additional arguments)
- Update OSL color3 / color4 image implementations to accept structure as input. Use string tokens to output arguments to texture() calls.
- Modify Syntax / TypeSyntax interface to accept string value extraction based on ShaderPort (which has typed inputs/outputs).
- Modify OSL shader code generation to emit structure as input argument.
- Modify GLSL introspection to query for colorspace information. Only used for reflection currently.
- Add new GenOption options to indicate whether to emit transforms if a color transform is found. Default is set to true.

* Custom namespace and library naming support (#785)

* Align formatting for standard_surface

* Apply Clang formatting to MaterialXCore

* Give access to class derived from SurfaceNodeGLSL (#789)

One such class is the SurfaceNodeMaya as used by MayaUSD.

* Update changelog for recent work

* Finalize changelog for v1.38.3

* Clarify changelog text

* Update development build to 1.38.4

* Update main page for ASWF transition

- Remove Lucasfilm renders from the main page and viewer documentation, in preparation for the transition of MaterialX to the Academy Software Foundation.
- Update image alignment on the main page and viewer documentation.

* Improved handling for empty materials

- Add a null check to getShaderNodes, handling the case where a material node has no implementation.
- Add a check for empty material nodes in Node::validate.

* Improved document validation

- Add validation for node interfaces when standard libraries are present in a document.
- Fix errors caught by the new validation logic.
- Remove the older example Looks.mtlx, which no longer passes validation or reflects current usage.

* Improvements to Windows build testing

- Create a separate step for vcpkg installation on Windows.
- Add an optional step for OpenImageIO installation on Windows.
- Simplify runtime path handling on Windows.

* Improvements to build matrix

- Add Python 3.9 builds for all platforms.
- Update compiler versions on MacOS.
- Suppress warnings in Windows setup.

* Add reference GLSL implementation for Worley Noise nodes. (#776)

This adds the reference implementation to `lib/mx_noise.glsl` and new `.glsl` functions that call into the noise library.  `stdlib_genglsl_impl.mtlx` was modified to call the new functions.
This is the implementation as discussed on the ASWF slack.

* Improvements to standard libraries

- Remove unneeded guards in GLSL albedo table lookups.
- Improve robustness of the GLSL implementation of normalmap.
- Fix the default output of heighttonormal.

* Add include guards for ESSL

* Web Update Part 3 : Javascript Wrappers  (#709)

- Adds JS wrappers which cover MaterialXCore, MaterialXFormat, and sufficient wrappers for OpenES code generation.
- Uses Emscripten for wrapper generation as part of CI.
- Unit tests include basic non-browser tests + non-interactive browser test.
- JS MaterialXView sample view uses generation to feed into Three.js for interactive browser. Tests are limited to default sample Materials for now, and can be run using a local server.
- The JS MaterialXView example also updates a `gh-pages` branch as part of CI. A public github page can be created allowing for a supported browser to execute the run the viewer found in this branch. By default the published page can be: `materialx.github.io` with the folder `MaterialX` containing the viewer contents.

* Remove Draco dependency for speed

* Enable single-commit deployment

* Fix shader compilation in albedo table generation (#807)

The albedo table shader fails to compile because DIRECTIONAL_ALBEDO_METHOD is not defined.
DIRECTIONAL_ALBEDO_METHOD gets defined if and only if lighting nodes are found (see GlslShaderGenerator::requiresLighting)

* Ensure CMake configuration relocatability (#805)

- All install paths must be relative for CMake to generate a relocatable config file. This means removing all `CMAKE_INSTALL_PREFIX` components that point to an absolute path.
- Patch to handle non-python MaterialX config generation.

* Port Worley noise GLSL implementation to MDL (#809)

Straightforward port from GLSL to MDL shader code.

* Fix MDL sheen BSDF (#786)

Similar to the other BSDFs, mx_sheen_bsdf also needs to pass the volume properties to the next layer.

* Initial implementation of Worley noise for OSL (#810)

Adds an initial implementation of Worley noise for OSL.

The hash is not yet identical to the one used by the GLSL and MDL implementations (an unsigned int right shift operator is missing in OSL). As discussed we will ignore this for now and we will refine this later to get identical results.

* Improved OSL render testing (#811)

- Clarify the names of OSL test options, giving them a consistent MATERIALX_OSL prefix.
- Move the list of render test paths from code to data, adding a "renderTestPaths" option to options.mtlx.
- Manually convert relative paths in OSL render tests, working around an issue in testrender on Windows.
- Add support for launching MaterialXTest directly from Visual Studio.
- Fix typos in the transparency regression check for MaterialXGenShader.

* Add PyElement.getDescendant (#813)

* Ensure libMaterialXRenderHw has a dependency on libXt (#753)

After linking a program against a MaterialX build I made recently on Linux, I got this error on execution:

Error: /blah/libMaterialXRenderHw.so: undefined symbol: topLevelShellWidgetClass

On inspection, the problem was that `libMaterialXRenderHw.so` wasn't declaring a dependency on `libXt.so`. When I inspected the CMake source, I found this was because RenderHw wasn't doing a `find_package(X11)` - so that even though it calls `target_link_libraries(${X11_Xt_LIB})`, it does nothing because `${X11_Xt_LIB}` hasn't been populated yet.

* Improvements to render test parity (#814)

This changelist implements a number of improvements to the parity of render tests between GLSL and OSL, including the following:

- Render with a unit sphere in both GLSL and OSL, adjusting the zoom in OSL to compensate for framing differences.
- Increase the environment map sample count in GLSL.
- Increase the rays per pixel for lit surfaces in OSL.
- Increase the tolerance for error messages in testrender.

* Fix up HTML generator for tests. (#815)

Fixes the following:

- Adding to source destination lists incorrectly, producing source on one row and destination on another.
- Cleaned up to use source to determine destination file name by replacing language to avoid name mismatches per row. - If exists as source file, then append destination file. e.g. if foo.glsl.png found then foo.osl.png is added. The second file is not checked until generation time.
- Fix to allow only one language to be shown (again) if both destination and source languages are the same.

* Security updates for JS dependencies (#1352) (#816)

* Remap texcoord indices in MaterialXView

- Remap unsupported texcoord indices in MaterialXView, allowing materials with multiple texcoords to be roughly visualized.
- Add exception handling to renderFrame in MaterialXView.

* Improvements to reference OSL shaders

- Remove the original, hardcoded set of reference OSL shaders, which no longer reflect the current specification.
- Improve the reference OSL shader generation and validation in GenReference.cpp.
- Upload reference OSL shaders as an artifact in GitHub Actions.
- Move shared OSL includes to a dedicated folder (libraries/stdlib/genosl/include).

* Fix to OBJ geometry: sphere and plane (#819)

- Align sphere geometry and UV origin border line with z-axis.
- Orient plane geometry so UVs are not flipped in V.
- Remove additional extra UV transform which was used to try and align UVs properly.

* Upgrade to latest NanoGUI

This changelist upgrades MaterialXView to the latest version of NanoGUI, providing initial access to its support for Metal and WASM code generation.

See https://github.com/mitsuba-renderer/nanogui for more details on the NanoGUI framework.

* Update OSL to latest directional albedo

This changelist updates OSL code generation to the latest analytic approximation for directional albedo, improving the parity of BSDF renders between OSL and other languages.

For simplicity, the two alternative methods for computing directional albedo in OSL have been removed, since they achieved nearly identical results in a less efficient way.

* Refinements to GGX directional albedo (#826)

This changelist refines the constants for the analytic approximation to GGX directional albedo in MaterialX.  The latest constants have been fitted to a Monte Carlo simulation with 16K samples per pixel, and reduce the average error from 0.0022 to 0.0012.

Additional improvements:
- Add an "Albedo Method" combo box to MaterialXView, with its set of options being "Analytic", "Table", and "MC".
- Update the resource paths in MaterialXView to match the latest CMake build process.

* Add V-flip option for geometry loaders (#825)

- Allows for customization on load allowing for tangent space to be computed on load
- Used for GLSL render unit testing when the specified geometry is the "stock" sphere or plane.
- Turn off texture flip as a consequence of flipping texture coordinates.
- Also simplified testing logic to either use the geometry file if specified or default to the stock sphere otherwise.

* Default to analytic albedo in MaterialXView

- Default to using analytic directional albedo in MaterialXView, only generating a directional albedo table when requested by the user.
- Clamp the AB term in analytic directional albedo, providing a small improvement in accuracy (reduces average error from 0.0012 to 0.0011, and improves behavior at parameter boundaries).

* Add new signatures for cellnoise (#829)

Add new signatures for cellnoise to support higher dimensions of seed, but also to generate Vec3 results.  These methods are consistent with the OSL implementation of cellnoise.

Change Worley noise to use cellnoise to pick the offsets in the cell (rather than mx_hash_vec3()).  This is a more generic form that only uses public API calls in OSL so it can be implemented without any changes to the core OSL library.

* Clarify usage of alpha and roughness

This changelist clarifies the usage of the terms alpha and roughness in the PBR libraries for GLSL and OSL, using the term 'alpha' to mean the square of artist-facing roughness in the context of specular BSDFs.

In the future, we should consider modifying the interfaces of specular BSDF nodes such as <dielectric_bsdf> and <conductor_bsdf> to follow this convention as well, since their "roughness" inputs actually represent alpha.

Additional changes:
- Align handling of input alpha between GLSL and OSL.
- Remove unused helper functions in the PBR library for OSL.

* Refinements to GGX directional albedo (#831)

- Improve the precision of the computation in mx_ggx_dir_albedo_monte_carlo, moving the global component of the geometric term outside of the sample loop.
- Rebuild the constants in mx_ggx_dir_albedo_analytic using MATLAB.

* OSL Reference Generation Updates (#833)

Minor fixes for the following:

- Add in ignore list to skip definitions which have no implementations.
- Fix include search path for OSL renderer. Syntax was incorrect, and did not handle multiple paths.
- Fix to add in proper search path for inlines if not running compilation test.
- Fix to avoid emitting absolute paths for includes and instead handle this via the compilation time check by adding in include search paths.
- Add in failure condition for any unexpected generation. Could fail without detection before.

* Add OSL node name metadata  (#834)

Add in metadata at the shader level which outputs the node category and qualified name.

* Adoption of new Worley noise implementation for OSL (#836)

Adopting the new Worley noise implementation written by @code-monkey. The results are now identical between GLSL and OSL, and there is no longer any code duplication since the implementation uses OSL's built-in cellnoise functions.

* Make fractal3d node consistent between GLSL and OSL (#838)

Improve GLSL implementation to make fractal3d results consistent with OSL.

* Improvements to OSL tangent frame (#844)

- Generate normalized tangent and bitangent vectors in vanilla OSL.
- Generate custom tangent and bitangent vectors for the parametric sphere in testrender, aligning them with Lengyel/Mikkelsen conventions for a polygonal sphere.
- Add a reference quality option for render tests.

* GLSL mx_fresnel_conductor now uses physically correct function (#843)

The previous implementation was an optimization, and gave incorrect results when "k" approached zero.
This change improves alignment with offline renderers.

* Port noise improvements to MDL (#842)

This changelist ports the recent improvements to noise in GLSL/OSL to MDL.

Results should now be consistent between all three languages.

* Material test suite cleanup

- Remove value attributes that are overridden by node connections.
- Remove explicit assignments of default values.
- Remove legacy xpos and ypos attributes with screen-space coordinates.

* Improvements to convolution render tests

This changelist improves the render test suite for convolution nodes, clarifying the extent of their current implementation in MaterialX code generation.

Additionally, it restores the originally-intended value for blur filter size, which was lost in the upgrade from 1.37 to 1.38.

* Update to standard Apache License 2.0

This changelist updates the MaterialX project to a standard Apache License 2.0, in preparation for its transition to the Academy Software Foundation.

* Make addInputFromNodeDef consider inheritance (#837)

Based on discussion with @niklasharrysson on Slack Node::addInputFromNodeDef should consider inherited inputs.

* Clarify Fresnel logic in GLSL

- Add constants for Fresnel model indices.
- Separate FresnelData parameters for physical and generalized Schlick models.
- Move shared initializations to an mx_init_fresnel_data function.

* Fix typo in MDL thin_surface (#855)

* Update mxdoc node definition script (#851)

- Add support for `html` output as an option in addition to `Markdown`
- Add in additional attributes not currently output per attribute: `doc`, `uiname`
- Add in `output` and `token` port attribute support
- Add in `version`, `isdefaultversion`, and `inherit`. For inheritance, allow to emit inherited attributes as an option.
- For testing: add in html output for python tests as part of CI actions.

* Update contribution guidelines for ASWF

This changelist updates the contribution guidelines for the MaterialX project within the Academy Software Foundation.

* Fix for code generation from multioutput graphs (#853)

* Optimize GitHub Actions testing

- Disable shadow maps in virtual framebuffer renders.
- Remove duplication of render tests between GCC and Clang.

Supporting changes:
- Add a 'shadowMap' command-line option to MaterialXView.
- Align render settings conventions between MaterialXRender and MaterialXView.

* Shader generation token resolution (#845)

Update to make code generation (or any resolver call) correctly perform token substitution. Can handle token elements within a node, a nodegraph and at the Document level. Those tokens which are closest in level to the input are considered higher priority than those at higher levels.

* Update main page links for ASWF

This changelist updates links on the main page, reflecting the new location of the MaterialX project within the ASWF organization on GitHub.

* GLTF geometry loader using cgltf library. (#846)

GLTF geometry-only loader

* Uses cgltf for loading
* Converts transform instancing into instances of geometry as this is not supported by the Mesh geometry classes and the viewer.
* Auto generates uvs, normals and tangents if not found.
* Does not handle materials or texture dependencies
* The viewer logic has been updated to handle multiple meshes.

* An unlit surface shader constructor node (#860)

Implementation of the "unlit" surface shader, as proposed in issue #839.

This change list adds the definitions and implementations for GLSL, OSL and MDL.

* Fix range node graphs

This changelist fixes the handling of clamp functionality in the graph definitions of the range node, and updates related test materials for clarity.

* Remove test coverage for color2 type

This changelist removes legacy test coverage for the color2 data type, which is no longer present in MaterialX 1.38.

* Update changelog for recent work

* Add glTF PBR (#861)

This PR adds a node definition and implementation of the glTF PBR material with the following extensions:
* KHR_materials_transmission
* KHR_materials_specular
* KHR_materials_ior
* KHR_materials_sheen
* KHR_materials_clearcoat
* KHR_materials_volume

* Remove legacy syntax examples

This changelist removes the legacy material examples in the Materials/Examples/Syntax folder.

These examples were useful references in earlier versions of MaterialX, but they have since been superseded by renderable examples in the Materials/Examples and Materials/TestSuite folders.

* Remove hardcoded search path string

This changelist removes a hardcoded inclusion of the "libraries" string in calls to GenContext::registerSourceCodeSearchPath, giving control back to include directives to specify which top-level folder is intended.

As a result, applications with custom code generators will need to remove this string from their own calls to GenContext::registerSourceCodeSearchPath when they upgrade to MaterialX 1.38.4.

Supporting changes include:
- Give precedence to user-supplied libraries over the standard libraries in MaterialXView, generateshader.py, and translateshader.py.
- Minor fixes to texture baking in MaterialXView.

* Upgrade light nodes

This changelist upgrades all light nodes used in hardware shading to the 1.38 standard, refining their documentation for clarity.

* Command-line viewer improvements

This changelist makes the following improvements to command-line usage of MaterialXView:

- Add support for filename arguments that are relative to the current working directory.
- Compile optional shaders on demand, providing a small performance improvement for command-line renders.

* Update changelog for recent work

* Update PyBind11 to version 2.9.0

* Fix "show all inputs" option in MaterialXView (#869)

- At load time node definition inputs are added to each node.
- This allows shader gen to take these into consideration.
- At UI building time the inputs will exist for usage.

* Initial third-party license file

This changelist moves third-party licenses from their original LICENSE.txt to a dedicated THIRD-PARTY.md file, following the pattern of other projects within the ASWF.

Also, add LICENSE and THIRD-PARTY.md to the installation process, making these files part of MaterialX releases.

* Static analysis fixes

- Remove const keyword from Shader::setSourceCode.
- Assign explicitly-defaulted constructor to the ShCoeffs class.
- Use consistent letter case for GLFramebuffer and related classes.
- Clarify logic in GLTextureHandler::mapFilterTypeToGL and Viewer::initCamera.

* Improvements to testing and TextureBaker (#883)

Testing updates:
- Create data model to define wedge and baking testing parameters in options.mtlx
- Add test case for material nodegraph translation 

TextureBaker updates:
- Add a uv min/max settings and update GlslRenderer::renderTextureSpace to set the uv range for the baking quad.
- Enable hashing for baked image names to avoid long path issues.

* Add glTF BoomBox example (#870)

- Add in BoomBox example from Ed Mackey. Minor name change to shader and material so it's easier to read results.
- Add in `GltfPbr` directory for generation tests and render tests.
- As part of this fixed OSL tests to work if any new test file uses relative resource pathing by pre-processing these paths beforehand.

* Minor updates / corrections to Javascript documentation. (#893)

- Fix up some incorrect / outdated information
- Update with info on sample build scripts

* Additional improvements to surface_unlit

- Assign a unique name to the new node, in order to avoid name collisions in applications with dynamic node typing (i.e. where node types are inferred from connections).
- Set the default value of the emission scalar input to 1.

* Improvements to geometric constants

- Add Python bindings for all geometric constants (e.g. UDIM_TOKEN, UV_TILE_TOKEN).
- Clarify the name of the UDIM_SET_PROPERTY constant.

* Simplify MaterialXCore includes

- Remove duplicate header includes in MaterialXCore.
- Include Generated.h before defining platform macros in Library.h.

* Move Quaternion class to MaterialXRender

This changelist moves the Quaternion class from MaterialXCore to MaterialXRender, clarifying its role as a camera/render helper class rather than a core MaterialX data type.

* JavaScript viewer update (#895)

- Add USD and glTF as loadable materials.
- Add in geometry switcher to select glTF files to load.
- Fix texture flipping.
- Fix when default url options not set.
- Update camera to more closely match desktop viewer.
- For boombox example add in images and image path mapping. Search pathing has not been added to viewer so adding to manual mapping.
- Fixed up geometric stream loading so there is fallback geometry if the load fails, and if there are no uvs or normals they are generated. This prevents tangent generation from failing if either of those does not exist and hence failing on a series of GL errors.
- Add some very basic parameter control.

* Finalize changelog for v1.38.4

* Update development build to 1.38.5

* Update main page links

This changelist updates links to pre-built binaries on the main page.

* Static analysis fixes

- Fix mismatched namespace macros.
- Fix const correctness in BIND_VECTOR_SUBCLASS.
- Remove unused variables, classes, and includes.
- Add unit test for readFromXmlBuffer.

* Update TestSuite to align with main

* Pass strings by const reference

This changelist updates a handful of common methods to pass strings by const reference rather than by value.

* Initial static analysis in GitHub Actions

This changelist adds an initial static analysis test to GitHub Actions, running cppcheck on the C++ codebase for each commit to the repository.

Also, two related improvements:
- Clarify the handling of the unique_ptr in TypeDesc::registerType.
- Clarify the order of reads and writes to a union in Half::toFloat16.

* Improvements to MaterialXView

- Improve OpenGL state handling, addressing an environment clipping error caused by changes in the sphere geometry.
- Simplify the writing of shader source to disk, reusing viewport shaders when they're already present.

* Build fix

* Fix UI min/max range for subsurface_anisotropy in Standard Surface (#911)

* Add emissive strength to glTF PBR (#910)

* Refactor Web MaterialXView (#909)

* Create Viewer, Editor, Material and Scene classes to organize functionality
* Change material and geometry changes to not reload the entire page causing everything to be re-initialized. Instead perform incremental updates.
* Small fix to get any UI names if looking up an interface input

* Use qualified names in getDownstreamPorts (#890)

This changelist fixes the issue with flattenSubgraphs described in #865.

* Fix environment preview for viewer (#913)

The environment material used for 3d preview was not being recompiled when changing the environment.
Hence the scene was rendering using the new environment, but the preview was not.

* Improvements to support locale and units (#892)

- Add utilities UnitConverterRegistry::convertToUnit and MaterialX::joinStrings.
- Use C Locale for string stream operations (https://github.com/autodesk-forks/MaterialX/issues/1183).
- Add tests for unit and locale content.

* Improved color consistency of backgrounds

- Align screen background colors between MaterialXView, MaterialXRenderGlsl, and MaterialXRenderOsl.
- Add helper methods to transform colors between linear RGB and the sRGB encoding.

* IMP_UsdPrimvarReader reader fixes (#915)

As per discussions on MaterialX slack channel, this implements...
- the "fallback" parameter in IMP_UsdPrimvarReader
- also makes the default parameter in ND_geompropvalue_integer non-uniform

* Update resources to remove adsk_contrib changes

* Add Export.mtlx for Runtime

* Improvements to locale unit tests

- Restore the original locale after unit tests are complete, so that render tests are unaffected by the change.
- Simplify locale unit tests, removing steps that aren't required.

* TempFix: Disable SUPPORT_ARNOLD_CONTEXT_STRING

* Build fix

* .js buildfix

* Fix sample sphere geometry (#917)

An interior test plane was left inside the sphere geometry.
Removing it as it affects transparent objects as well as environment preview in MaterialXView.

* Restoring two missing test files

* Initial refraction approximation in GLSL (#918)

This changelist introduces a rough approximation of refraction in GLSL, allowing transmissive materials such as glass to respond visually to changes in specular_IOR, specular_roughness, and transmission_color.

Because this initial approximation is limited to a single render pass, only the environment radiance map is currently visible in refractions, and opaque objects behind transmissive surfaces are not yet visible.

* Update generator search path in JavaScript

This changelist updates the generator search path used in MaterialX JavaScript, aligning it with other generators in the MaterialX codebase.

* Simplify Python bindings for ShaderGenerator

This changelist simplifies Python bindings for the base ShaderGenerator class, making it concrete rather than abstract, and removing the PyShaderGenerator trampoline class.

Co-authored-by: Jonathan Stone <jstone@lucasfilm.com>
Co-authored-by: Bernard Kwok <Bernard.Kwok@autodesk.com>
Co-authored-by: marsupial <marsupial@users.noreply.github.com>
Co-authored-by: Mark Tucker <mtucker@sidefx.com>
Co-authored-by: Niklas Harrysson <niklas.harrysson@gmail.com>
Co-authored-by: dlarsson-adobe <68669897+dlarsson-adobe@users.noreply.github.com>
Co-authored-by: K. S. Ernest (iFire) Lee <fire@users.noreply.github.com>
Co-authored-by: kngo-lucasfilm <86328732+kngo-lucasfilm@users.noreply.github.com>
Co-authored-by: Brian Sharpe <brisharpe@yahoo.com>
Co-authored-by: Madeleine Yip <52723401+mjyip-lucasfilm@users.noreply.github.com>
Co-authored-by: Bernard Kwok <kwokcb@gmail.com>
Co-authored-by: yuri@FreeBSD <yurivict@users.noreply.github.com>
Co-authored-by: Mark Elendt <mark@sidefx.com>
Co-authored-by: Tobias Häußler <mail@tobiashaeussler.com>
Co-authored-by: Paul Molodowitch <elrond79@gmail.com>
Co-authored-by: Rasmus Bonnedal <rasmus.bonnedal@gmail.com>
Co-authored-by: ZapAndersson <102356572+ZapAndersson@users.noreply.github.com>
Co-authored-by: Jerry Gamache <jerry.gamache@autodesk.com>
ashwinbhat added a commit that referenced this issue Jul 22, 2022
* Additional color space updates

This changelist makes two additional updates to the default color space names, based on feedback from Doug Walker:
- Use the standard "rec709_display" instead of "g24_rec709".
- Use the standard "acescg" as the preferred name, with "lin_ap1" being a supported alias.

* Transfer material attributes in upgrade

This changelist improves the upgrade logic for legacy MaterialX documents, transferring any custom attributes present in a material element to its corresponding material node.

* Fix typo in OSL cm implementation (#687)

* Fix typos in MDL color management

* Update changelog for recent work

* Add rational curve fit for sheen albedo (#690)

* Improvements to sheen rendering (#691)

- Add a ground-truth GPU Monte Carlo mode for sheen albedo.
- Add a GPU-generated table mode for sheen albedo, and make this the default in the viewer.
- Update curve constants for sheen albedo based on newly-generated data.
- Increase the minimum sheen roughness to 0.005, in order to avoid rendering artifacts in Monte Carlo mode.
- Minor clarity improvements to directional albedo functions.

* Add rational curve fit for GGX albedo (#692)

This changelist adds a rational curve fit for GGX directional albedo, as a potential replacement for the classic Karis mobile approximation. The new rational curve is generally more accurate at grazing angles than the Karis approximation, while maintaining comparable shading complexity.

* Fix inconsistency in mix nodes default value (#697)

* Improved rational curve fit for sheen albedo (#698)

This changelist improves the rational curve fit for sheen directional albedo, generating results that are significantly closer to Monte Carlo reference for low roughness values.

Additionally, it increases the size of the directional albedo table to 128, allowing a correct match for sheen direction albedo when table-based rendering is used.

* Update MaterialXView to handle multiple meshes. (#699)

* Improved rational curve fit for GGX albedo (#700)

This changelist improves the visual quality of the rational curve fit for GGX albedo, generating results that are very close to Monte Carlo ground truth.  Since this improvement comes at the cost of additional shader instructions, it's worthwhile to discuss the tradeoffs before moving forward.

* File template naming update for TextureBaker (#702)

Added file template naming and updated naming for baked texture filenames.
* Template variables include: `$ASSET`, `$INPUT`, `$EXTENSION`, `$NAMEPATH`, `$MATERIAL`, `$SHADINGMODEL`, `$UDIM`, `$UDIMPREFIX`
* Variable values are inferred accordingly
  * For example, `$ASSET` is inferred from the output socket's `activeSourceUri`
* Note `$UDIMPREFIX` and `$UDIM` is only added when udims are detected
* Default filename template is `$MATERIAL_$SHADINGMODEL_$INPUT$UDIMPREFIX$UDIM.$EXTENSION`
* Adding `.$EXTENSION` in template is optional (`.$EXTENSION` will be added if not specified)

* Use VNDF sampling for GGX directional albedo (#706)

This changelist updates the Monte Carlo computation for GGX directional albedo to use VNDF sampling (http://jcgt.org/published/0007/04/01/paper.pdf), creating a notable improvement in its accuracy. Additionally, the rational quadratic fit for for GGX directional albedo has been rebuilt from the latest Monte Carlo data, creating a smoother, more accurate fit.

* ESSL code generator addition (#693)

Web merge part 2: ESSL code generator

Previous check-in has modified other GLSL code snippets and shader node code generators to produce ESSL and GLSL compliant code such as avoiding explicit casts. This formally introduces a new generator to which shares existing GLSL code but is injected in into the final shader in a custom manner.

This change includes the following:
1. Refactors some of the underlying code in the GLSL generator to be modularized into virtual methods which can be overridden by the derived ESSL shader class.
2. Some pertinent points including modifying the language directives, and not initializing any uniforms.
3. From a usage perspective:
    - Include Python wrappers for this generator and add in a Python utility to allow arbitrary language output. (`generateshader`)
    -  Add the ability to output ESSL source code from MaterialXView
4. ESSL implementation checking uses `generateshader` as part of CI.
5. `glslang` is setup as part of CI with `glslangValidator` being invoked for ESSL and GLSL syntax checking of vertex and pixel shader stages. (Note: This covers all of the `pbr` library nodes + some stdlib nodes based on usage in the examples materials. 
basic infrastructure is now available.)
(Note: Actual WASM testing is not part of this check-in but will use this generator. ) As part of this CI has been modified a bit to reduce the number of builds for pushes vs PRs.
6. Some minor additional fixes for GLSL / ESSL source code implementation compliance in the pbr library.

* Documentation updates

- Update directional albedo naming conventions for recent work.
- Update changelog for recent work.

* Static analysis fixes

Clarify null checks for ColorManagementSystemPtr and UnitSystemPtr arguments in shader generation.

* Finalize changelog for v1.38.2

* Update development build to 1.38.3

* Add support for Xcode 13

- Suppress NanoGUI warnings for Xcode 13.
- Add Xcode 13 to automated testing.

* Main page updates

- Update project description to align with recent work and collaborations.
- Update links to pre-built binaries.
- Add a link to the ASWF OSD 2021 slide deck.

* Set transmission roughness to zero in UsdPreviewSurface (#718)

* Texture filename template naming variable fix (#721)

* Main page updates

- Minor refinements to the introduction.
- Add the MaterialX logo.

* Initial clang-format file

This changelist adds an initial clang-format file to the MaterialX project, allowing developers to align their code to its conventions on demand.

For now, the use of Clang formatting is optional, and we should consider its integration into automated testing as we gain more experience with its usage.

The new clang-format file requires Clang 13 or newer, as it leverages newly-added formatting options for lambdas (https://clang.llvm.org/docs/ClangFormatStyleOptions.html).

* Clarify interface of getGeometryBindings

This changelist clarifies the interface of the getGeometryBindings function, expressing its first argument more precisely as a ConstNodePtr, and adding a missing default value for its second argument.

* Add version defines to MaterialXCore

This changelist adds preprocessor definitions for the API version to MaterialXCore, allowing applications to detect version details at compile time.

The new preprocessor definitions are accessed through a Version.h file that is generated at MaterialX build time.

* Fix skipped inputs in createUIPropertyGroups

This changelist fixes a bug that caused shader inputs to be skipped in createUIPropertyGroups.

Instead of computing breadth-first indices in a dedicated (and inaccurate) method, we now compute exact depth-first indices by traversing the document tree in advance.

The original inaccurate method has been removed, as it is otherwise unused in the MaterialX codebase.

* Improvements to Linux Clang support

- Add Linux Clang 9, 11, and 12 builds to the GitHub Actions matrix.
- Improve compiler handling in MaterialXRenderGlsl and MaterialXView.
- Minor refinements to generateshader.py testing.

* Upgrade to Xcode 12.5.1

This changelist upgrades GitHub Actions builds to Xcode 12.5.1, as Xcode 12.5 has been removed from the MacOS 11 virtual environment.

* Fix search path for XML stream loading (#707)

The XML stream loading path does not take into consideration search paths.
This affects cases such as when an xinclude is in being loaded from memory.
This makes the functionality orthogonal to the file based XML API.

Note: this in memory xinclude workflow can be used for loading for web browsing.

Additional small API addition to set current file path.

* Add color transforms to Image class

This changelist adds two color transform methods to the Image class in MaterialXRender, Image::applyMatrixTransform and Image::applyGammaTransform.  Additionally, it adds an Image::copy method that supports changes of channel count and base type.

* Apply Clang formatting to MaterialXCore

This changelist applies Clang formatting to the C++ source in MaterialXCore, providing improvements in coding style consistency.  Additionally, a new setting for preprocessor directive formatting has been added to the root clang-format file.

* Fix order of installation settings

This changelist fixes the order of installation settings in the root CMakeLists.txt, making sure that MATERIALX_INSTALL_STDLIB_PATH is defined before it is referenced.

* Apply Clang formatting to MaterialXFormat

This changelist applies Clang formatting to the C++ source in MaterialXFormat, providing improvements in coding style consistency.

* Refactoring of BSDF handling in shader generation (#747)

This change list is a refactor of some concepts for BSDF handling in MaterialX shader generation. The two main changes are:

**1. Propagation of BSDF throughput**

In BSDF evaluation the result has been separated into _response_ and _throughput_. Response is the normal fraction of light reflected, while throughput is the remaining fraction of light transmitted after reflection and absorption. For opaque substances this throughput is always zero, since all light that is not reflected is then absorbed. A typical example is conductors/metals. But for dielectric media light can transmit, possibly through multiple vertical layers, and here the throughput is used to track the fraction of light remaining as it arrives at each interface in a layer stack.

This makes it possible to calculate vertical layering on any two BSDF's or mixtures of BSDF's. This was not possible before when vertical layering was done by transforming the BSDF layer operator graph into a nesting of BSDFs, and only a limited number of BSDFs support such nested layering.

The new changes applies mainly to GLSL codegen. For now it also applies to OSL codegen, since we currently calculate vertical layering in shader code, outside from the closures. For longer term, when the OSL reference closures are implemented, this should be handled inside the closures instead. For MDL only BSDF nesting can be used for layering, so this change does not apply there. Other improvements can be done on MDL side to support more layering configuration, by transforming the layering graphs, but his is future work and not part of this change list. If an unsupported configuration is found MDL will for now just render the top BSDF as if it was opaque.

**2. Propagation of BSDF parameters**

Setting of BSDF parameters for thin-film was previously done by direct assignment from the top thin-film layer to the base BSDF layer it applies to. Hence layering of thin-film could only be done directly on top of an atomic BSDF node.

In this change list we instead propagate these closure parameters through the BSDF network. For example, if the thin-film is applied to a BSDF mix node the parameters will propagate to both BSDF components upstream. If it's applied to a BSDF layer node it will be applied to only the top component upstream. Hence it's possible to apply thin-film to both atomic BSDFs, mixtures and layer stacks. This can be extended to include other layering parameters in the future.

This change also applies mainly to GLSL and OSL. For MDL there is an explicit node handling thin-film so it does not apply there.

**Other changes**

- Some improvements towards supporting VDF's with the BSDF-over-VDF version of the layer operator.
- Cleanup of legacy elements in test suite documents.
- Adding missing class export directives.

* Fix the incorrect package version in CMake file (#749)

* Optimizations to GLSL shading (#748)

- Move filtered importance sampling from world space to tangent space.
- Move NDF and PDF computations from world space to tangent space.
- Pass alpha arguments as vec2, allowing additional SIMD optimizations to be stated explicitly.

* FreeBSD support. (#734)

* Add support for rough nodedef matches

This changelist adds support for rough nodedef matches, where a node contains additional inputs not found in its nodedef declaration.  This matching approach has been applied to shader nodes in code generation, allowing a roughly-matching shader node to render with warnings, rather than completely failing to render.

* Add include statements for PATH_MAX on linux and FreeBSD. (#733)

* Update changelog for recent work

* Update writelooks.py for 1.38.3

This changelist updates Python script 'writelooks.py' for the 1.38.3 API.  Moving forward, we should consider more modern replacements for the Materials/Examples/Syntax folder and its associated Python scripts, but for now we're preserving them and updating this script to the latest API.

* Merge of additional fixes after BSDF refactor (#758)

* Fix issue with getting implementations for nodedefs with inheritance.
* Fix regression with vertex data prefix.

* Build matrix improvements

- Add coverage for Visual Studio 2022
- Add coverage for shared libraries and Python 2 on Linux Clang.
- Add render testing for Linux Clang.
- Simplify shader validations tests for readability.

* Refactor TextureBaker and add support for baking material subsets (#745)

* Removed `createBakeDocuments`. 
* Created function `bakeMaterialToDoc` (contains functionality nested in the loop of `createBakeDocuments` which iterated through each `renderablePath`).
* Moved public facing `bakeMaterial` to protected `generateBakedDocumentFromShader`.

* FreeBSD compatibility patch (#761)

* Install cmake files into lib/cmake, not just cmake. (#762)

cmake files are commonly installed into lib/cmake.

* Update PyBind11 to version 2.7.1 (#760)

* Add Python 3.9 to build matrix

This changelist adds Python 3.9 to the build matrix in GitHub Actions, leveraging support for this version of Python in PyBind11 2.7.1.

* Add material discovery utilities (#743)

* `NodeGraph::getMaterialOutputs` : return any outputs connected to an graph material node
* `Node::getMaterialOutputs` : return any outputs of type material.
* `MaterialAssign::getMaterialOutputs` : return any outputs on assigned nodegraphs which have outputs of type material. Uses the Nodegraph method.
* `Document::getMaterialOutputs` : return any outputs on nodegraphs which have outputs of type material. Uses the Nodegraph method. Note that implementation nodegraphs are ignored.

* Fix viewer performance for multi-UDIM assets (#765)

This changelist fixes a regression in the performance of the MaterialX viewer for multi-UDIM assets, which was caused by unbinding geometries between the rendering of each mesh partition.

Additionally, it adds the helper method GeometryHandler::findParentMesh, which is used to clarify mesh and shader binding logic in Viewer::renderFrame.

* Streamline property binding in GlslProgram

- Merge dual paths for property binding in GlslProgram, removing the older bindInputs/unbindInputs path.
- Clarify the implementation of GlslProgram::unbindGeometry.
- Remove unneeded geometry unbinding steps in the viewer.

* Deterministic codegen (#767)

This change list adds some changes to make codegen deterministic, always producing the same code from the same input data.

* Change connection storage on ShaderOutput from set to vector to make connection ordering deterministic.
* Make ShaderGraph topological sort order independent of std::unorder_map implementation.
* Add test for deterministic codegen.

* Improvements to mesh names

- For improved readability and compactness, use the term 'name' for mesh/partition name strings in MaterialXRender.
- Track the source names of partitions when they are merged or split.
- Add handling for source names in viewer mesh assignment.

* Add Camera class to MaterialXRender

This changelist adds an initial Camera class to the MaterialXRender library, merging the original ViewHandler class with the MaterialXView camera, and adding viewport projection methods previously provided by NanoGUI.

* Update for Vulkan compliance in GLSL codegen (#769)

- Fix usage of keyword "sampler" in code
- Update `generateShader` script to support Vulkan code and uniform layout code generation.
- Add test to CI using `glslValidaitor` with Vulkan option.

* Unify GLSL light handling

- Unify light handling between MaterialXRenderGlsl and MaterialXView, reducing code duplication.
- Align naming conventions for light IDs in GLSL.
- Add input arguments to GlslProgram::bindTimeAndFrame, allowing applications to override its default values.

* Support nodedef/nodegraph associations via implementation elements (#754)

- Add ability to find a nodedef / nodegraph definition via an implementation.
- Update "standard surface" to allow for 2 versions to be specified in the library.

* Improvements to document versioning

- Add an upgradeVersion option to XmlReadOptions, allowing clients to disable version upgrading in utilities.
- Add warnings for unsupported and future document versions in validation.

* Update changelog for recent work

* Update CMake config file (#780)

- Stores shared library state for downstream Windows clients
- Adds utility paths found in legacy FindMaterialX.cmake
- Fixes config file location to follow CMake guidelines

Tested by building USD on Windows using generated config files of a MaterialX built with shared libraries.

* Fix output type of blackbody node

This changelist fixes the output type of the blackbody node, aligning it with the specification.

* Re-expose virtual callback to emit light functions (#784)

This callback was removed in PR #747. We restore it so USD can keep using it in their codegen.

* OSL image structure support (#782)

- Modify code generation to query and pass on colorspace information to top level uniforms. 
- Change OSL filename syntax to be a structure. Current members include `filename` and `colorspace` but more can be added (such as for udim information which is currently additional arguments)
- Update OSL color3 / color4 image implementations to accept structure as input. Use string tokens to output arguments to texture() calls.
- Modify Syntax / TypeSyntax interface to accept string value extraction based on ShaderPort (which has typed inputs/outputs).
- Modify OSL shader code generation to emit structure as input argument.
- Modify GLSL introspection to query for colorspace information. Only used for reflection currently.
- Add new GenOption options to indicate whether to emit transforms if a color transform is found. Default is set to true.

* Custom namespace and library naming support (#785)

* Align formatting for standard_surface

* Apply Clang formatting to MaterialXCore

* Give access to class derived from SurfaceNodeGLSL (#789)

One such class is the SurfaceNodeMaya as used by MayaUSD.

* Update changelog for recent work

* Finalize changelog for v1.38.3

* Clarify changelog text

* Update development build to 1.38.4

* Update main page for ASWF transition

- Remove Lucasfilm renders from the main page and viewer documentation, in preparation for the transition of MaterialX to the Academy Software Foundation.
- Update image alignment on the main page and viewer documentation.

* Improved handling for empty materials

- Add a null check to getShaderNodes, handling the case where a material node has no implementation.
- Add a check for empty material nodes in Node::validate.

* Improved document validation

- Add validation for node interfaces when standard libraries are present in a document.
- Fix errors caught by the new validation logic.
- Remove the older example Looks.mtlx, which no longer passes validation or reflects current usage.

* Improvements to Windows build testing

- Create a separate step for vcpkg installation on Windows.
- Add an optional step for OpenImageIO installation on Windows.
- Simplify runtime path handling on Windows.

* Improvements to build matrix

- Add Python 3.9 builds for all platforms.
- Update compiler versions on MacOS.
- Suppress warnings in Windows setup.

* Add reference GLSL implementation for Worley Noise nodes. (#776)

This adds the reference implementation to `lib/mx_noise.glsl` and new `.glsl` functions that call into the noise library.  `stdlib_genglsl_impl.mtlx` was modified to call the new functions.
This is the implementation as discussed on the ASWF slack.

* Improvements to standard libraries

- Remove unneeded guards in GLSL albedo table lookups.
- Improve robustness of the GLSL implementation of normalmap.
- Fix the default output of heighttonormal.

* Add include guards for ESSL

* Web Update Part 3 : Javascript Wrappers  (#709)

- Adds JS wrappers which cover MaterialXCore, MaterialXFormat, and sufficient wrappers for OpenES code generation.
- Uses Emscripten for wrapper generation as part of CI.
- Unit tests include basic non-browser tests + non-interactive browser test.
- JS MaterialXView sample view uses generation to feed into Three.js for interactive browser. Tests are limited to default sample Materials for now, and can be run using a local server.
- The JS MaterialXView example also updates a `gh-pages` branch as part of CI. A public github page can be created allowing for a supported browser to execute the run the viewer found in this branch. By default the published page can be: `materialx.github.io` with the folder `MaterialX` containing the viewer contents.

* Remove Draco dependency for speed

* Enable single-commit deployment

* Fix shader compilation in albedo table generation (#807)

The albedo table shader fails to compile because DIRECTIONAL_ALBEDO_METHOD is not defined.
DIRECTIONAL_ALBEDO_METHOD gets defined if and only if lighting nodes are found (see GlslShaderGenerator::requiresLighting)

* Ensure CMake configuration relocatability (#805)

- All install paths must be relative for CMake to generate a relocatable config file. This means removing all `CMAKE_INSTALL_PREFIX` components that point to an absolute path.
- Patch to handle non-python MaterialX config generation.

* Port Worley noise GLSL implementation to MDL (#809)

Straightforward port from GLSL to MDL shader code.

* Fix MDL sheen BSDF (#786)

Similar to the other BSDFs, mx_sheen_bsdf also needs to pass the volume properties to the next layer.

* Initial implementation of Worley noise for OSL (#810)

Adds an initial implementation of Worley noise for OSL.

The hash is not yet identical to the one used by the GLSL and MDL implementations (an unsigned int right shift operator is missing in OSL). As discussed we will ignore this for now and we will refine this later to get identical results.

* Improved OSL render testing (#811)

- Clarify the names of OSL test options, giving them a consistent MATERIALX_OSL prefix.
- Move the list of render test paths from code to data, adding a "renderTestPaths" option to options.mtlx.
- Manually convert relative paths in OSL render tests, working around an issue in testrender on Windows.
- Add support for launching MaterialXTest directly from Visual Studio.
- Fix typos in the transparency regression check for MaterialXGenShader.

* Add PyElement.getDescendant (#813)

* Ensure libMaterialXRenderHw has a dependency on libXt (#753)

After linking a program against a MaterialX build I made recently on Linux, I got this error on execution:

Error: /blah/libMaterialXRenderHw.so: undefined symbol: topLevelShellWidgetClass

On inspection, the problem was that `libMaterialXRenderHw.so` wasn't declaring a dependency on `libXt.so`. When I inspected the CMake source, I found this was because RenderHw wasn't doing a `find_package(X11)` - so that even though it calls `target_link_libraries(${X11_Xt_LIB})`, it does nothing because `${X11_Xt_LIB}` hasn't been populated yet.

* Improvements to render test parity (#814)

This changelist implements a number of improvements to the parity of render tests between GLSL and OSL, including the following:

- Render with a unit sphere in both GLSL and OSL, adjusting the zoom in OSL to compensate for framing differences.
- Increase the environment map sample count in GLSL.
- Increase the rays per pixel for lit surfaces in OSL.
- Increase the tolerance for error messages in testrender.

* Fix up HTML generator for tests. (#815)

Fixes the following:

- Adding to source destination lists incorrectly, producing source on one row and destination on another.
- Cleaned up to use source to determine destination file name by replacing language to avoid name mismatches per row. - If exists as source file, then append destination file. e.g. if foo.glsl.png found then foo.osl.png is added. The second file is not checked until generation time.
- Fix to allow only one language to be shown (again) if both destination and source languages are the same.

* Security updates for JS dependencies (#1352) (#816)

* Remap texcoord indices in MaterialXView

- Remap unsupported texcoord indices in MaterialXView, allowing materials with multiple texcoords to be roughly visualized.
- Add exception handling to renderFrame in MaterialXView.

* Improvements to reference OSL shaders

- Remove the original, hardcoded set of reference OSL shaders, which no longer reflect the current specification.
- Improve the reference OSL shader generation and validation in GenReference.cpp.
- Upload reference OSL shaders as an artifact in GitHub Actions.
- Move shared OSL includes to a dedicated folder (libraries/stdlib/genosl/include).

* Fix to OBJ geometry: sphere and plane (#819)

- Align sphere geometry and UV origin border line with z-axis.
- Orient plane geometry so UVs are not flipped in V.
- Remove additional extra UV transform which was used to try and align UVs properly.

* Upgrade to latest NanoGUI

This changelist upgrades MaterialXView to the latest version of NanoGUI, providing initial access to its support for Metal and WASM code generation.

See https://github.com/mitsuba-renderer/nanogui for more details on the NanoGUI framework.

* Update OSL to latest directional albedo

This changelist updates OSL code generation to the latest analytic approximation for directional albedo, improving the parity of BSDF renders between OSL and other languages.

For simplicity, the two alternative methods for computing directional albedo in OSL have been removed, since they achieved nearly identical results in a less efficient way.

* Refinements to GGX directional albedo (#826)

This changelist refines the constants for the analytic approximation to GGX directional albedo in MaterialX.  The latest constants have been fitted to a Monte Carlo simulation with 16K samples per pixel, and reduce the average error from 0.0022 to 0.0012.

Additional improvements:
- Add an "Albedo Method" combo box to MaterialXView, with its set of options being "Analytic", "Table", and "MC".
- Update the resource paths in MaterialXView to match the latest CMake build process.

* Add V-flip option for geometry loaders (#825)

- Allows for customization on load allowing for tangent space to be computed on load
- Used for GLSL render unit testing when the specified geometry is the "stock" sphere or plane.
- Turn off texture flip as a consequence of flipping texture coordinates.
- Also simplified testing logic to either use the geometry file if specified or default to the stock sphere otherwise.

* Default to analytic albedo in MaterialXView

- Default to using analytic directional albedo in MaterialXView, only generating a directional albedo table when requested by the user.
- Clamp the AB term in analytic directional albedo, providing a small improvement in accuracy (reduces average error from 0.0012 to 0.0011, and improves behavior at parameter boundaries).

* Add new signatures for cellnoise (#829)

Add new signatures for cellnoise to support higher dimensions of seed, but also to generate Vec3 results.  These methods are consistent with the OSL implementation of cellnoise.

Change Worley noise to use cellnoise to pick the offsets in the cell (rather than mx_hash_vec3()).  This is a more generic form that only uses public API calls in OSL so it can be implemented without any changes to the core OSL library.

* Clarify usage of alpha and roughness

This changelist clarifies the usage of the terms alpha and roughness in the PBR libraries for GLSL and OSL, using the term 'alpha' to mean the square of artist-facing roughness in the context of specular BSDFs.

In the future, we should consider modifying the interfaces of specular BSDF nodes such as <dielectric_bsdf> and <conductor_bsdf> to follow this convention as well, since their "roughness" inputs actually represent alpha.

Additional changes:
- Align handling of input alpha between GLSL and OSL.
- Remove unused helper functions in the PBR library for OSL.

* Refinements to GGX directional albedo (#831)

- Improve the precision of the computation in mx_ggx_dir_albedo_monte_carlo, moving the global component of the geometric term outside of the sample loop.
- Rebuild the constants in mx_ggx_dir_albedo_analytic using MATLAB.

* OSL Reference Generation Updates (#833)

Minor fixes for the following:

- Add in ignore list to skip definitions which have no implementations.
- Fix include search path for OSL renderer. Syntax was incorrect, and did not handle multiple paths.
- Fix to add in proper search path for inlines if not running compilation test.
- Fix to avoid emitting absolute paths for includes and instead handle this via the compilation time check by adding in include search paths.
- Add in failure condition for any unexpected generation. Could fail without detection before.

* Add OSL node name metadata  (#834)

Add in metadata at the shader level which outputs the node category and qualified name.

* Adoption of new Worley noise implementation for OSL (#836)

Adopting the new Worley noise implementation written by @code-monkey. The results are now identical between GLSL and OSL, and there is no longer any code duplication since the implementation uses OSL's built-in cellnoise functions.

* Make fractal3d node consistent between GLSL and OSL (#838)

Improve GLSL implementation to make fractal3d results consistent with OSL.

* Improvements to OSL tangent frame (#844)

- Generate normalized tangent and bitangent vectors in vanilla OSL.
- Generate custom tangent and bitangent vectors for the parametric sphere in testrender, aligning them with Lengyel/Mikkelsen conventions for a polygonal sphere.
- Add a reference quality option for render tests.

* GLSL mx_fresnel_conductor now uses physically correct function (#843)

The previous implementation was an optimization, and gave incorrect results when "k" approached zero.
This change improves alignment with offline renderers.

* Port noise improvements to MDL (#842)

This changelist ports the recent improvements to noise in GLSL/OSL to MDL.

Results should now be consistent between all three languages.

* Material test suite cleanup

- Remove value attributes that are overridden by node connections.
- Remove explicit assignments of default values.
- Remove legacy xpos and ypos attributes with screen-space coordinates.

* Improvements to convolution render tests

This changelist improves the render test suite for convolution nodes, clarifying the extent of their current implementation in MaterialX code generation.

Additionally, it restores the originally-intended value for blur filter size, which was lost in the upgrade from 1.37 to 1.38.

* Update to standard Apache License 2.0

This changelist updates the MaterialX project to a standard Apache License 2.0, in preparation for its transition to the Academy Software Foundation.

* Make addInputFromNodeDef consider inheritance (#837)

Based on discussion with @niklasharrysson on Slack Node::addInputFromNodeDef should consider inherited inputs.

* Clarify Fresnel logic in GLSL

- Add constants for Fresnel model indices.
- Separate FresnelData parameters for physical and generalized Schlick models.
- Move shared initializations to an mx_init_fresnel_data function.

* Fix typo in MDL thin_surface (#855)

* Update mxdoc node definition script (#851)

- Add support for `html` output as an option in addition to `Markdown`
- Add in additional attributes not currently output per attribute: `doc`, `uiname`
- Add in `output` and `token` port attribute support
- Add in `version`, `isdefaultversion`, and `inherit`. For inheritance, allow to emit inherited attributes as an option.
- For testing: add in html output for python tests as part of CI actions.

* Update contribution guidelines for ASWF

This changelist updates the contribution guidelines for the MaterialX project within the Academy Software Foundation.

* Fix for code generation from multioutput graphs (#853)

* Optimize GitHub Actions testing

- Disable shadow maps in virtual framebuffer renders.
- Remove duplication of render tests between GCC and Clang.

Supporting changes:
- Add a 'shadowMap' command-line option to MaterialXView.
- Align render settings conventions between MaterialXRender and MaterialXView.

* Shader generation token resolution (#845)

Update to make code generation (or any resolver call) correctly perform token substitution. Can handle token elements within a node, a nodegraph and at the Document level. Those tokens which are closest in level to the input are considered higher priority than those at higher levels.

* Update main page links for ASWF

This changelist updates links on the main page, reflecting the new location of the MaterialX project within the ASWF organization on GitHub.

* GLTF geometry loader using cgltf library. (#846)

GLTF geometry-only loader

* Uses cgltf for loading
* Converts transform instancing into instances of geometry as this is not supported by the Mesh geometry classes and the viewer.
* Auto generates uvs, normals and tangents if not found.
* Does not handle materials or texture dependencies
* The viewer logic has been updated to handle multiple meshes.

* An unlit surface shader constructor node (#860)

Implementation of the "unlit" surface shader, as proposed in issue #839.

This change list adds the definitions and implementations for GLSL, OSL and MDL.

* Fix range node graphs

This changelist fixes the handling of clamp functionality in the graph definitions of the range node, and updates related test materials for clarity.

* Remove test coverage for color2 type

This changelist removes legacy test coverage for the color2 data type, which is no longer present in MaterialX 1.38.

* Update changelog for recent work

* Add glTF PBR (#861)

This PR adds a node definition and implementation of the glTF PBR material with the following extensions:
* KHR_materials_transmission
* KHR_materials_specular
* KHR_materials_ior
* KHR_materials_sheen
* KHR_materials_clearcoat
* KHR_materials_volume

* Remove legacy syntax examples

This changelist removes the legacy material examples in the Materials/Examples/Syntax folder.

These examples were useful references in earlier versions of MaterialX, but they have since been superseded by renderable examples in the Materials/Examples and Materials/TestSuite folders.

* Remove hardcoded search path string

This changelist removes a hardcoded inclusion of the "libraries" string in calls to GenContext::registerSourceCodeSearchPath, giving control back to include directives to specify which top-level folder is intended.

As a result, applications with custom code generators will need to remove this string from their own calls to GenContext::registerSourceCodeSearchPath when they upgrade to MaterialX 1.38.4.

Supporting changes include:
- Give precedence to user-supplied libraries over the standard libraries in MaterialXView, generateshader.py, and translateshader.py.
- Minor fixes to texture baking in MaterialXView.

* Upgrade light nodes

This changelist upgrades all light nodes used in hardware shading to the 1.38 standard, refining their documentation for clarity.

* Command-line viewer improvements

This changelist makes the following improvements to command-line usage of MaterialXView:

- Add support for filename arguments that are relative to the current working directory.
- Compile optional shaders on demand, providing a small performance improvement for command-line renders.

* Update changelog for recent work

* Update PyBind11 to version 2.9.0

* Fix "show all inputs" option in MaterialXView (#869)

- At load time node definition inputs are added to each node.
- This allows shader gen to take these into consideration.
- At UI building time the inputs will exist for usage.

* Initial third-party license file

This changelist moves third-party licenses from their original LICENSE.txt to a dedicated THIRD-PARTY.md file, following the pattern of other projects within the ASWF.

Also, add LICENSE and THIRD-PARTY.md to the installation process, making these files part of MaterialX releases.

* Static analysis fixes

- Remove const keyword from Shader::setSourceCode.
- Assign explicitly-defaulted constructor to the ShCoeffs class.
- Use consistent letter case for GLFramebuffer and related classes.
- Clarify logic in GLTextureHandler::mapFilterTypeToGL and Viewer::initCamera.

* Improvements to testing and TextureBaker (#883)

Testing updates:
- Create data model to define wedge and baking testing parameters in options.mtlx
- Add test case for material nodegraph translation 

TextureBaker updates:
- Add a uv min/max settings and update GlslRenderer::renderTextureSpace to set the uv range for the baking quad.
- Enable hashing for baked image names to avoid long path issues.

* Add glTF BoomBox example (#870)

- Add in BoomBox example from Ed Mackey. Minor name change to shader and material so it's easier to read results.
- Add in `GltfPbr` directory for generation tests and render tests.
- As part of this fixed OSL tests to work if any new test file uses relative resource pathing by pre-processing these paths beforehand.

* Minor updates / corrections to Javascript documentation. (#893)

- Fix up some incorrect / outdated information
- Update with info on sample build scripts

* Additional improvements to surface_unlit

- Assign a unique name to the new node, in order to avoid name collisions in applications with dynamic node typing (i.e. where node types are inferred from connections).
- Set the default value of the emission scalar input to 1.

* Improvements to geometric constants

- Add Python bindings for all geometric constants (e.g. UDIM_TOKEN, UV_TILE_TOKEN).
- Clarify the name of the UDIM_SET_PROPERTY constant.

* Simplify MaterialXCore includes

- Remove duplicate header includes in MaterialXCore.
- Include Generated.h before defining platform macros in Library.h.

* Move Quaternion class to MaterialXRender

This changelist moves the Quaternion class from MaterialXCore to MaterialXRender, clarifying its role as a camera/render helper class rather than a core MaterialX data type.

* JavaScript viewer update (#895)

- Add USD and glTF as loadable materials.
- Add in geometry switcher to select glTF files to load.
- Fix texture flipping.
- Fix when default url options not set.
- Update camera to more closely match desktop viewer.
- For boombox example add in images and image path mapping. Search pathing has not been added to viewer so adding to manual mapping.
- Fixed up geometric stream loading so there is fallback geometry if the load fails, and if there are no uvs or normals they are generated. This prevents tangent generation from failing if either of those does not exist and hence failing on a series of GL errors.
- Add some very basic parameter control.

* Finalize changelog for v1.38.4

* Update development build to 1.38.5

* Update main page links

This changelist updates links to pre-built binaries on the main page.

* Static analysis fixes

- Fix mismatched namespace macros.
- Fix const correctness in BIND_VECTOR_SUBCLASS.
- Remove unused variables, classes, and includes.
- Add unit test for readFromXmlBuffer.

* Pass strings by const reference

This changelist updates a handful of common methods to pass strings by const reference rather than by value.

* Initial static analysis in GitHub Actions

This changelist adds an initial static analysis test to GitHub Actions, running cppcheck on the C++ codebase for each commit to the repository.

Also, two related improvements:
- Clarify the handling of the unique_ptr in TypeDesc::registerType.
- Clarify the order of reads and writes to a union in Half::toFloat16.

* Improvements to MaterialXView

- Improve OpenGL state handling, addressing an environment clipping error caused by changes in the sphere geometry.
- Simplify the writing of shader source to disk, reusing viewport shaders when they're already present.

* Fix UI min/max range for subsurface_anisotropy in Standard Surface (#911)

* Add emissive strength to glTF PBR (#910)

* Refactor Web MaterialXView (#909)

* Create Viewer, Editor, Material and Scene classes to organize functionality
* Change material and geometry changes to not reload the entire page causing everything to be re-initialized. Instead perform incremental updates.
* Small fix to get any UI names if looking up an interface input

* Use qualified names in getDownstreamPorts (#890)

This changelist fixes the issue with flattenSubgraphs described in #865.

* Fix environment preview for viewer (#913)

The environment material used for 3d preview was not being recompiled when changing the environment.
Hence the scene was rendering using the new environment, but the preview was not.

* Improvements to support locale and units (#892)

- Add utilities UnitConverterRegistry::convertToUnit and MaterialX::joinStrings.
- Use C Locale for string stream operations (https://github.com/autodesk-forks/MaterialX/issues/1183).
- Add tests for unit and locale content.

* Improved color consistency of backgrounds

- Align screen background colors between MaterialXView, MaterialXRenderGlsl, and MaterialXRenderOsl.
- Add helper methods to transform colors between linear RGB and the sRGB encoding.

* IMP_UsdPrimvarReader reader fixes (#915)

As per discussions on MaterialX slack channel, this implements...
- the "fallback" parameter in IMP_UsdPrimvarReader
- also makes the default parameter in ND_geompropvalue_integer non-uniform

* Improvements to locale unit tests

- Restore the original locale after unit tests are complete, so that render tests are unaffected by the change.
- Simplify locale unit tests, removing steps that aren't required.

* Fix sample sphere geometry (#917)

An interior test plane was left inside the sphere geometry.
Removing it as it affects transparent objects as well as environment preview in MaterialXView.

* Initial refraction approximation in GLSL (#918)

This changelist introduces a rough approximation of refraction in GLSL, allowing transmissive materials such as glass to respond visually to changes in specular_IOR, specular_roughness, and transmission_color.

Because this initial approximation is limited to a single render pass, only the environment radiance map is currently visible in refractions, and opaque objects behind transmissive surfaces are not yet visible.

* Update generator search path in JavaScript

This changelist updates the generator search path used in MaterialX JavaScript, aligning it with other generators in the MaterialX codebase.

* Simplify Python bindings for ShaderGenerator

This changelist simplifies Python bindings for the base ShaderGenerator class, making it concrete rather than abstract, and removing the PyShaderGenerator trampoline class.

* Update UsdUVTexture to version 2.3 (#919)

* Relative shader includes

This changelist adds support for relative includes of shader source files in code generation, and makes all file includes relative within the MaterialX data libraries.

This allows clients to use arbitrary naming conventions for the root folder of their MaterialX data libraries, with "libraries" being the default name in the MaterialX distribution.

* Fix issue with thin-film in standard_surface implementation (#927)

This change list improves the implementation of standard_surface. The thin-film BSDF operator is now applied to both the dielectric specular BSDF and the metal BSDF, following the Standard Surface specification.

* Add transmission rendering option

This changelist adds an hwTransmissionRenderMethod option to the GenOptions class, selecting the transmission render method in hardware shading languages.

Initially, this option chooses between a single-pass refraction approximation (TRANSMISSION_REFRACTION) and the conversion of transmission to opacity (TRANSMISSION_OPACITY).

* Add missing nodegroup to PBR node definitions (#929)

- Few small updates for Lama nodes so all nodes have `nodegroup`  tags.
- Update Disney bxdf node tags also.
- Update `mxdoc` script to output `nodegroup` if it exists.

* Static analysis fixes

- Remove a duplicated test in UnitConverterRegistry::convertToUnit.
- Clarify an initialization call in the TextureBaker constructor.
- Call string::find_first_of with chars rather than strings for performance.
- Pass file paths by const reference for performance.
- Remove unused variables.

* Reduce viewer test resolution

This changelist reduces the time spent in GitHub Actions builds by reducing the resolution of viewer render tests.

* Transmission shading improvements

- Add support for generalized Schlick transmission in OSL.
- Minor improvements to dielectric transmission in OSL.
- Clamp input values to a stable range in mx_f0_to_ior.

* Initial security policy file

This changelist adds an initial security policy file to the MaterialX project.

* Add CII badge

This changelist adds the CII badge for MaterialX to the main page.

* Improve generated header setup in MaterialXCore (#940)

This PR improves how MaterialXCore generated header is handled in the CMake setup.
It writes generated sources in the build tree rather than the source tree, so the MaterialXCore .gitignore file is not needed anymore.
I have encountered issues with it while developing a materialx port for vcpkg C++ package manager (cf. microsft/vcpkg#24614).

* Fix color attribute parsing in glTF loader (#943)

<geomcolor> wasn't properly working with this asset:
https://github.com/KhronosGroup/glTF-Sample-Models/tree/master/2.0/BoxVertexColors

* Upload MaterialX JavaScript (#944)

- Set up so that CI will upload an artifact for Javascript / WASM libraries
- Add a package.json wrapper to the install directory. This file can be used to publish to npm. (via npm publish).

* Initial governance file

This changelist adds an initial governance file for the MaterialX project, describing the rules and current membership of the MaterialX TSC.

* Normal and tangent fixes (#937)

Fixes to vector normalization and tangent/bitangent transformation in MaterialXGenGlsl and MaterialXRender.

* Fix build error with OSL or MDL disabled (#948)

* Remove legacy gitignore

This changelist removes a gitignore file that is no longer required in MaterialXCore, following the generated header improvements in #940.

* Improve build dependencies

- Include MaterialXGenShader in all builds, allowing dependencies on MaterialXCore to be correctly inherited.
- Exclude MaterialXRenderGlsl and MaterialXRenderOsl when their supporting generators are not present.

* Clarify conversion in toFloat16

This changelist clarifies a float-to-int conversion in Half::toFloat16, removing a dependency on implementation-specific behavior.  Additionally, it extends unit tests to cover values without exact equivalence as float and half.

* Upgrade to Xcode 13.3

This changelist upgrades from Xcode 13.1 to 13.3 in the build matrix, and reorders build steps for clarity when uploading artifacts.

* Initial dynamic analysis in GitHub Actions

This changelist adds an initial dynamic analysis test to GitHub Actions, building and running the standard test suite with Clang sanitizers enabled.

* Optimize build matrix

This changelist redistributes tasks in the GitHub Actions build matrix to reduce build times.

* Update data library documentation

- Update links to MDL declarations and implementations.
- Remove references to the legacy OSL reference library (now superseded by genosl).

* Update developer documentation

- Add documentation for OSL validation options.
- Add documentation for MaterialX versioning.
- Minor reorganization of the page for clarity.

* Fix typo in TransformNormalNodeGlsl

This changelist fixes a typo in TransformNormalNodeGlsl::emitFunctionCall, setting includeType to false so that the output variable is only declared once.

* Static analysis fixes

- Remove a duplicate variable definition in FilePath::getSubDirectories.
- Remove unused variables in BlurNodeMdl::emitFunctionCall.
- Remove an unneeded helper method in SimpleWindow::SimpleWindow.
- Clarify ambiguous logic in EsslShaderGenerator::getVertexDataPrefix.
- Additional minor fixes for correctness.

* Fix TextureBaker image filename bug (#963)

Fix texturebaker regression from image filename hashing.

* Viewer shadow map fix

This changelist addresses an issue with shadow mapping for scenes with multiple meshes in the MaterialX viewer.  Previously, only the first scene mesh was used in computing shadow bounds, and now all scene meshes are taken into account.

* Initial turntable options in viewers (#947)

* Generalize viewer search paths

This changelist generalizes the handling of source search paths in the MaterialX viewer, allowing documents to reference relative image paths from XIncluded content.

* Update Worley noise for compatibility with OSL 1.9.10 (#968)

This change list updates the `vector` accessor syntax from .x .y .z to subscript operator [], to be compatible with older OSL versions that don't support .x .y .z accessors. Since we state 1.9.10 as the minimum supported OSL version.

* Add TSC stakeholder

This changelist adds Brian Savery as the AMD stakeholder on the MaterialX TSC, as confirmed by vote at the last TSC meeting.

* Add alpha to transparency detection

This changelist adds "alpha" to the list of shader inputs that are checked in transparency detection functions (e.g. mx::isTransparentSurface), making them inclusive of the conventions of the glTF PBR shading model.  Materials with non-zero or spatially-varying values for "alpha" will now be considered transparent by renderers that leverage these functions.

* Fix incorrect glTF PBR default input values (#971)

* Fix incorrect transform in genosl (#972)

This changelist updates the transform(matrix, vector4) method in genosl to match a corresponding fix in the OSL codebase.  See https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1513 for more details.

* Update changelog for recent work

* Support multiple folders in render comparisons (#973)

- Add the ability to have difference source folders for different source languages. This allows for the same or different languages to be compared against different runs. Note that the folder structure must still be the same. e.g. can compare OSL in one build with one renderer vs OSL in another build with another renderer.
- Cleanup so that destination files will just try and match source ones to avoid file name mismatch comparisons.

* Restore GCC 6 support

This changelist restores support for GCC 6 in MaterialXRender, extending the GitHub Actions build matrix to include this version of GCC.  The GCC 6 configuration in GitHub Actions is built without MaterialXView, as NanoGUI requires GCC 7 or newer.

* Viewer UI improvements

- Add support for default outputs in the material UI, improving the readability of test suite material examples.
- Remove hotkeys that duplicate checkboxes, in order to keep the interface as simple as possible.

* Build matrix improvements

- Add GCC 12 build to GitHub Actions.
- Add Clang 13 build to GitHub Actions.
- Suppress new warnings in dependencies.

* Update OpenGL loader in MaterialXRenderGlsl

This changelist updates the OpenGL loader in MaterialXRenderGlsl from GLew to glad.  Some advantages of the latter are that it's more lightweight and efficient to build, and that it aligns with the OpenGL loader in the NanoGUI framework.

* Resource folder optimizations

- Remove the OBJ version of the Arnold Shader Ball, making the GLB version the default geometry in the MaterialX viewer.
- Remove the EXR version of the cloth texture example, since this format is supported through an OpenImageIO integration rather than native code.

* Build matrix improvements

- Add Clang 14 build with dynamic analysis to GitHub Actions.
- Reduce viewer test resolution to improve build times.

* Add Chess Set example (#982)

Adds the Chess Set geometry and materials from the Karma: A Beautiful Game tutorial.  Original artwork and assets by Moeen Sayed and Mujtaba Sayed.

* Support for code generation from material nodes (#981)

This change list adds support for generating shaders directly from material type nodes. Previously material nodes were terminals from which we first extracted shader nodes to generate code from. Now we can generate code from these nodes directly and include custom logic for them.

This change is foundational work towards having support for double-sided materials, which will be added in a future change list (issue tracked here #864).

* Update changelog for recent work

* Fix regressions with light shader node in GLSL (#984)

This change list fixes a regression with light shader generation for GLSL. This should fix issue #964.

* Static analysis fixes

- Add const and override modifiers for clarity.
- Remove duplicate namespace qualifiers.
- Remove duplicate null checks.

* Add orthographic option to viewer

This changelist adds an orthographic projection option to the MaterialX viewer, selected by setting 'cameraViewAngle' to zero.

* Improve BSDF fallbacks in OSL

This changelist improves the fallbacks for subsurface_bsdf and translucent_bsdf in vanilla OSL, providing better visual parity across languages for the MaterialX Chess Set.

* Minor fixes to mx_fresnel_airy in GLSL (#989)

- Removed unused variable R21
- Updated link to Laurent Belcour's paper

* Add look support to Web Viewer (#990)

- Parse looks found in MaterialX files and use this to perform assignment. In the case where no assignment matches any geometry in the scene then the first material is assigned to the entire scene. Supports rudimentary regexpr string matching of names.
- Keep track of material assignments and compile unique set of shaders once and assign after 1) material load, 2) geometry change. The latter allows for material to be loaded first and geometry second to have the same result as the reverse.
- Will load UI for all materials found via looks. Add back in "hide" controls as the material list can take up more space.

* Simplify color transforms in GLSL and OSL (#993)

- Simplify the GLSL and OSL implementations of mx_srgb_texture_to_lin_rec709, improving their alignment with standard references such as https://en.wikipedia.org/wiki/SRGB.
- Add a shared M_AP1_TO_REC709 matrix to OSL, following the pattern for this transform in GLSL.

* Transmission rendering improvements in GLSL (#994)

- Unify transmission computations between GLSL render options, addressing inconsistencies in the interaction between transmission and surface opacity.
- Add support for transmission refraction using prefiltered environment maps.
- Remove duplicated energy compensation in prefiltered environment maps.

* Moved setConnectedOutput from Input to PortElement (#995)

* Improved persistence of viewer settings

This changelist makes MaterialX viewer settings "cameraPosition" and "cameraViewAngle" persistent when the user loads a new mesh, providing a more consistent experience when validating materials across multiple meshes.

* Fix spelling in GlslProgram::addStage

This changelist fixes the spelling of "sourceCode" in the GlslProgram::addStage method.

* Add v-flip option in JavaScript geometry loading (#1001)

- Add in a flip "V" for geometry load. This is a generally useful option.
- The option is currently always enabled for geometry which is loaded. This is to be consistent in orientation with desktop and orientation used for 2d placement.
- Images when loaded to GPU have an option to be flipped. This is now enabled based on the geometry orientation option (which is true).

* Initial FilePath normalization in shader generation (#1004)

* Add in new `FilePath::getNormalized()` which will normalize and return a new `FilePath`. For now only sequential "." paths are removed. Possible additions include collapsing intermediate ".." paths.
* This means that we no longer have a  mismatch between "./<foo>" and "././<foo>" as they are both the same paths
but just happen to hold different path strings. New test added for this.
* Added to `GenContext::resolveSourceFile()` to avoid duplicate source code includes during shader generation as the `FilePath` is used as the unique dictionary key.
* Added to `FileFormat flattenFilenames()` utility to make to closer to a true "flatten".

* Fix shader translation unit tests (#1006)

Clear cached graph member so it cannot be accidently reused. CI tests would not catch this as a new instance
of a ShaderTranslator was created for each test thus no possibility of reusing the same.
Change unit test to actually fail vs check failure.

* Update shading model display (#1007)

This changelist updates the shading model display in MaterialXView, adding handling for renderable material nodes in 1.38.5.

* Simplify graph logic in translateShader

This changelist simplifies the graph selection logic in ShaderTranslator::translateShader, clarifying its intended handling of edge cases.

* Vulkan GLSL shader generation (#1002)

Vulkan Shaders use SPIRV but they are written using a variant of GLSL.
This variant of GLSL that conforms to Vulkan specification has a few semantic differences. see KHR_vulkan_glsl

This new VkShaderGenerator builds upon existing GLSLShaderGenerator and add Vulkan semantics in the generated GLSL code.

The MaterialX Test code exercises the VkShaderGenerator. In a future change, we will introduce validation and test rendering.

* Improvements to FilePath::getNormalized (#1009)

- Add support for parent path references.
- Extend unit tests to cover additional cases.
- Clarify documentation.

* Enable generation from material nodes (#1010)

Remove conversion of material nodes to surface shader nodes now that material nodes are supported.

* Update changelog for recent work

* Python binding for VkShaderGenerator (#1014)

Example usage:
python\Scripts\generateshader.py resources/Materials/Examples/StandardSurface/standard_surface_gold.mtlx --path .. **--target vulkan** --validator c:\VulkanSDK\1.3.204.1\Bin\glslangValidator.exe

* Fixed linker errors in PyMaterialX subdirectory (#1016)

When `MATERIALX_BUILD_RENDER` is `ON` and `MATERIALX_BUILD_GEN_GLSL` is `OFF` (the same happens with OSL) `MaterialXRenderGlsl` library is not built (which is nice) but the Python module for it is still built, which results in linker errors.
This commit skip adding the Python bindings for the RenderGlsl and/or RenderOsl libs, depending on the corresponding CMake option.

* Change material type name in generated OSL (#1020)

This change list updates the name of data type 'material' in generated OSL code. This is to resolve a naming conflict were the name "material" is already used in some OSL systems.

* Fix numerical warnings in GLSL (#1019)

This changelist adds a guard to the GLSL implementation of thin-film rendering, addressing numerical warnings and visual artifacts in situations where eta values decrease between interfaces.  Without this guard, the logic requires the computation of an imaginary square root, which is undefined behavior in GLSL.

* Fix initialization warning in GLSL

This changelist refactors the implementation of mx_surface_transmission in GLSL, addressing an initialization warning when the function is called in WebGL.

* Update TSC stakeholders

This changelist assigns Fran Gonzalez as the Pixar RenderMan stakeholder on the MaterialX TSC, and adds Bernard Kwok as the Khronos Group stakeholder, as confirmed by votes at recent meetings.

* Finalize changelog for v1.38.5

* Update development build to 1.38.6

* Update adsk modules to reflect API changes.

- Use emitLibraryInclude
- Remove Arnold shadergen in MaterialXView.

* Update OGSFX and OGSXML tests

* Patch the failures

Workaround to support new libraries layout
 We have a few materials in our libraries (adsk/shaders/brick) that have texture references (libraries/adsk/textures).
This was done with the assumption that libraries were part of the image resolver search path.
libraries is no longer the default search path for Images. For now make them relative.

Disable MaterialXRuntime tests, they cannot support the new libraries layout

* Build fix

* Disable adsk:brick and adsk:parquet tests since they have image reference

* Disable: adsk_shaders test and remove outdated sd library

* Revert "Update development build to 1.38.6"

This reverts commit b97ee12daac82aff56fb7545ccce8901e83d3705.

Co-authored-by: Jonathan Stone <jstone@lucasfilm.com>
Co-authored-by: Niklas Harrysson <niklas.harrysson@gmail.com>
Co-authored-by: Bernard Kwok <Bernard.Kwok@autodesk.com>
Co-authored-by: Madeleine Yip <52723401+mjyip-lucasfilm@users.noreply.github.com>
Co-authored-by: Bernard Kwok <kwokcb@gmail.com>
Co-authored-by: yuri@FreeBSD <yurivict@users.noreply.github.com>
Co-authored-by: Mark Elendt <mark@sidefx.com>
Co-authored-by: Tobias Häußler <mail@tobiashaeussler.com>
Co-authored-by: Paul Molodowitch <elrond79@gmail.com>
Co-authored-by: Brian Sharpe <brisharpe@yahoo.com>
Co-authored-by: Rasmus Bonnedal <rasmus.bonnedal@gmail.com>
Co-authored-by: ZapAndersson <102356572+ZapAndersson@users.noreply.github.com>
Co-authored-by: MACHIZAUD Andréa <andrea.machizaud@gmail.com>
Co-authored-by: Pablo Delgado <private@pablode.com>
Co-authored-by: Chris Rydalch <crydalch@gmail.com>
Co-authored-by: Igor Elovikov <igor.elovikov@gmail.com>
Co-authored-by: Damien Courtois <dcourtois@isotropix.com>
Michaelredaa pushed a commit to Michaelredaa/MaterialX that referenced this issue Oct 21, 2023
- Add utilities UnitConverterRegistry::convertToUnit and MaterialX::joinStrings.
- Use C Locale for string stream operations (autodesk-forks#1183).
- Add tests for unit and locale content.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Core Core change required
Projects
Develop
  
To do
Development

No branches or pull requests

3 participants