### Install MaterialXView Executable Source: https://github.com/academysoftwarefoundation/materialx/blob/main/source/MaterialXView/CMakeLists.txt Installs the MaterialXView executable to the specified runtime destination. This is a standard installation step for executables. ```cmake EXPORT MaterialX RUNTIME DESTINATION ${MATERIALX_INSTALL_BIN_PATH}) ``` -------------------------------- ### Install Root-Level Documents Source: https://github.com/academysoftwarefoundation/materialx/blob/main/CMakeLists.txt Installs license, changelog, readme, and third-party files to the root installation directory. ```cmake if(NOT SKBUILD) install(FILES LICENSE CHANGELOG.md README.md THIRD-PARTY.md DESTINATION .) set(MATERIALX_GEN_CONFIG_PATH "${MATERIALX_INSTALL_LIB_PATH}/cmake/${CMAKE_PROJECT_NAME}") include(CMakePackageConfigHelpers) if (MATERIALX_BUILD_MONOLITHIC) # Export aliases for the MaterialX modules built in this monolithic build # to be less disruptive to downstream projects. get_property(MATERIALX_MODULES GLOBAL PROPERTY MATERIALX_MODULES) set(EXPORT_ALIASES "# Aliased targets for the monolithic build\n") foreach (MODULE ${MATERIALX_MODULES}) string(APPEND EXPORT_ALIASES "add_library(${MODULE} ALIAS MaterialX)\n") endforeach () if (NOT MATERIALX_MODULES) message(FATAL_ERROR "Building MaterialX as a monolithic library, but did not find any libraries to alias.") endif () endif () configure_package_config_file(cmake/modules/MaterialXConfig.cmake.in ${PROJECT_BINARY_DIR}/cmake/${CMAKE_PROJECT_NAME}Config.cmake INSTALL_DESTINATION "${MATERIALX_GEN_CONFIG_PATH}" PATH_VARS CMAKE_INSTALL_PREFIX CMAKE_PROJECT_NAME) write_basic_package_version_file(${PROJECT_BINARY_DIR}/cmake/${CMAKE_PROJECT_NAME}ConfigVersion.cmake VERSION ${MATERIALX_LIBRARY_VERSION} COMPATIBILITY AnyNewerVersion) # Install auto-generated CMake configuration files install(EXPORT MaterialX DESTINATION "${MATERIALX_GEN_CONFIG_PATH}" FILE ${CMAKE_PROJECT_NAME}Targets.cmake) install(FILES "${PROJECT_BINARY_DIR}/cmake/${CMAKE_PROJECT_NAME}ConfigVersion.cmake" "${PROJECT_BINARY_DIR}/cmake/${CMAKE_PROJECT_NAME}Config.cmake" DESTINATION "${MATERIALX_GEN_CONFIG_PATH}") endif() ``` -------------------------------- ### Install npm packages and build the sample viewer Source: https://github.com/academysoftwarefoundation/materialx/blob/main/javascript/README.md Install dependencies and build the sample viewer from the MaterialXView directory. ```sh npm install call npm run build ``` -------------------------------- ### Installing MaterialXView Target Source: https://github.com/academysoftwarefoundation/materialx/blob/main/source/MaterialXView/CMakeLists.txt Installs the MaterialXView executable. ```cmake install(TARGETS MaterialXView ``` -------------------------------- ### Install and run http-server for sample viewer Source: https://github.com/academysoftwarefoundation/materialx/blob/main/javascript/README.md Install the http-server globally and use it to serve the current directory on port 8000 for the sample viewer. ```sh call npm install http-server -g call http-server . -p 8000 # Open browser ``` -------------------------------- ### MaterialX Filename Syntax Examples Source: https://github.com/academysoftwarefoundation/materialx/blob/main/documents/Specification/MaterialX.Specification.md Provides examples of filename attributes, including paths, substitution strings, and URIs. ```mtlx filevalue = "diffuse/color01.tif" filevalue = "/s/myshow/assets/myasset/v102.1/wetdrips/drips.{frame}.tif" filevalue = "https://github.com/organization/project/tree/master/src/node.osl" filevalue = "cmsscheme:myassetdiffuse..tif?ver=current" ``` -------------------------------- ### Install MaterialX Python Directories Source: https://github.com/academysoftwarefoundation/materialx/blob/main/python/CMakeLists.txt Installs the MaterialX and Scripts directories to the python destination if SKBUILD is not enabled. Use this for standard installations. ```cmake if(NOT SKBUILD) install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/MaterialX" DESTINATION "python" MESSAGE_NEVER) install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/Scripts" DESTINATION "python" MESSAGE_NEVER) endif() ``` -------------------------------- ### MaterialX Look Example with Assignments Source: https://github.com/academysoftwarefoundation/materialx/blob/main/documents/Specification/MaterialX.GeomExts.md An example demonstrating the definition of collections, a light shader, material, and propertyset, followed by their use in two different looks with various assignments. ```xml ``` -------------------------------- ### Install Executable and Optional PDB Source: https://github.com/academysoftwarefoundation/materialx/blob/main/source/MaterialXGraphEditor/CMakeLists.txt Installs the MaterialXGraphEditor executable to the specified runtime destination. Optionally installs the PDB file on MSVC. ```cmake install(TARGETS MaterialXGraphEditor EXPORT MaterialX RUNTIME DESTINATION ${MATERIALX_INSTALL_BIN_PATH}) if(MSVC) install(FILES $ DESTINATION ${MATERIALX_INSTALL_BIN_PATH} OPTIONAL) endif() ``` -------------------------------- ### Configure GLFW Build Options Source: https://github.com/academysoftwarefoundation/materialx/blob/main/source/MaterialXGraphEditor/CMakeLists.txt Sets build options for the GLFW library to disable examples, tests, and documentation, and to prevent installation. ```cmake set(GLFW_BUILD_EXAMPLES OFF) set(GLFW_BUILD_TESTS OFF) set(GLFW_BUILD_DOCS OFF) set(GLFW_INSTALL OFF) ``` -------------------------------- ### Finding External NanoGUI Installation Source: https://github.com/academysoftwarefoundation/materialx/blob/main/source/MaterialXView/CMakeLists.txt Locates the include directories and libraries for an external NanoGUI installation. Fails if not found. ```cmake if (MATERIALX_NANOGUI_EXTERNAL) find_path(NANOGUI_INCLUDE_DIRS NAMES nanogui/nanogui.h HINTS "${NANOGUI_ROOT}/include" "$ENV{NANOGUI_ROOT}/include") find_library(NANOGUI_LIBRARIES NAMES nanogui HINTS "${NANOGUI_ROOT}/lib" "$ENV{NANOGUI_ROOT}/lib" "${NANOGUI_ROOT}/lib64" "$ENV{NANOGUI_ROOT}/lib64") if (NOT NANOGUI_INCLUDE_DIRS OR NOT NANOGUI_LIBRARIES) message(FATAL_ERROR "Could not find external NanoGUI installation, is NANOGUI_ROOT set?") endif() else() # ... (rest of the else block) ``` -------------------------------- ### Build and Install Project Source: https://github.com/academysoftwarefoundation/materialx/blob/main/javascript/README.md Build the project using CMake and install the generated artifacts. The -j option controls the number of parallel build threads. ```sh cmake --build . --target install -j8 ``` -------------------------------- ### Install JavaScript Executables Source: https://github.com/academysoftwarefoundation/materialx/blob/main/source/JsMaterialX/CMakeLists.txt Installs the compiled JavaScript executables (JsMaterialXCore and JsMaterialXGenShader) to the specified destination directory. ```cmake install(TARGETS JsMaterialXCore DESTINATION "JavaScript/MaterialX") install(TARGETS JsMaterialXGenShader DESTINATION "JavaScript/MaterialX") ``` -------------------------------- ### Define Installation Paths Source: https://github.com/academysoftwarefoundation/materialx/blob/main/CMakeLists.txt Sets cache variables to define the installation layout for MaterialX headers, binaries, libraries, and standard libraries. These paths control where build artifacts are placed during installation. ```cmake set(MATERIALX_INSTALL_INCLUDE_PATH "include" CACHE STRING "Install header include path (e.g. 'inc', 'include').") set(MATERIALX_INSTALL_BIN_PATH "bin" CACHE STRING "Install bin path (e.g. 'bin').") set(MATERIALX_INSTALL_LIB_PATH "lib" CACHE STRING "Install lib path (e.g. 'libs', 'lib').") set(MATERIALX_INSTALL_STDLIB_PATH "libraries" CACHE STRING "Install path for mtlx std libs (e.g. 'libraries').") ``` -------------------------------- ### Install npm packages for MaterialX tests Source: https://github.com/academysoftwarefoundation/materialx/blob/main/javascript/README.md Run this command from the MaterialXTest directory to install necessary npm packages for running unit tests. ```sh npm install ``` -------------------------------- ### Install WebAssembly Output Source: https://github.com/academysoftwarefoundation/materialx/blob/main/source/JsMaterialX/CMakeLists.txt Copies the WebAssembly binary (.wasm) and associated data files (.data) for the MaterialX JavaScript targets to the installation directory. ```cmake install(FILES ${PROJECT_BINARY_DIR}/bin/JsMaterialXCore.wasm DESTINATION JavaScript/MaterialX/) install(FILES ${PROJECT_BINARY_DIR}/bin/JsMaterialXGenShader.wasm ${PROJECT_BINARY_DIR}/bin/JsMaterialXGenShader.data DESTINATION JavaScript/MaterialX/) ``` -------------------------------- ### Install Python Package Source: https://github.com/academysoftwarefoundation/materialx/blob/main/CMakeLists.txt Installs the Python package using pip after all other installation steps are complete, if Python build and installation are enabled. ```cmake if(MATERIALX_BUILD_PYTHON AND MATERIALX_INSTALL_PYTHON AND PYTHON_EXECUTABLE AND NOT SKBUILD) install(CODE "execute_process(COMMAND ${PYTHON_EXECUTABLE} -m pip install . WORKING_DIRECTORY ${CMAKE_INSTALL_PREFIX}/python)") endif() ``` -------------------------------- ### Install PyMaterialXFormat Target Source: https://github.com/academysoftwarefoundation/materialx/blob/main/source/PyMaterialX/PyMaterialXFormat/CMakeLists.txt Installs the PyMaterialXFormat target to the specified destination directory within the MaterialX Python folder. ```cmake install(TARGETS PyMaterialXFormat DESTINATION "${MATERIALX_PYTHON_FOLDER_NAME}") ``` -------------------------------- ### Install JavaScript Files with Version Source: https://github.com/academysoftwarefoundation/materialx/blob/main/source/JsMaterialX/CMakeLists.txt Installs the JavaScript files, renaming them to include the MaterialX library version for clear identification. ```cmake install(FILES ${PROJECT_BINARY_DIR}/bin/JsMaterialXCore.js DESTINATION ${PROJECT_BINARY_DIR}/ RENAME JsMaterialXCore-${MATERIALX_LIBRARY_VERSION}.js) install(FILES ${CMAKE_INSTALL_PREFIX}/JavaScript/MaterialX/JsMaterialXCore.js DESTINATION JavaScript/MaterialX/ RENAME JsMaterialXCore-${MATERIALX_LIBRARY_VERSION}.js) install(FILES ${PROJECT_BINARY_DIR}/bin/JsMaterialXGenShader.js DESTINATION ${PROJECT_BINARY_DIR}/ RENAME JsMaterialXGenShader-${MATERIALX_LIBRARY_VERSION}.js) install(FILES ${CMAKE_INSTALL_PREFIX}/JavaScript/MaterialX/JsMaterialXGenShader.js DESTINATION JavaScript/MaterialX/ RENAME JsMaterialXGenShader-${MATERIALX_LIBRARY_VERSION}.js) ``` -------------------------------- ### Install Pybind11 Headers and Configuration Source: https://github.com/academysoftwarefoundation/materialx/blob/main/source/PyMaterialX/External/PyBind11/CMakeLists.txt Installs pybind11 headers and CMake configuration files. This snippet handles the installation of pybind11 headers, CMake config files, and version files, with specific logic for CMake versions prior to 3.14 regarding CMAKE_SIZEOF_VOID_P. ```cmake if(PYBIND11_INSTALL) install(DIRECTORY ${pybind11_INCLUDE_DIR}/pybind11 DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) set(PYBIND11_CMAKECONFIG_INSTALL_DIR "${CMAKE_INSTALL_DATAROOTDIR}/cmake/${PROJECT_NAME}" CACHE STRING "install path for pybind11Config.cmake") if(IS_ABSOLUTE "${CMAKE_INSTALL_INCLUDEDIR}") set(pybind11_INCLUDEDIR "${CMAKE_INSTALL_FULL_INCLUDEDIR}") else() set(pybind11_INCLUDEDIR "\${\${PACKAGE_PREFIX_DIR}}/${CMAKE_INSTALL_INCLUDEDIR}") endif() configure_package_config_file( tools/${PROJECT_NAME}Config.cmake.in "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake" INSTALL_DESTINATION ${PYBIND11_CMAKECONFIG_INSTALL_DIR}) if(CMAKE_VERSION VERSION_LESS 3.14) # Remove CMAKE_SIZEOF_VOID_P from ConfigVersion.cmake since the library does # not depend on architecture specific settings or libraries. set(_PYBIND11_CMAKE_SIZEOF_VOID_P ${CMAKE_SIZEOF_VOID_P}) unset(CMAKE_SIZEOF_VOID_P) write_basic_package_version_file( ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake VERSION ${PROJECT_VERSION} COMPATIBILITY AnyNewerVersion) set(CMAKE_SIZEOF_VOID_P ${_PYBIND11_CMAKE_SIZEOF_VOID_P}) else() # CMake 3.14+ natively supports header-only libraries write_basic_package_version_file( ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake VERSION ${PROJECT_VERSION} COMPATIBILITY AnyNewerVersion ARCH_INDEPENDENT) endif() install( FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake tools/FindPythonLibsNew.cmake tools/pybind11Common.cmake tools/pybind11Tools.cmake tools/pybind11NewTools.cmake tools/pybind11GuessPythonExtSuffix.cmake DESTINATION ${PYBIND11_CMAKECONFIG_INSTALL_DIR}) if(NOT PYBIND11_EXPORT_NAME) set(PYBIND11_EXPORT_NAME "${PROJECT_NAME}Targets") endif() install(TARGETS pybind11_headers EXPORT "${PYBIND11_EXPORT_NAME}") install( EXPORT "${PYBIND11_EXPORT_NAME}" NAMESPACE "pybind11::" DESTINATION ${PYBIND11_CMAKECONFIG_INSTALL_DIR}) # pkg-config support if(NOT prefix_for_pc_file) if(IS_ABSOLUTE "${CMAKE_INSTALL_DATAROOTDIR}") set(prefix_for_pc_file "${CMAKE_INSTALL_PREFIX}") else() set(pc_datarootdir "${CMAKE_INSTALL_DATAROOTDIR}") if(CMAKE_VERSION VERSION_LESS 3.20) set(prefix_for_pc_file "\${\${pcfiledir}}/..") while(pc_datarootdir) get_filename_component(pc_datarootdir "${pc_datarootdir}" DIRECTORY) string(APPEND prefix_for_pc_file "/..") endwhile() else() cmake_path(RELATIVE_PATH CMAKE_INSTALL_PREFIX BASE_DIRECTORY CMAKE_INSTALL_DATAROOTDIR OUTPUT_VARIABLE prefix_for_pc_file) endif() endif() endif() join_paths(includedir_for_pc_file "\${\${prefix}}" "${CMAKE_INSTALL_INCLUDEDIR}") configure_file("${CMAKE_CURRENT_SOURCE_DIR}/tools/pybind11.pc.in" "${CMAKE_CURRENT_BINARY_DIR}/pybind11.pc" @ONLY) install(FILES "${CMAKE_CURRENT_BINARY_DIR}/pybind11.pc" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/pkgconfig/") # Uninstall target if(PYBIND11_MASTER_PROJECT) configure_file("${CMAKE_CURRENT_SOURCE_DIR}/tools/cmake_uninstall.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" IMMEDIATE @ONLY) add_custom_target(uninstall COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake) endif() endif() ``` -------------------------------- ### Install PyMaterialXGenGlsl Target Source: https://github.com/academysoftwarefoundation/materialx/blob/main/source/PyMaterialX/PyMaterialXGenGlsl/CMakeLists.txt Installs the PyMaterialXGenGlsl target to the specified destination folder. ```cmake install(TARGETS PyMaterialXGenGlsl DESTINATION "${MATERIALX_PYTHON_FOLDER_NAME}") ``` -------------------------------- ### Setting Install RPATH for MaterialXView Source: https://github.com/academysoftwarefoundation/materialx/blob/main/source/MaterialXView/CMakeLists.txt Configures the runtime search path for libraries installed with the MaterialXView executable. ```cmake set_target_properties( MaterialXView PROPERTIES INSTALL_RPATH "${MATERIALX_UP_ONE_RPATH}") ``` -------------------------------- ### Constant Node Example Source: https://github.com/academysoftwarefoundation/materialx/blob/main/documents/Specification/MaterialX.StandardNodes.md An example of the 'constant' node, which outputs a predefined value. This snippet shows its usage for a color3 type. ```xml ``` -------------------------------- ### Append Specific ImGuiNodeEditor Source and Headers Source: https://github.com/academysoftwarefoundation/materialx/blob/main/source/MaterialXGraphEditor/CMakeLists.txt Appends specific example utility source and header files for ImGuiNodeEditor to the globbed lists. ```cmake set(imguinode_source ${imguinode_source} "${CMAKE_CURRENT_SOURCE_DIR}/External/ImGuiNodeEditor/examples/blueprints-example/utilities/drawing.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/External/ImGuiNodeEditor/examples/blueprints-example/utilities/widgets.cpp") set(imguinode_headers ${imguinode_headers} "${CMAKE_CURRENT_SOURCE_DIR}/External/ImGuiNodeEditor/examples/blueprints-example/utilities/drawing.h" "${CMAKE_CURRENT_SOURCE_DIR}/External/ImGuiNodeEditor/examples/blueprints-example/utilities/widgets.h") ``` -------------------------------- ### NanoGUI External Build Option Source: https://github.com/academysoftwarefoundation/materialx/blob/main/source/MaterialXView/CMakeLists.txt Configures the build to use an external NanoGUI installation. Ensure NANOGUI_ROOT is set if using this option. ```cmake option(MATERIALX_NANOGUI_EXTERNAL "Build against an external install of NanoGUI (NANOGUI_ROOT may also need to be set)" OFF) ``` -------------------------------- ### Example AOV Output Elements Source: https://github.com/academysoftwarefoundation/materialx/blob/main/documents/Specification/MaterialX.Proposals.md Illustrates how to define AOV outputs for different types, such as color3 for diffuse color and BSDF for shader node outputs. These examples show the practical application of the element. ```xml nodename="diffuse_bsdf"/> ``` -------------------------------- ### Configure noise2d Node Source: https://github.com/academysoftwarefoundation/materialx/blob/main/documents/Specification/MaterialX.StandardNodes.md Example of configuring a 2D Perlin noise node with pivot and amplitude values. ```xml ``` -------------------------------- ### Configure pyproject.toml for Python Installation Source: https://github.com/academysoftwarefoundation/materialx/blob/main/python/CMakeLists.txt Configures the pyproject.toml file during installation when MaterialX Python support is enabled, a Python executable is found, and SKBUILD is not used. This ensures the Python package metadata is correctly set up. ```cmake if(MATERIALX_INSTALL_PYTHON AND PYTHON_EXECUTABLE AND NOT SKBUILD) set(PYPROJECT_TOML "${CMAKE_INSTALL_PREFIX}/python/pyproject.toml") configure_file("${CMAKE_CURRENT_SOURCE_DIR}/pyproject.toml.in" "${PYPROJECT_TOML}") endif() ``` -------------------------------- ### MaterialX XInclude Example Source: https://github.com/academysoftwarefoundation/materialx/blob/main/documents/Specification/MaterialX.Supplement.md Demonstrates how to include MaterialX definition files using XML's xi:include directive. This is useful for modularizing MaterialX documents. ```xml ``` -------------------------------- ### Build MaterialXGenOsl_LibsToOso Executable Source: https://github.com/academysoftwarefoundation/materialx/blob/main/source/MaterialXGenOsl/CMakeLists.txt Creates an executable for converting libraries to Oso, linking necessary MaterialX components and optionally OSL if found. Includes installation rules. ```cmake if (MATERIALX_BUILD_OSOS) file(GLOB GenNodes_SRC "${CMAKE_CURRENT_SOURCE_DIR}/LibsToOso.cpp") add_executable(MaterialXGenOsl_LibsToOso ${GenNodes_SRC}) target_link_libraries(MaterialXGenOsl_LibsToOso PRIVATE MaterialXCore MaterialXFormat MaterialXGenShader MaterialXGenOsl) if (OSL_FOUND) target_link_libraries(MaterialXGenOsl_LibsToOso PRIVATE OSL::oslcomp) target_compile_definitions(MaterialXGenOsl_LibsToOso PRIVATE USE_OSLCOMP) endif() set_target_properties( MaterialXGenOsl_LibsToOso PROPERTIES INSTALL_RPATH "${MATERIALX_UP_ONE_RPATH}") # TODO: We likely want to install that file elsewhere and not under `bin`, # if at all, as we maybe want to keep this executable available at build time only. install(TARGETS MaterialXGenOsl_LibsToOso EXPORT MaterialX RUNTIME DESTINATION ${MATERIALX_INSTALL_BIN_PATH}) if(MSVC) install(FILES $ DESTINATION ${MATERIALX_INSTALL_BIN_PATH} OPTIONAL) endif() endif() ``` -------------------------------- ### Configure Wayland Backend for Window Creation Source: https://github.com/academysoftwarefoundation/materialx/blob/main/source/MaterialXGraphEditor/External/Glfw/CMakeLists.txt Finds and configures Wayland, WaylandScanner, WaylandProtocols, and XKBCommon for Wayland window creation. Includes checks for Egl, Compose, memfd_create, and EpollShim. ```cmake if (_GLFW_WAYLAND) find_package(ECM REQUIRED NO_MODULE) list(APPEND CMAKE_MODULE_PATH "${ECM_MODULE_PATH}") find_package(Wayland REQUIRED Client Cursor Egl) find_package(WaylandScanner REQUIRED) find_package(WaylandProtocols 1.15 REQUIRED) list(APPEND glfw_PKG_DEPS "wayland-egl") list(APPEND glfw_INCLUDE_DIRS "${Wayland_INCLUDE_DIRS}") list(APPEND glfw_LIBRARIES "${Wayland_LIBRARIES}") find_package(XKBCommon REQUIRED) list(APPEND glfw_INCLUDE_DIRS "${XKBCOMMON_INCLUDE_DIRS}") include(CheckIncludeFiles) include(CheckFunctionExists) check_include_files(xkbcommon/xkbcommon-compose.h HAVE_XKBCOMMON_COMPOSE_H) check_function_exists(memfd_create HAVE_MEMFD_CREATE) if (NOT ("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")) find_package(EpollShim) if (EPOLLSHIM_FOUND) list(APPEND glfw_INCLUDE_DIRS "${EPOLLSHIM_INCLUDE_DIRS}") list(APPEND glfw_LIBRARIES "${EPOLLSHIM_LIBRARIES}") endif() endif() endif() ``` -------------------------------- ### Configure X11 Backend for Window Creation Source: https://github.com/academysoftwarefoundation/materialx/blob/main/source/MaterialXGraphEditor/External/Glfw/CMakeLists.txt Finds the X11 package and its components (XRandR, Xinerama, Xkb, Xcursor, Xi) for window creation. Sets up include paths and libraries, and checks for the presence of essential X11 extensions. ```cmake if (_GLFW_X11) find_package(X11 REQUIRED) list(APPEND glfw_PKG_DEPS "x11") # Set up library and include paths list(APPEND glfw_INCLUDE_DIRS "${X11_X11_INCLUDE_PATH}") list(APPEND glfw_LIBRARIES "${X11_X11_LIB}") # Check for XRandR (modern resolution switching and gamma control) if (NOT X11_Xrandr_INCLUDE_PATH) message(FATAL_ERROR "RandR headers not found; install libxrandr development package") endif() # Check for Xinerama (legacy multi-monitor support) if (NOT X11_Xinerama_INCLUDE_PATH) message(FATAL_ERROR "Xinerama headers not found; install libxinerama development package") endif() # Check for Xkb (X keyboard extension) if (NOT X11_Xkb_INCLUDE_PATH) message(FATAL_ERROR "XKB headers not found; install X11 development package") endif() # Check for Xcursor (cursor creation from RGBA images) if (NOT X11_Xcursor_INCLUDE_PATH) message(FATAL_ERROR "Xcursor headers not found; install libxcursor development package") endif() # Check for XInput (modern HID input) if (NOT X11_Xi_INCLUDE_PATH) message(FATAL_ERROR "XInput headers not found; install libxi development package") endif() endif() ``` -------------------------------- ### Instantiate a Shader Node with Values Source: https://github.com/academysoftwarefoundation/materialx/blob/main/documents/Specification/MaterialX.Specification.md Instantiate a shader node by providing specific input values. This example shows how to set 'diffColor', 'specColor', and 'specRoughness' for a 'unified_srf' shader node. ```xml ``` -------------------------------- ### MaterialXView Command-Line Options Source: https://github.com/academysoftwarefoundation/materialx/blob/main/documents/DeveloperGuide/Viewer.md This section lists and describes the common command-line options for the MaterialXView tool. Use `--help` for a complete list. ```APIDOC ## MaterialXView Command-Line Options ### Description This section details the various command-line arguments that can be used to control the behavior and appearance of the MaterialXView application. ### Command-Line Options - **`--material [FILENAME]`** (string) - Specify the filename of the MTLX document to be displayed in the viewer. - **`--mesh [FILENAME]`** (string) - Specify the filename of the OBJ or glTF mesh to be displayed in the viewer. - **`--meshRotation [VECTOR3]`** (vector3) - Specify the rotation of the displayed mesh as three comma-separated floats, representing rotations in degrees about the X, Y, and Z axes (defaults to 0,0,0). - **`--meshScale [FLOAT]`** (float) - Specify the uniform scale of the displayed mesh. - **`--cameraPosition [VECTOR3]`** (vector3) - Specify the position of the camera as three comma-separated floats (defaults to 0,0,5). - **`--cameraTarget [VECTOR3]`** (vector3) - Specify the position of the camera target as three comma-separated floats (defaults to 0,0,0). - **`--cameraViewAngle [FLOAT]`** (float) - Specify the view angle of the camera, or zero for an orthographic projection (defaults to 45). - **`--cameraZoom [FLOAT]`** (float) - Specify the zoom factor for the camera, implemented as a mesh scale multiplier (defaults to 1). - **`--envRad [FILENAME]`** (string) - Specify the filename of the environment light to display, stored as HDR environment radiance in the latitude-longitude format. - **`--envMethod [INTEGER]`** (integer) - Specify the environment lighting method (0 = filtered importance sampling, 1 = prefiltered environment maps, defaults to 0). - **`--envSampleCount [INTEGER]`** (integer) - Specify the environment sample count (defaults to 16). - **`--lightRotation [FLOAT]`** (float) - Specify the rotation in degrees of the lighting environment about the Y axis (defaults to 0). - **`--path [FILEPATH]`** (filepath) - Specify an additional data search path location (e.g. '/projects/MaterialX'). This absolute path will be queried when locating data libraries, XInclude references, and referenced images. - **`--library [FILEPATH]`** (filepath) - Specify an additional data library folder (e.g. 'vendorlib', 'studiolib'). This relative path will be appended to each location in the data search path when loading data libraries. - **`--screenWidth [INTEGER]`** (integer) - Specify the width of the screen image in pixels (defaults to 1280). - **`--screenHeight [INTEGER]`** (integer) - Specify the height of the screen image in pixels (defaults to 960). - **`--screenColor [VECTOR3]`** (vector3) - Specify the background color of the viewer as three comma-separated floats (defaults to 0.3,0.3,0.32). - **`--captureFilename [FILENAME]`** (string) - Specify the filename to which the first rendered frame should be written. - **`--refresh [FLOAT]`** (float) - Specify the refresh period for the viewer in milliseconds (defaults to 50, set to -1 to disable). - **`--remap [TOKEN1:TOKEN2]`** (string) - Specify the remapping from one token to another when MaterialX document is loaded. - **`--skip [NAME]`** (string) - Specify to skip elements matching the given name attribute. - **`--terminator [STRING]`** (string) - Specify to enforce the given terminator string for file prefixes. - **`--help`** - Display the complete list of command-line options. ``` -------------------------------- ### Create Material with Shader Connection Source: https://github.com/academysoftwarefoundation/materialx/blob/main/documents/Specification/MaterialX.Specification.md This XML demonstrates creating a 'standard_surface' shader and connecting it to a 'surfacematerial' node's 'surfaceshader' input. ```xml ``` -------------------------------- ### Equivalent XML with and without fileprefix Source: https://github.com/academysoftwarefoundation/materialx/blob/main/documents/Specification/MaterialX.Specification.md Demonstrates how fileprefix attributes can simplify XML structure by defining common path components. ```xml ``` ```xml ``` -------------------------------- ### Adding Definitions for Build Source: https://github.com/academysoftwarefoundation/materialx/blob/main/source/MaterialXView/CMakeLists.txt Adds preprocessor definitions for NanoGUI and the selected render backend. ```cmake add_definitions(${NANOGUI_EXTRA_DEFS}) add_definitions(${MATERIALXVIEW_RENDER_BACKEND_DEFINITIONS}) ``` -------------------------------- ### Set Visual Studio Startup Projects Source: https://github.com/academysoftwarefoundation/materialx/blob/main/CMakeLists.txt Configures the default startup project in Visual Studio based on build flags for viewer, graph editor, or tests. ```cmake if(MATERIALX_BUILD_VIEWER) set_property(DIRECTORY PROPERTY VS_STARTUP_PROJECT MaterialXView) elseif(MATERIALX_BUILD_GRAPH_EDITOR) set_property(DIRECTORY PROPERTY VS_STARTUP_PROJECT MaterialXGraphEditor) elseif(MATERIALX_BUILD_TESTS) set_property(DIRECTORY PROPERTY VS_STARTUP_PROJECT MaterialXTest) endif() ``` -------------------------------- ### Install Scripts for SKBUILD Source: https://github.com/academysoftwarefoundation/materialx/blob/main/python/CMakeLists.txt Installs scripts to a specific subdirectory for SKBUILD, excluding README.md files. This is for internal build system integration. ```cmake if(SKBUILD) install( DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/Scripts/" DESTINATION "${MATERIALX_PYTHON_FOLDER_NAME}/_scripts" PATTERN "README.md" EXCLUDE ) endif() ``` -------------------------------- ### Conditional Resource Installation in CMake Source: https://github.com/academysoftwarefoundation/materialx/blob/main/resources/CMakeLists.txt Installs the resources directory only if SKBUILD is not enabled. Ensure CMake is configured correctly for your build environment. ```cmake if(NOT SKBUILD) install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ DESTINATION "resources" MESSAGE_NEVER) endif() ``` -------------------------------- ### Configure Win32 Backend for Window Creation Source: https://github.com/academysoftwarefoundation/materialx/blob/main/source/MaterialXGraphEditor/External/Glfw/CMakeLists.txt Appends the 'gdi32' library to the package libraries when the Win32 backend is selected. Also checks for the GLFW_USE_HYBRID_HPG option. ```cmake if (_GLFW_WIN32) list(APPEND glfw_PKG_LIBS "-lgdi32") if (GLFW_USE_HYBRID_HPG) set(_GLFW_USE_HYBRID_HPG 1) endif() endif() ``` -------------------------------- ### Ramp Table Node Example Source: https://github.com/academysoftwarefoundation/materialx/blob/main/documents/Specification/MaterialX.StandardNodes.md An example of the 'ramptb' node, used for creating a table-based ramp. This snippet demonstrates its configuration for a float type. ```xml ``` -------------------------------- ### NanoGUI Preferred Backend Selection Source: https://github.com/academysoftwarefoundation/materialx/blob/main/source/MaterialXView/CMakeLists.txt Sets the preferred NanoGUI backend, defaulting to OpenGL and switching to Metal on Apple platforms under specific conditions. ```cmake set(NANOGUI_PREFERRED_BACKEND OpenGL) if(APPLE) option(USE_OPENGL_BACKEND_ON_APPLE_PLATFORM "Use OpenGL Backend on Apple Platform" OFF) # Disables MaterialXView Metal Rendering on MacOS version below 10.14 if (CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin" AND CMAKE_HOST_SYSTEM_VERSION VERSION_LESS 19) set(USE_OPENGL_BACKEND_ON_APPLE_PLATFORM ON) endif() if(USE_OPENGL_BACKEND_ON_APPLE_PLATFORM) set(NANOGUI_PREFERRED_BACKEND OpenGL) set(MATERIALXVIEW_RENDER_BACKEND_DEFINITIONS "-DMATERIALXVIEW_OPENGL_BACKEND=1") else() set(NANOGUI_PREFERRED_BACKEND Metal) set(MATERIALXVIEW_RENDER_BACKEND_DEFINITIONS "-DMATERIALXVIEW_METAL_BACKEND=1") endif() endif() ``` -------------------------------- ### Image Texture Node Examples Source: https://github.com/academysoftwarefoundation/materialx/blob/main/documents/Specification/MaterialX.StandardNodes.md Examples of 'image' nodes used for reading filtered image data from files. Specifies the file to read and a default color if the file is not found. ```xml ``` ```xml ``` -------------------------------- ### Install MaterialXView PDB on MSVC Source: https://github.com/academysoftwarefoundation/materialx/blob/main/source/MaterialXView/CMakeLists.txt Conditionally installs the PDB (Program Database) file for MaterialXView on Microsoft Visual C++ (MSVC) builds. This is typically done to provide debugging symbols. ```cmake if(MSVC) install(FILES $ DESTINATION ${MATERIALX_INSTALL_BIN_PATH} OPTIONAL) endif() ``` -------------------------------- ### Configuring NanoGUI Build Options (Internal) Source: https://github.com/academysoftwarefoundation/materialx/blob/main/source/MaterialXView/CMakeLists.txt Sets various build options for NanoGUI when building it internally as a submodule. ```cmake set(NANOGUI_BACKEND ${NANOGUI_PREFERRED_BACKEND} CACHE STRING " " FORCE) set(NANOGUI_BUILD_EXAMPLES OFF CACHE BOOL " " FORCE) set(NANOGUI_BUILD_SHARED OFF CACHE BOOL " " FORCE) set(NANOGUI_BUILD_PYTHON OFF CACHE BOOL " " FORCE) set(NANOGUI_INSTALL OFF CACHE BOOL " " FORCE) if(APPLE) set(NANOGUI_NATIVE_FLAGS CACHE STRING "" FORCE) endif() ``` -------------------------------- ### Set Install Include Directory Source: https://github.com/academysoftwarefoundation/materialx/blob/main/source/PyMaterialX/External/PyBind11/CMakeLists.txt Determines the installation directory for include files based on Python include directories. Use when Python include directories are defined and the USE_PYTHON_INCLUDE_DIR flag is set. ```cmake if(USE_PYTHON_INCLUDE_DIR AND DEFINED Python_INCLUDE_DIRS) file(RELATIVE_PATH CMAKE_INSTALL_INCLUDEDIR ${CMAKE_INSTALL_PREFIX} ${Python_INCLUDE_DIRS}) elseif(USE_PYTHON_INCLUDE_DIR AND DEFINED PYTHON_INCLUDE_DIR) file(RELATIVE_PATH CMAKE_INSTALL_INCLUDEDIR ${CMAKE_INSTALL_PREFIX} ${PYTHON_INCLUDE_DIRS}) endif() ``` -------------------------------- ### Set up emscripten SDK Environment Source: https://github.com/academysoftwarefoundation/materialx/blob/main/javascript/README.md Source this script to set the necessary environment variables for the emscripten SDK in your current terminal session. This is required for using the SDK's tools. ```sh source ./emsdk_env.sh ``` -------------------------------- ### Define Vector2Array Value Source: https://github.com/academysoftwarefoundation/materialx/blob/main/documents/Specification/MaterialX.Specification.md Example of defining a Vector2Array with comma-separated X, Y values. ```text vector2arrayvalue = "0,.1, .4,.5, .9,1.0" ``` -------------------------------- ### Define Color4Array Value Source: https://github.com/academysoftwarefoundation/materialx/blob/main/documents/Specification/MaterialX.Specification.md Example of defining a Color4Array with comma-separated RGBA values. ```text color4arrayvalue = ".1,.2,.3,1, .2,.3,.4,.98, .3,.4,.5,.9" ``` -------------------------------- ### Configure Config Header and Add Source Source: https://github.com/academysoftwarefoundation/materialx/blob/main/source/MaterialXGraphEditor/External/Glfw/src/CMakeLists.txt Configures the 'glfw_config.h' header file and adds it as a source to 'glfw_minimal'. This incorporates build-specific configurations into the library. ```cmake configure_file(glfw_config.h.inglfw_config.h @ONLY) target_compile_definitions(glfw_minimal PRIVATE _GLFW_USE_CONFIG_H) target_sources(glfw_minimal PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/glfw_config.h") ``` -------------------------------- ### Define Color3Array Value Source: https://github.com/academysoftwarefoundation/materialx/blob/main/documents/Specification/MaterialX.Specification.md Example of defining a Color3Array with comma-separated RGB values. ```text color3arrayvalue = ".1,.2,.3, .2,.3,.4, .3,.4,.5" ``` -------------------------------- ### Load Standard Libraries and Document Source: https://github.com/academysoftwarefoundation/materialx/blob/main/javascript/README.md Load the standard libraries required for shader code assembly and create a MaterialX document. Ensure these libraries are imported into the document. ```javascript const stdlib = mx.loadStandardLibraries(genContext); const doc = mx.createDocument(); doc.importLibrary(stdlib); ``` -------------------------------- ### Define FloatArray Value Source: https://github.com/academysoftwarefoundation/materialx/blob/main/documents/Specification/MaterialX.Specification.md Example of defining a FloatArray with comma-separated float values. ```text floatarrayvalue = "1.0, 2.2, 3.3, 4.4, 5.5" ``` -------------------------------- ### Define IntegerArray Value Source: https://github.com/academysoftwarefoundation/materialx/blob/main/documents/Specification/MaterialX.Specification.md Example of defining an IntegerArray with comma-separated integer values. ```text integerarrayvalue = "1,2,3,4,5" ``` -------------------------------- ### Create and Navigate to Build Directory Source: https://github.com/academysoftwarefoundation/materialx/blob/main/javascript/README.md Create a build directory within the javascript folder and change into it. This is the standard practice for out-of-source builds with CMake. ```sh mkdir ./javascript/build cd ./javascript/build ```