Skip to content

Commit

Permalink
Merge branch 'main' into nikelsm/materialx_dev
Browse files Browse the repository at this point in the history
  • Loading branch information
mnikelsky authored Aug 30, 2023
2 parents fdfaada + 0675af7 commit 26bef45
Show file tree
Hide file tree
Showing 87 changed files with 2,722 additions and 686 deletions.
15 changes: 8 additions & 7 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,12 @@ jobs:
cmake_config: -DMATERIALX_BUILD_SHARED_LIBS=ON
static_analysis: ON

- name: Linux_Clang_13_Python39
os: ubuntu-22.04
compiler: clang
compiler_version: "13"
python: 3.9
test_render: ON

- name: Linux_Clang_14_Python311
os: ubuntu-22.04
compiler: clang
compiler_version: "14"
python: 3.11
test_render: ON
clang_format: ON

- name: Linux_Clang_14_DynamicAnalysis
Expand Down Expand Up @@ -89,6 +83,13 @@ jobs:
python: 3.11
test_shaders: ON

- name: iOS_Xcode_14
os: macos-13
compiler: xcode
compiler_version: "14.3"
python: None
cmake_config: -DMATERIALX_BUILD_IOS=ON -DCMAKE_OSX_SYSROOT=`xcrun --sdk iphoneos --show-sdk-path` -DCMAKE_OSX_ARCHITECTURES=arm64

- name: Windows_VS2019_Win32_Python37
os: windows-2019
architecture: x86
Expand Down
130 changes: 130 additions & 0 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
name: python

on:
push:
paths-ignore:
- '**.md'
pull_request:
paths-ignore:
- '**.md'
workflow_dispatch:

jobs:
# Generate the sdist first. We'll use it to create the wheels.
# https://packaging.python.org/en/latest/flow#the-source-distribution-sdist
sdist:
name: Generate Source Distribution
runs-on: ubuntu-latest
outputs:
sdist_filename: ${{ steps.generate.outputs.filename }}

steps:
- name: Sync Repository
uses: actions/checkout@v3

- name: Install Python ${{ matrix.python }}
uses: actions/setup-python@v4
with:
python-version: 3.11

- name: Install Build Command
run: python -m pip install build

- name: Generate Sdist
id: generate
run: |
python -m build -s . --outdir dist
echo "filename=$(ls dist)" >> "$GITHUB_OUTPUT"
- name: Upload Sdist
uses: actions/upload-artifact@v3
with:
name: MaterialX_Python_Source_Distribution
path: ./dist/*.tar.gz

# Create the wheels. It'll use the sdist to confirm that we can compile MaterialX from the sdist.
# https://packaging.python.org/en/latest/flow#the-built-distributions-wheels
wheels:
name: Generate Wheel
runs-on: ${{ matrix.os }}
needs: ['sdist']
strategy:
fail-fast: false
matrix:
python-version: ['37', '38', '39', '310', '311']
os: ['ubuntu-latest', 'macos-latest', 'windows-latest']

steps:
- name: Download Sdist
uses: actions/download-artifact@v3
with:
name: MaterialX_Python_Source_Distribution
path: sdist

- name: Build Wheel
# https://cibuildwheel.readthedocs.io/en/stable/
uses: pypa/[email protected]
with:
# Build from the sdist. We want to make sure it's valid and works as expected.
package-dir: ${{ github.workspace }}/sdist/${{ needs.sdist.outputs.sdist_filename }}
output-dir: wheels
env:
CIBW_BUILD: 'cp${{ matrix.python-version }}-*'
CIBW_SKIP: '*musllinux*'
CIBW_ARCHS: 'auto64'
# https:/pypa/manylinux
# manylinux2014 is CentOS 7 based. Which means GCC 10 and glibc 2.17.
CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014
CIBW_BEFORE_ALL_LINUX: yum install -y libXt-devel
CIBW_BEFORE_ALL_MACOS: sudo xcode-select -switch /Applications/Xcode_13.4.app
CIBW_BUILD_VERBOSITY: 1
CIBW_ENVIRONMENT: CMAKE_BUILD_PARALLEL_LEVEL=2
# CIBW_BUILD_FRONTEND: build # https:/pypa/build
MACOSX_DEPLOYMENT_TARGET: '10.15'

- name: Upload Wheel
uses: actions/upload-artifact@v3
with:
name: MaterialX_Python_Wheels
path: ./wheels/*.whl

test:
name: Test Wheel
needs: ['wheels']
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11']
os: ['ubuntu-latest', 'macos-latest', 'windows-latest']

steps:
- uses: actions/checkout@v3

- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Download Wheels
uses: actions/download-artifact@v3
with:
name: MaterialX_Python_Wheels
path: wheels

- name: Install Wheel
run: python -m pip install MaterialX --find-links wheels --no-index

- name: Python Tests
shell: bash
run: |
set -e
python python/MaterialXTest/main.py
python python/MaterialXTest/genshader.py
python python/Scripts/mxformat.py ./resources/Materials/TestSuite/stdlib/upgrade --yes --upgrade
python python/Scripts/mxvalidate.py ./resources/Materials/Examples/StandardSurface/standard_surface_marble_solid.mtlx --stdlib --verbose
python python/Scripts/mxdoc.py --docType md ./libraries/pbrlib/pbrlib_defs.mtlx
python python/Scripts/mxdoc.py --docType html ./libraries/bxdf/standard_surface.mtlx
python python/Scripts/generateshader.py ./resources/Materials/Examples/StandardSurface --target glsl
python python/Scripts/generateshader.py ./resources/Materials/Examples/StandardSurface --target osl
python python/Scripts/generateshader.py ./resources/Materials/Examples/StandardSurface --target mdl
python python/Scripts/generateshader.py ./resources/Materials/Examples/StandardSurface --target msl
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
build
dist
29 changes: 29 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,35 @@

## [1.38.8] - Development

### Added
- Added a broad set of new pattern nodes to MaterialX, including [Circle, Hexagon, Cloverleaf, Line, Grid, Crosshatch](https:/AcademySoftwareFoundation/MaterialX/pull/1411), [Checkerboard](https:/AcademySoftwareFoundation/MaterialX/pull/1328), [Random Color, Random Float](https:/AcademySoftwareFoundation/MaterialX/pull/1330), [Triangle Wave](https:/AcademySoftwareFoundation/MaterialX/pull/1334), [Integer Floor, Integer Ceiling](https:/AcademySoftwareFoundation/MaterialX/pull/1362), and [Distance](https:/AcademySoftwareFoundation/MaterialX/pull/1333).
- Added support for [MaterialX builds on iOS](https:/AcademySoftwareFoundation/MaterialX/pull/1435).
- Added support for [drag-and-drop import](https:/AcademySoftwareFoundation/MaterialX/pull/1482) of MaterialX files in the [Web Viewer](https://academysoftwarefoundation.github.io/MaterialX/).
- Added generation of [MaterialX Python wheels](https:/AcademySoftwareFoundation/MaterialX/pull/1317) in GitHub Actions, enabling the distribution of MaterialX Python packages through PyPI.
- Added support for the [lin_displayp3 and srgb_displayp3](https:/AcademySoftwareFoundation/MaterialX/pull/1368) colorspaces in shader generation.
- Added support for the [blackbody PBR node](https:/AcademySoftwareFoundation/MaterialX/pull/1367) in shader generation.
- Added support for [displacement](https:/AcademySoftwareFoundation/MaterialX/pull/1396) in MDL generation.
- Added version details to [shared libraries](https:/AcademySoftwareFoundation/MaterialX/pull/1447) on Windows.
- Added a [MacOS 13](https:/AcademySoftwareFoundation/MaterialX/pull/1375) build to GitHub Actions.

### Changed
- Raised the minimum C++ version for MaterialX builds to [C++14](https:/AcademySoftwareFoundation/MaterialX/pull/1340).
- Upgraded the [PyBind11 library](https:/AcademySoftwareFoundation/MaterialX/pull/1343) to version 2.10.4, raising the minimum Python version to 3.6, and enabling support for Python versions 3.11 and beyond.
- Improved the performance and convergence of [GGX importance sampling](https:/AcademySoftwareFoundation/MaterialX/pull/1390) in GLSL generation, leveraging insights from the HPG 2023 paper by Jonathan Dupuy and Anis Benyoub.
- Improved [property panel display](https:/AcademySoftwareFoundation/MaterialX/pull/1346) in the MaterialX Graph Editor.
- Improved [node spacing](https:/AcademySoftwareFoundation/MaterialX/pull/1476) in the MaterialX Graph Editor.
- Improved the robustness of [MaterialX unit tests](https:/AcademySoftwareFoundation/MaterialX/pull/1370) with respect to the current working directory.
- Simplified the handling of [default colors](https:/AcademySoftwareFoundation/MaterialX/pull/1452) in GLSL generation, removing dynamic branches on texture size.
- Simplified the definitions of the [default color transforms](https:/AcademySoftwareFoundation/MaterialX/pull/1352), implementing them as language-independent MaterialX graphs.
- Moved the MaterialX specification to [public Markdown files in GitHub](https:/AcademySoftwareFoundation/MaterialX/tree/main/documents/Specification), enabling direct contributions from the community.

### Fixed
- Fixed brightness artifacts in the [triplanar projection node](https:/AcademySoftwareFoundation/MaterialX/pull/1350).
- Aligned default values for [conductor_bsdf](https:/AcademySoftwareFoundation/MaterialX/pull/1379) with the MaterialX specification.
- Fixed [volume mixing](https:/AcademySoftwareFoundation/MaterialX/pull/1395) in MDL generation.
- Fixed a bug to improve [shader generation determinism](https:/AcademySoftwareFoundation/MaterialX/pull/1376).
- Fixed a bug to improve the [consistency of auto layout](https:/AcademySoftwareFoundation/MaterialX/pull/1389) in the MaterialX Graph Editor.

## [1.38.7] - 2023-04-21

### Added
Expand Down
87 changes: 62 additions & 25 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ if (MATERIALX_BUILD_JS)
endif()
endif()

project(MaterialX)
project(MaterialX VERSION ${MATERIALX_LIBRARY_VERSION})

option(MATERIALX_BUILD_PYTHON "Build the MaterialX Python package from C++ bindings. Requires Python 3.6 or greater." OFF)
option(MATERIALX_BUILD_VIEWER "Build the MaterialX Viewer." OFF)
Expand All @@ -55,6 +55,27 @@ option(MATERIALX_WARNINGS_AS_ERRORS "Interpret all compiler warnings as errors."
option(MATERIALX_DYNAMIC_ANALYSIS "Build MaterialX libraries with dynamic analysis on supporting platforms." OFF)
option(MATERIALX_OSL_LEGACY_CLOSURES "Build OSL shader generation supporting the legacy OSL closures." ON)

option(MATERIALX_BUILD_IOS "Build MaterialX for iOS." OFF)
if (MATERIALX_BUILD_IOS)
set(CMAKE_SYSTEM_NAME iOS)
add_definitions(-DTARGET_OS_IOS=1)
set(MATERIALX_BUILD_PYTHON OFF)
set(MATERIALX_BUILD_VIEWER OFF)
set(MATERIALX_BUILD_GRAPH_EDITOR OFF)
set(MATERIALX_BUILD_GEN_GLSL OFF)
set(MATERIALX_BUILD_GEN_OSL OFF)
set(MATERIALX_BUILD_GEN_GLSL OFF)
set(MATERIALX_BUILD_GEN_MDL OFF)
set(MATERIALX_BUILD_OIIO OFF)
set(MATERIALX_PYTHON_LTO OFF)
set(MATERIALX_INSTALL_PYTHON OFF)
set(MATERIALX_DYNAMIC_ANALYSIS OFF)
set(MATERIALX_DYNAMIC_ANALYSIS OFF)
set(MATERIALX_OSL_LEGACY_CLOSURES OFF)
set(MATERIALX_BUILD_TESTS OFF)
set(MATERIALX_TEST_RENDER OFF)
endif()

set(MATERIALX_PYTHON_VERSION "" CACHE STRING
"Python version to be used in building the MaterialX Python package (e.g. '3.9').")
set(MATERIALX_PYTHON_EXECUTABLE "" CACHE FILEPATH
Expand All @@ -80,6 +101,12 @@ set(MATERIALX_OSL_BINARY_OSLC "" CACHE FILEPATH "Full path to the OSL compiler b
set(MATERIALX_OSL_BINARY_TESTRENDER "" CACHE FILEPATH "Full path to the OSL test render binary.")
set(MATERIALX_OSL_INCLUDE_PATH "" CACHE PATH "Full path to OSL shader includes (e.g. 'stdosl.h').")

set(MATERIALX_PYTHON_FOLDER_NAME "python/MaterialX" CACHE INTERNAL "Folder name to user for installing the Python library.")

if(SKBUILD)
set(MATERIALX_PYTHON_FOLDER_NAME "MaterialX")
endif()

# Helpers for MDL validation
if (MATERIALX_BUILD_GEN_MDL)
set(MATERIALX_MDLC_EXECUTABLE "" CACHE FILEPATH "Full path to the mdlc binary.")
Expand Down Expand Up @@ -116,6 +143,7 @@ mark_as_advanced(MATERIALX_NAMESPACE_SUFFIX)
mark_as_advanced(MATERIALX_LIBNAME_SUFFIX)
mark_as_advanced(MATERIALX_PYTHON_LTO)
mark_as_advanced(MATERIALX_INSTALL_PYTHON)
mark_as_advanced(MATERIALX_INSTALL_RESOURCES)
mark_as_advanced(MATERIALX_TEST_RENDER)
mark_as_advanced(MATERIALX_WARNINGS_AS_ERRORS)
mark_as_advanced(MATERIALX_DYNAMIC_ANALYSIS)
Expand All @@ -133,6 +161,7 @@ mark_as_advanced(MATERIALX_INSTALL_LIB_PATH)
mark_as_advanced(MATERIALX_INSTALL_STDLIB_PATH)
mark_as_advanced(MATERIALX_BUILD_JS)
mark_as_advanced(MATERIALX_EMSDK_PATH)
mark_as_advanced(MATERIALX_BUILD_IOS)
if (MATERIALX_BUILD_GEN_MDL)
mark_as_advanced(MATERIALX_MDLC_EXECUTABLE)
mark_as_advanced(MATERIALX_MDL_RENDER_EXECUTABLE)
Expand Down Expand Up @@ -184,6 +213,12 @@ set(MATERIALX_SAME_DIR_RPATH "${RPATH_RELATIVE_SYMBOL};${CMAKE_INSTALL_PREFIX}/$
set(MATERIALX_UP_ONE_RPATH "${RPATH_RELATIVE_SYMBOL}/../${MATERIALX_INSTALL_LIB_PATH};${MATERIALX_SAME_DIR_RPATH}")
# For linking to libraries where source is two directories deep, ie: "MATX/python/MaterialX/../../lib"
set(MATERIALX_UP_TWO_RPATH "${RPATH_RELATIVE_SYMBOL}/../../${MATERIALX_INSTALL_LIB_PATH};${MATERIALX_SAME_DIR_RPATH}")
if(SKBUILD)
# When building the Python wheels, we don't want to set any RPATH because
# we want to wheel to be self-contained. We don't want any interference from
# external paths.
set(MATERIALX_UP_TWO_RPATH "${RPATH_RELATIVE_SYMBOL}")
endif()

# Adjust compiler settings
if(MSVC)
Expand Down Expand Up @@ -277,7 +312,7 @@ if(MATERIALX_BUILD_RENDER)
if(MATERIALX_BUILD_GRAPH_EDITOR)
add_subdirectory(source/MaterialXGraphEditor)
endif()
if(MATERIALX_INSTALL_RESOURCES)
if(MATERIALX_INSTALL_RESOURCES AND NOT SKBUILD)
add_subdirectory(resources)
endif()
endif()
Expand Down Expand Up @@ -312,26 +347,28 @@ if(${CMAKE_VERSION} VERSION_GREATER "3.6.2")
endif()

# Install root-level documents
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)
configure_package_config_file(cmake/modules/MaterialXConfig.cmake.in
${CMAKE_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(${CMAKE_BINARY_DIR}/cmake/${CMAKE_PROJECT_NAME}ConfigVersion.cmake
VERSION ${MATERIALX_LIBRARY_VERSION}
COMPATIBILITY AnyNewerVersion)

# Install the auto-generated CMake configuration files:

install(EXPORT MaterialX
DESTINATION "${MATERIALX_GEN_CONFIG_PATH}"
FILE ${CMAKE_PROJECT_NAME}Targets.cmake)

install(FILES "${CMAKE_BINARY_DIR}/cmake/${CMAKE_PROJECT_NAME}ConfigVersion.cmake"
"${CMAKE_BINARY_DIR}/cmake/${CMAKE_PROJECT_NAME}Config.cmake"
DESTINATION "${MATERIALX_GEN_CONFIG_PATH}")
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)
configure_package_config_file(cmake/modules/MaterialXConfig.cmake.in
${CMAKE_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(${CMAKE_BINARY_DIR}/cmake/${CMAKE_PROJECT_NAME}ConfigVersion.cmake
VERSION ${MATERIALX_LIBRARY_VERSION}
COMPATIBILITY AnyNewerVersion)

# Install the auto-generated CMake configuration files:

install(EXPORT MaterialX
DESTINATION "${MATERIALX_GEN_CONFIG_PATH}"
FILE ${CMAKE_PROJECT_NAME}Targets.cmake)

install(FILES "${CMAKE_BINARY_DIR}/cmake/${CMAKE_PROJECT_NAME}ConfigVersion.cmake"
"${CMAKE_BINARY_DIR}/cmake/${CMAKE_PROJECT_NAME}Config.cmake"
DESTINATION "${MATERIALX_GEN_CONFIG_PATH}")
endif()
34 changes: 34 additions & 0 deletions cmake/modules/MaterialXVersion.rc.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@

#define MATERIALX_FILEVERSION @MATERIALX_MAJOR_VERSION@,@MATERIALX_MINOR_VERSION@,@MATERIALX_BUILD_VERSION@,0
#define MATERIALX_FILEVERSION_STR "@MATERIALX_MAJOR_VERSION@.@MATERIALX_MINOR_VERSION@.@[email protected]\0"
#define MATERIALX_FILENAME_STR "@[email protected]\0"

1 VERSIONINFO
FILEVERSION MATERIALX_FILEVERSION
PRODUCTVERSION MATERIALX_FILEVERSION
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x4L
FILETYPE 0x1L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904E4"
BEGIN
VALUE "FileVersion", MATERIALX_FILEVERSION_STR
VALUE "LegalCopyright", "Apache License 2.0\0"
VALUE "OriginalFilename", MATERIALX_FILENAME_STR
VALUE "ProductName", "MaterialX\0"
VALUE "ProductVersion", MATERIALX_FILEVERSION_STR
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1252
END
END
Loading

0 comments on commit 26bef45

Please sign in to comment.