- - - - -
+ +Tiled Brass | Tiled Wood +------------|----------- +![MaterialX TiledBrass material](../Images/MaterialXView_TiledBrass.png) | ![MaterialX TiledWood material](../Images/MaterialXView_TiledWood.png) **Figure 2:** Textured, color-space-managed materials in the MaterialX viewer -- - -
## Building The MaterialX Viewer Select the `MATERIALX_BUILD_VIEWER` option in CMake to build the MaterialX Viewer. Installation will copy the **MaterialXView** executable to a `/bin` directory within the selected install folder. -### Summary of Viewer Options +## Summary of Viewer Options 1. **Load Mesh**: Load a new geometry in the OBJ or glTF format. 2. **Load Material**: Load a material document in the MTLX format. @@ -29,13 +27,13 @@ Select the `MATERIALX_BUILD_VIEWER` option in CMake to build the MaterialX Viewe 4. **Property Editor**: View or edit properties of the current material. 5. **Advanced Settings** : Asset and rendering options. -### Geometry +## Geometry The default display geometry for the MaterialX viewer is the Arnold Shader Ball, which was contributed to the MaterialX project by the Solid Angle team at Autodesk. To change the display geometry, click `Load Mesh` and navigate to the [Geometry](../../resources/Geometry) folder for additional models in the OBJ format. If a loaded geometry contains more than one geometric group, then a `Select Geometry` drop-down box will appear, allowing the user to select which group is active. The active geometric group will be used for subsequent actions such as material assignment and rendering property changes. -### Materials +## Materials To change the displayed material, click `Load Material` and navigate to the [Materials/Examples/StandardSurface](../../resources/Materials/Examples/StandardSurface) or [Materials/Examples/UsdPreviewSurface](../../resources/Materials/Examples/UsdPreviewSurface) folders, which contain a selection of example materials in the MTLX format. @@ -45,17 +43,17 @@ Multiple material documents can be combined in a single session by navigating to If a material document containing `look` elements is loaded into the viewer, then any material assignments within the look will be applied to geometric groups that match the specified geometry strings. See [standard_surface_look_brass_tiled.mtlx](../../resources/Materials/Examples/StandardSurface/standard_surface_look_brass_tiled.mtlx) for an example of a material document containing look elements. -### Lighting +## Lighting The default lighting environment for the viewer is the San Giuseppe Bridge environment from HDRI Haven. To load another environment into the viewer, click `Load Environment` and navigate to the [Lights](../../resources/Lights) folder, or load any HDR environment in the latitude-longitude format. If the HDR file on disk has a companion MaterialX document with a matching name, then this document will be loaded as the direct lighting rig for the environment; otherwise only indirect lighting will be rendered. If the HDR file on disk has a companion image in an `irradiance` subfolder, then this image will be loaded as the diffuse convolution of the environment; otherwise, a diffuse convolution will be generated at load-time using spherical harmonics. Shadow maps from the primary directional light may be enabled with the `Shadow Map` option under `Advanced Settings`. Ambient occlusion, if available for the given geometry, may be enabled with the `Ambient Occlusion` option. The fidelity of environment lighting may be improved by increasing the value of `Environment Samples`, though this requires additional GPU resources and can affect the interactivity of the viewer. -### Images +## Images By default, the MaterialX viewer loads and saves image files using `stb_image`, which supports commmon 8-bit formats such as JPEG, PNG, TGA, and BMP, as well as the HDR format for high-dynamic-range images. If you need access to additional image formats such as EXR and TIFF, then the MaterialX viewer can be built with support for `OpenImageIO`. To build MaterialX with OpenImageIO, check the `MATERIALX_BUILD_OIIO` option in CMake, and specify the location of your OpenImageIO installation with the `MATERIALX_OIIO_DIR` option. -### Keyboard Shortcuts +## Keyboard Shortcuts - `R`: Reload the current material from file. Hold `SHIFT` to reload all standard libraries as well. - `G`: Save the current GLSL shader source to file. @@ -74,7 +72,7 @@ By default, the MaterialX viewer loads and saves image files using `stb_image`, - `+` : Zoom in with the camera. - `-` : Zoom out with the camera. -### Command-Line Options +## Command-Line Options The following are common command-line options for MaterialXView, and a complete list can be displayed with the `--help` option. - `--material [FILENAME]` : Specify the filename of the MTLX document to be displayed in the viewer diff --git a/documents/DeveloperGuide/index.rst b/documents/DeveloperGuide/index.rst new file mode 100644 index 0000000000..8c902e5e57 --- /dev/null +++ b/documents/DeveloperGuide/index.rst @@ -0,0 +1,53 @@ +MaterialX Developer Guide +========================= + +.. toctree:: + :maxdepth: 1 + + MainPage.md + GraphEditor.md + Viewer.md + ShaderGeneration.md + + +MaterialX Python Modules +------------------------ + +.. autosummary:: + :toctree: generated + :caption: MaterialX Python Modules: + + PyMaterialXCore + PyMaterialXFormat + PyMaterialXGenGlsl + PyMaterialXGenMdl + PyMaterialXGenMsl + PyMaterialXGenOsl + PyMaterialXGenShader + PyMaterialXRender + PyMaterialXRenderGlsl + PyMaterialXRenderMsl + PyMaterialXRenderOsl + + +Import Order Dependencies +------------------------- + +Note that the order in which the MaterialX Python modules are imported matters, as there are dependencies between them: + +- :py:mod:`PyMaterialXCore` -- typically always needed + - :py:mod:`PyMaterialXFormat` -- needed for file I/O + - :py:mod:`PyMaterialXRender` -- needed for core rendering + - :py:mod:`PyMaterialXRenderGlsl` -- render using OpenGL Shading Language + - :py:mod:`PyMaterialXRenderMsl` -- render using Metal Shading Language + - :py:mod:`PyMaterialXRenderOsl` -- render using Open Shading Language +- :py:mod:`PyMaterialXGenShader` -- needed for core shader generation + - :py:mod:`PyMaterialXGenGlsl` -- generating shaders using OpenGL Shading Language + - :py:mod:`PyMaterialXGenMdl` -- generating shaders using Material Definition Language + - :py:mod:`PyMaterialXGenMsl` -- generating shaders using Metal Shading Language + - :py:mod:`PyMaterialXGenOsl` -- generating shaders using Open Shading Language + +That is to say, for example: + +- :py:mod:`PyMaterialXCore` needs to be imported before :py:mod:`PyMaterialXFormat` and :py:mod:`PyMaterialXRender` +- :py:mod:`PyMaterialXGenShader` needs to be imported before :py:mod:`PyMaterialXGenMsl` diff --git a/documents/Doxyfile.in b/documents/Doxyfile.in index 873037ef99..c92dbbed27 100644 --- a/documents/Doxyfile.in +++ b/documents/Doxyfile.in @@ -1,9 +1,9 @@ PROJECT_NAME = MaterialX -PROJECT_NUMBER = ${MATERIALX_MAJOR_VERSION}.${MATERIALX_MINOR_VERSION}.${MATERIALX_BUILD_VERSION} -PROJECT_LOGO = MaterialXLogo_200x155.png +PROJECT_NUMBER = ${MATERIALX_LIBRARY_VERSION} +PROJECT_LOGO = Images/MaterialXLogo_200x155.png -USE_MDFILE_AS_MAINPAGE = MainPage.md -HTML_EXTRA_STYLESHEET = doxygen-awesome.css +USE_MDFILE_AS_MAINPAGE = DeveloperGuide/MainPage.md +HTML_EXTRA_STYLESHEET = DoxygenAwesome/doxygen-awesome.css INPUT = ${DOXYGEN_INPUT_STR} OUTPUT_DIRECTORY = ${DOXYGEN_OUTPUT_DIR} diff --git a/documents/sphinx-conf.py.in b/documents/sphinx-conf.py.in new file mode 100644 index 0000000000..67e1d21705 --- /dev/null +++ b/documents/sphinx-conf.py.in @@ -0,0 +1,77 @@ +# Configuration file for the Sphinx documentation builder. +# +# For the full list of built-in configuration values, see the documentation: +# https://www.sphinx-doc.org/en/master/usage/configuration.html + +# -- Project information ----------------------------------------------------- +# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information + +project = 'MaterialX' +copyright = '2023, MaterialX Maintainers' +author = 'MaterialX Maintainers' +release = '${MATERIALX_LIBRARY_VERSION}' + + +# -- Path Manipulation ------------------------------------------------------- + +import os +import sys +sys.path.insert(0, os.path.abspath('${MATERIALX_PYTHONPATH}')) + + +# -- Module Import Order Dependencies ---------------------------------------- + +# Make sure to import the core module before modules like `PyMaterialXFormat` +# and `PyMaterialXRender`, as otherwise, their import fails with an +# `ImportError` exception: +# ``` +# ImportError: arg(): could not convert default argument into a Python object +# (type not registered yet?). +# ``` +import PyMaterialXCore + +# Make sure to import `PyMaterialXRender` before modules like +# `PyMaterialXRenderMsl`, as otherwise, their import fails with an +# `ImportError` exception, for example: +# ``` +# ImportError: generic_type: type "MslRenderer" referenced unknown base type +# "MaterialX_v1_38_9::ShaderRenderer" +# ``` +import PyMaterialXRender + +# Make sure to import `PyMaterialXGenShader` before modules like +# `PyMaterialXGenGlsl`, as otherwise, their import fails with an `ImportError` +# exception, for example: +# ``` +# ImportError: generic_type: type "GlslShaderGenerator" referenced unknown base +# type "MaterialX_v1_38_9::HwShaderGenerator" +# ``` +import PyMaterialXGenShader + + +# -- General configuration --------------------------------------------------- +# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration + +extensions = [ + 'myst_parser', + 'sphinx.ext.autodoc', + 'sphinx.ext.autosummary', +] + +exclude_patterns = [] + + +# -- Options for HTML output ------------------------------------------------- +# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output + +html_theme = 'alabaster' +html_theme_options = { + 'logo': '${MATERIALX_LOGO_FILENAME}', + 'description': 'MaterialX – An open standard for the exchange of rich material and look-development content across applications and renderers.', + 'github_button': True, + 'github_user': 'AcademySoftwareFoundation', + 'github_repo': 'MaterialX', + 'extra_nav_links': { + 'MaterialX C++ API Docs': 'https://materialx.org/docs/api/index.html', + }, +} diff --git a/documents/sphinx-custom.css b/documents/sphinx-custom.css new file mode 100644 index 0000000000..dfe1adc3ca --- /dev/null +++ b/documents/sphinx-custom.css @@ -0,0 +1,207 @@ +/* +Dark Mode colors and other variables copied from "doxygen-awesome.css". +We could potentially import the entire style sheet here, but we're only +interested in the color definitions and a select few other styles. +DoxygenAwesome is licensed under the MIT License. +*/ +html { + /* font-families. will affect all text on the website + * font-family: the normal font for text, headlines, menus + * font-family-monospace: used for preformatted text in memtitle, code, fragments + */ + --font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,Fira Sans,Droid Sans,Helvetica Neue,sans-serif; + --font-family-monospace: ui-monospace,SFMono-Regular,SF Mono,Menlo,Consolas,Liberation Mono,monospace; + + /* font sizes */ + --page-font-size: 15.6px; + --navigation-font-size: 14.4px; + --toc-font-size: 13.4px; + --code-font-size: 14px; /* affects code, fragment */ + --title-font-size: 22px; + + /* color for all separators on the website: hr, borders, ... */ + --separator-color: #dedede; + + /* border radius for all rounded components. Will affect many components, like dropdowns, memitems, codeblocks, ... */ + --border-radius-large: 8px; + --border-radius-small: 4px; + --border-radius-medium: 6px; + + color-scheme: dark; + + --primary-color: #1982d2; + --primary-dark-color: #86a9c4; + --primary-light-color: #4779ac; + + --box-shadow: 0 2px 8px 0 rgba(0,0,0,.30); + + --odd-color: rgba(100,100,100,.06); + + --menu-selected-background: rgba(0,0,0,.4); + + --page-background-color: #1C1D1F; + --page-foreground-color: #d2dbde; + --page-secondary-foreground-color: #859399; + --separator-color: #38393b; + --side-nav-background: #252628; + + --code-background: #2a2c2f; + + --tablehead-background: #2a2c2f; + + --blockquote-background: #222325; + --blockquote-foreground: #7e8c92; + + --warning-color: #2e1917; + --warning-color-dark: #ad2617; + --warning-color-darker: #f5b1aa; + --note-color: #3b2e04; + --note-color-dark: #f1b602; + --note-color-darker: #ceb670; + --todo-color: #163750; + --todo-color-dark: #1982D2; + --todo-color-darker: #dcf0fa; + --deprecated-color: #2e323b; + --deprecated-color-dark: #738396; + --deprecated-color-darker: #abb0bd; + --bug-color: #2a2536; + --bug-color-dark: #7661b3; + --bug-color-darker: #ae9ed6; + --invariant-color: #303a35; + --invariant-color-dark: #76ce96; + --invariant-color-darker: #cceed5; + + --fragment-background: #282c34; + --fragment-foreground: #dbe4eb; + --fragment-keyword: #cc99cd; + --fragment-keywordtype: #ab99cd; + --fragment-keywordflow: #e08000; + --fragment-token: #7ec699; + --fragment-comment: #999999; + --fragment-link: #98c0e3; + --fragment-preprocessor: #65cabe; + --fragment-linenumber-color: #cccccc; + --fragment-linenumber-background: #35393c; + --fragment-linenumber-border: #1f1f1f; +} + +/* Apply the dark mode colors on top of the default Alabastar styles */ +body, div.body { + background-color: var(--page-background-color); + color: var(--page-foreground-color); + font-family: var(--font-family); + font-size: var(--page-font-size); +} +div.sphinxsidebar { + background-color: var(--side-nav-background); +} +div.sphinxsidebar p, +div.sphinxsidebar h3, +div.sphinxsidebar h4 { + color: var(--page-foreground-color); + font-family: var(--font-family); +} +a { + color: var(--primary-color) !important; + text-decoration: none; +} +a:link, a:visited, a:hover, a:focus, a:active { + font-weight: 500; +} +a.reference, +div.sphinxsidebar a { + text-decoration: none; + border-bottom: none; +} +a.reference:hover, +div.sphinxsidebar a:hover { + text-decoration: underline; + border-bottom: none; +} +div.body h1, +div.body h2, +div.body h3, +div.body h4, +div.body h5, +div.body h6 +{ + font-family: var(--font-family); +} + +code, +div.fragment, +pre.fragment { + border-radius: var(--border-radius-small); + border: 1px solid var(--separator-color); + overflow: hidden; +} +code { + display: inline; + color: var(--code-foreground); + padding: 2px 6px; +} +tt, +tt.xref, +code, +code.xref, +a tt { + background-color: var(--code-background); + border-bottom: none; +} +code, +code a, +pre.fragment, +div.fragment, +div.fragment span, +div.fragment .line, +div.fragment .line a, +div.fragment .line span { + font-family: var(--font-family-monospace); + font-size: var(--code-font-size) !important; +} +code.xref, +a code { + font-weight: normal; +} +table, +table.docutils { + border: none; + border-collapse: collapse; + -webkit-box-shadow: none; + box-shadow: none; +} +table tr:nth-child(even) { + background-color: transparent; +} +table tr:nth-child(odd) { + background-color: var(--odd-color); +} +/* table header rows */ +table tr.row-odd:nth-child(odd) { + background-color: transparent; + border-bottom: 1px solid var(--separator-color); +} +table tr.row-even:nth-child(even) { + border-bottom: 1px solid var(--separator-color); +} +table.docutils td, +table.docutils th { + border: none; +} + +/* Make the MaterialX logo a little smaller */ +img.logo { + width: 60%; + height: 60%; +} + +/* Turn off auto-hyphenation in text blocks */ +div.body p, +div.body dd, +div.body li, +div.body blockquote { + -moz-hyphens: none; + -ms-hyphens: none; + -webkit-hyphens: none; + hyphens: none; +} diff --git a/source/PyMaterialX/PyMaterialXCore/PyModule.cpp b/source/PyMaterialX/PyMaterialXCore/PyModule.cpp index e2e8a0080f..6185da225f 100644 --- a/source/PyMaterialX/PyMaterialXCore/PyModule.cpp +++ b/source/PyMaterialX/PyMaterialXCore/PyModule.cpp @@ -26,7 +26,7 @@ void bindPyVariant(py::module& mod); PYBIND11_MODULE(PyMaterialXCore, mod) { - mod.doc() = "Module containing Python bindings for the MaterialXCore library"; + mod.doc() = "Core functionality of MaterialX"; bindPyElement(mod); bindPyTraversal(mod); diff --git a/source/PyMaterialX/PyMaterialXFormat/PyModule.cpp b/source/PyMaterialX/PyMaterialXFormat/PyModule.cpp index 842087d24f..69068d429b 100644 --- a/source/PyMaterialX/PyMaterialXFormat/PyModule.cpp +++ b/source/PyMaterialX/PyMaterialXFormat/PyModule.cpp @@ -13,7 +13,7 @@ void bindPyUtil(py::module& mod); PYBIND11_MODULE(PyMaterialXFormat, mod) { - mod.doc() = "Module containing Python bindings for the MaterialXFormat library"; + mod.doc() = "Cross-platform support for working with files, paths, and environment variables"; bindPyFile(mod); bindPyXmlIo(mod); diff --git a/source/PyMaterialX/PyMaterialXGenGlsl/PyModule.cpp b/source/PyMaterialX/PyMaterialXGenGlsl/PyModule.cpp index a36b815d32..f61488cbb8 100644 --- a/source/PyMaterialX/PyMaterialXGenGlsl/PyModule.cpp +++ b/source/PyMaterialX/PyMaterialXGenGlsl/PyModule.cpp @@ -14,7 +14,7 @@ void bindPyVkShaderGenerator(py::module& mod); PYBIND11_MODULE(PyMaterialXGenGlsl, mod) { - mod.doc() = "Module containing Python bindings for the MaterialXGenGlsl library"; + mod.doc() = "Shader generation using OpenGL Shading Language"; bindPyGlslShaderGenerator(mod); bindPyGlslResourceBindingContext(mod); diff --git a/source/PyMaterialX/PyMaterialXGenMdl/PyModule.cpp b/source/PyMaterialX/PyMaterialXGenMdl/PyModule.cpp index 020c944e63..69479788c3 100644 --- a/source/PyMaterialX/PyMaterialXGenMdl/PyModule.cpp +++ b/source/PyMaterialX/PyMaterialXGenMdl/PyModule.cpp @@ -11,7 +11,7 @@ void bindPyMdlShaderGenerator(py::module& mod); PYBIND11_MODULE(PyMaterialXGenMdl, mod) { - mod.doc() = "Module containing Python bindings for the MaterialXGenMdl library"; + mod.doc() = "Shader generation using Material Definition Language"; bindPyMdlShaderGenerator(mod); }; diff --git a/source/PyMaterialX/PyMaterialXGenMsl/PyModule.cpp b/source/PyMaterialX/PyMaterialXGenMsl/PyModule.cpp index 6eda44871b..a1098f138c 100644 --- a/source/PyMaterialX/PyMaterialXGenMsl/PyModule.cpp +++ b/source/PyMaterialX/PyMaterialXGenMsl/PyModule.cpp @@ -12,7 +12,7 @@ void bindPyMslResourceBindingContext(py::module &mod); PYBIND11_MODULE(PyMaterialXGenMsl, mod) { - mod.doc() = "Module containing Python bindings for the MaterialXGenMsl library"; + mod.doc() = "Shader generation using Metal Shading Language"; bindPyMslShaderGenerator(mod); bindPyMslResourceBindingContext(mod); diff --git a/source/PyMaterialX/PyMaterialXGenOsl/PyModule.cpp b/source/PyMaterialX/PyMaterialXGenOsl/PyModule.cpp index d772d18b6a..6fc0237f87 100644 --- a/source/PyMaterialX/PyMaterialXGenOsl/PyModule.cpp +++ b/source/PyMaterialX/PyMaterialXGenOsl/PyModule.cpp @@ -11,7 +11,7 @@ void bindPyOslShaderGenerator(py::module& mod); PYBIND11_MODULE(PyMaterialXGenOsl, mod) { - mod.doc() = "Module containing Python bindings for the MaterialXGenOsl library"; + mod.doc() = "Shader generation using Open Shading Language"; bindPyOslShaderGenerator(mod); } diff --git a/source/PyMaterialX/PyMaterialXGenShader/PyModule.cpp b/source/PyMaterialX/PyMaterialXGenShader/PyModule.cpp index f3dc613bff..66abde6878 100644 --- a/source/PyMaterialX/PyMaterialXGenShader/PyModule.cpp +++ b/source/PyMaterialX/PyMaterialXGenShader/PyModule.cpp @@ -24,7 +24,7 @@ void bindPyUnitSystem(py::module& mod); PYBIND11_MODULE(PyMaterialXGenShader, mod) { - mod.doc() = "Module containing Python bindings for the MaterialXGenShader library"; + mod.doc() = "Core functionality for shader generation"; bindPyColorManagement(mod); bindPyShaderPort(mod); diff --git a/source/PyMaterialX/PyMaterialXRender/PyModule.cpp b/source/PyMaterialX/PyMaterialXRender/PyModule.cpp index 1c60142346..c8ac371c23 100644 --- a/source/PyMaterialX/PyMaterialXRender/PyModule.cpp +++ b/source/PyMaterialX/PyMaterialXRender/PyModule.cpp @@ -23,7 +23,7 @@ void bindPyCgltfLoader(py::module& mod); PYBIND11_MODULE(PyMaterialXRender, mod) { - mod.doc() = "Module containing Python bindings for the MaterialXRender library"; + mod.doc() = "Core rendering functionality for MaterialX"; bindPyMesh(mod); bindPyGeometryHandler(mod); diff --git a/source/PyMaterialX/PyMaterialXRenderGlsl/PyModule.cpp b/source/PyMaterialX/PyMaterialXRenderGlsl/PyModule.cpp index 32fb79239d..f87854fde4 100644 --- a/source/PyMaterialX/PyMaterialXRenderGlsl/PyModule.cpp +++ b/source/PyMaterialX/PyMaterialXRenderGlsl/PyModule.cpp @@ -14,7 +14,7 @@ void bindPyTextureBaker(py::module& mod); PYBIND11_MODULE(PyMaterialXRenderGlsl, mod) { - mod.doc() = "Module containing Python bindings for the MaterialXRenderGlsl library"; + mod.doc() = "Rendering materials using OpenGL Shading Language"; bindPyGlslProgram(mod); bindPyGlslRenderer(mod); diff --git a/source/PyMaterialX/PyMaterialXRenderMsl/PyModule.mm b/source/PyMaterialX/PyMaterialXRenderMsl/PyModule.mm index 10b440d21c..1e120bf1c0 100644 --- a/source/PyMaterialX/PyMaterialXRenderMsl/PyModule.mm +++ b/source/PyMaterialX/PyMaterialXRenderMsl/PyModule.mm @@ -14,7 +14,7 @@ PYBIND11_MODULE(PyMaterialXRenderMsl, mod) { - mod.doc() = "Module containing Python bindings for the MaterialXRenderMsl library"; + mod.doc() = "Rendering materials using Metal Shading Language"; bindPyMslProgram(mod); bindPyMslRenderer(mod); diff --git a/source/PyMaterialX/PyMaterialXRenderOsl/PyModule.cpp b/source/PyMaterialX/PyMaterialXRenderOsl/PyModule.cpp index 15610066f3..31ec2b1b65 100644 --- a/source/PyMaterialX/PyMaterialXRenderOsl/PyModule.cpp +++ b/source/PyMaterialX/PyMaterialXRenderOsl/PyModule.cpp @@ -11,7 +11,7 @@ void bindPyOslRenderer(py::module& mod); PYBIND11_MODULE(PyMaterialXRenderOsl, mod) { - mod.doc() = "Module containing Python bindings for the MaterialXRenderOsl library"; + mod.doc() = "Rendering materials using Open Shading Language"; bindPyOslRenderer(mod); }