Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
b1b5d0a
Add native WGSL (genwgsl) shader generator
ashwinbhat Jul 3, 2026
8122045
Add wgsl data library
ashwinbhat Jul 3, 2026
f12bb7e
Add three.js/WebGPU viewer backend driven by WgslShaderGenerator
ashwinbhat Jul 3, 2026
dc547d0
Add Python binding for WgslShaderGenerator
ashwinbhat Jul 3, 2026
402e599
fixup: disable wgsl SPIRV validation
ashwinbhat Jul 3, 2026
ac17415
Merge branch 'main' into bhata/wgsl_generator_with_library
ashwinbhat Jul 6, 2026
fae361f
Delete auto-generated wgsl shaders fragments
ashwinbhat Jul 7, 2026
bbd7fb2
Enable wgsl data library generation during CI
ashwinbhat Jul 7, 2026
a2703ab
fix (build): Enable WGSL on python enabled runners
ashwinbhat Jul 7, 2026
0e96799
Merge branch 'main' into bhata/wgsl_generator_with_library
ashwinbhat Jul 8, 2026
8b0b063
Add developer documentation for WGSL Shader Generation
ashwinbhat Jul 9, 2026
7d89a79
Merge branch 'main' into bhata/wgsl_generator_with_library
ashwinbhat Jul 11, 2026
f035fb0
Remove hand-rolled wgsl microfacet library
ashwinbhat Jul 14, 2026
0fe2cc0
Update `glsl_to_wgsl.py` to generate the **entire** `genwgsl` node li…
ashwinbhat Jul 14, 2026
5381863
Implement WGSL prefilter env generation and update supporting shader …
ashwinbhat Jul 21, 2026
774d01a
Rename glsl_to_wgsl
ashwinbhat Jul 21, 2026
0cc09df
Add WGSL transpile tooling and cleanup test suite
ashwinbhat Jul 21, 2026
0eaf114
Update naga and documentation
ashwinbhat Jul 21, 2026
6375934
Add list of glsl transpile skip list
ashwinbhat Jul 21, 2026
4474257
Introduce a math helper mx_isinf
ashwinbhat Jul 21, 2026
c106374
Fix: mx_isinf
ashwinbhat Jul 22, 2026
c9693a0
[fixup!] Make shader cleanup optional
ashwinbhat Jul 23, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 42 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ permissions:
env:
CMAKE_BUILD_PARALLEL_LEVEL: 4
CTEST_PARALLEL_LEVEL: 4
NAGA_VERSION: "30.0.0"

jobs:

Expand Down Expand Up @@ -239,6 +240,24 @@ jobs:
if: matrix.clang_format == 'ON'
run: find source \( -name *.h -o -name *.cpp -o -name *.mm -o -name *.inl \) ! -path "*/External/*" ! -path "*/NanoGUI/*" | xargs clang-format -i --verbose

- name: Install naga
if: matrix.python != 'None'
run: cargo install naga-cli --locked --version ${{ env.NAGA_VERSION }}

- name: Generate WGSL library
if: matrix.python != 'None'
run: |
# Cleanup deps (tree-sitter) are optional and have no wheel on some interpreters (e.g. 3.9);
# install best-effort so their absence doesn't fail the build. Generation degrades to
# verbose-but-valid WGSL, and mxgenwgsl.py stays fatal so real failures still surface.
python -m pip install -r source/MaterialXGenWgsl/tools/requirements-transpile.txt \
|| echo "WGSL cleanup deps unavailable; generating verbose WGSL"
python source/MaterialXGenWgsl/tools/mxgenwgsl.py --libraries libraries --out libraries

- name: Test WGSL cleanup
if: matrix.python != 'None'
run: python source/MaterialXGenWgsl/tools/test_mxwgslcleanup.py

- name: CMake Generate
shell: bash
run: |
Expand All @@ -247,6 +266,7 @@ jobs:
-DMATERIALX_BUILD_PYTHON=ON \
-DMATERIALX_BUILD_TESTS=ON \
-DMATERIALX_TEST_RENDER=${{ matrix.extended_build_osl == 'ON' && 'ON' || 'OFF' }} \
-DMATERIALX_BUILD_GEN_WGSL=${{ matrix.python != 'None' && 'ON' || 'OFF' }} \
-DMATERIALX_WARNINGS_AS_ERRORS=ON \
${{ env.IS_EXTENDED_BUILD == 'true' && matrix.extended_cmake_config || '' }} \
${{ matrix.cmake_config }} \
Expand Down Expand Up @@ -290,7 +310,6 @@ jobs:
python python/Scripts/generateshader.py resources/Materials/Examples --target glsl --validator C:/vcpkg/installed/x64-windows-release/tools/glslang/glslangValidator.exe
python python/Scripts/generateshader.py resources/Materials/Examples/StandardSurface --target essl --validator C:/vcpkg/installed/x64-windows-release/tools/glslang/glslangValidator.exe
python python/Scripts/generateshader.py resources/Materials/Examples/StandardSurface --target vulkan --validator C:/vcpkg/installed/x64-windows-release/tools/glslang/glslangValidator.exe
python python/Scripts/generateshader.py resources/Materials/Examples/StandardSurface --target wgsl --validator "C:/vcpkg/installed/x64-windows-release/tools/glslang/glslangValidator.exe --target-env vulkan1.3 --quiet"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this removed ? If wgsl is available should it not be run still.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current validator uses glsllang that does not support wgsl syntax.
Note that the current generator was generating "glsl" code but the new one will generate "wgsl" code


- name: Shader Validation Tests (MacOS)
if: matrix.test_shaders == 'ON' && runner.os == 'macOS'
Expand Down Expand Up @@ -459,8 +478,21 @@ jobs:
with:
node-version: '22.16.0'

- name: Install naga
run: cargo install naga-cli --locked --version ${{ env.NAGA_VERSION }}

- name: Install Python
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6
with:
python-version: 3.13

- name: Generate WGSL library
run: |
python -m pip install -r source/MaterialXGenWgsl/tools/requirements-transpile.txt
python source/MaterialXGenWgsl/tools/mxgenwgsl.py --libraries libraries --out libraries

- name: JavaScript CMake Generate
run: cmake -S . -B javascript/build -DMATERIALX_BUILD_JS=ON -DMATERIALX_EMSDK_PATH=${{ env.EMSDK }}
run: cmake -S . -B javascript/build -DMATERIALX_BUILD_JS=ON -DMATERIALX_BUILD_GEN_WGSL=ON -DMATERIALX_EMSDK_PATH=${{ env.EMSDK }}

- name: JavaScript CMake Build
run: cmake --build javascript/build --target install --config Release
Expand Down Expand Up @@ -511,6 +543,14 @@ jobs:
with:
python-version: 3.11

- name: Install naga
run: cargo install naga-cli --locked --version ${{ env.NAGA_VERSION }}

- name: Generate WGSL library
run: |
python -m pip install -r source/MaterialXGenWgsl/tools/requirements-transpile.txt
python source/MaterialXGenWgsl/tools/mxgenwgsl.py --libraries libraries --out libraries

- name: Build SDist
id: generate
run: |
Expand Down
14 changes: 14 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ jobs:
runs-on: ubuntu-latest
env:
RELEASE_TAG: ${{ github.ref_name }}
NAGA_VERSION: "30.0.0"
permissions:
contents: write
id-token: write
Expand All @@ -28,6 +29,19 @@ jobs:
- name: Create Archive Name
run: echo "MATERIALX_ARCHIVE=MaterialX-${RELEASE_TAG//v}" >> $GITHUB_ENV

- name: Install Python

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious if it's possible to call into a shared setup from main and release ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have a config that is no Python based, so I kept it separate.

uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6
with:
python-version: 3.11

- name: Install naga
run: cargo install naga-cli --locked --version ${NAGA_VERSION}

- name: Generate WGSL library
run: |
python -m pip install -r source/MaterialXGenWgsl/tools/requirements-transpile.txt
python source/MaterialXGenWgsl/tools/mxgenwgsl.py --libraries libraries --out libraries

- name: Generate Archives
run: |
git archive --prefix ${MATERIALX_ARCHIVE}/ --output ${MATERIALX_ARCHIVE}.zip ${RELEASE_TAG}
Expand Down
15 changes: 13 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ option(MATERIALX_BUILD_GEN_OSL "Build the OSL shader generator back-ends." ON)
option(MATERIALX_BUILD_GEN_MDL "Build the MDL shader generator back-end." ON)
option(MATERIALX_BUILD_GEN_MSL "Build the MSL shader generator back-end." ON)
option(MATERIALX_BUILD_GEN_SLANG "Build the Slang shader generator back-end." ON)
option(MATERIALX_BUILD_GEN_WGSL "Build the WGSL (WebGPU) shader generator back-end." OFF)
option(MATERIALX_GENERATE_WGSL_LIBRARY "Regenerate the genwgsl shader-node library from genglsl at build time (requires Python and naga); surfaces transpile/validation failures as build errors." OFF)
option(MATERIALX_BUILD_RENDER "Build the MaterialX Render modules." ON)
option(MATERIALX_BUILD_RENDER_PLATFORMS "Build platform-specific render modules for each shader generator." ON)
option(MATERIALX_BUILD_OIIO "Build OpenImageIO support for MaterialXRender." OFF)
Expand Down Expand Up @@ -126,6 +128,8 @@ set(MATERIALX_PYTHON_EXECUTABLE "" CACHE FILEPATH
"Python executable to be used in building the MaterialX Python package (e.g. 'C:/Python39/python.exe').")
set(MATERIALX_PYTHON_PYBIND11_DIR "" CACHE PATH
"Path to a folder containing the PyBind11 source to be used in building MaterialX Python.")
set(MATERIALX_CARGO_PATH "" CACHE PATH
"Path to a Rust cargo installation (the CARGO_HOME directory containing bin/cargo, e.g. '~/.cargo'); used to obtain the naga CLI when MATERIALX_GENERATE_WGSL_LIBRARY is on and naga is not already found.")
option(MATERIALX_PYTHON_FORCE_REPLACE_DOCS "Force replace existing docstrings when generating Python binding documentation from Doxygen." OFF)

# Settings to define installation layout
Expand Down Expand Up @@ -176,6 +180,9 @@ set(MATERIALX_LIBNAME_SUFFIX "" CACHE STRING "Specify a suffix to all libraries
mark_as_advanced(MATERIALX_BUILD_DOCS)
mark_as_advanced(MATERIALX_BUILD_GEN_GLSL)
mark_as_advanced(MATERIALX_BUILD_GEN_SLANG)
mark_as_advanced(MATERIALX_BUILD_GEN_WGSL)
mark_as_advanced(MATERIALX_GENERATE_WGSL_LIBRARY)
mark_as_advanced(MATERIALX_CARGO_PATH)
mark_as_advanced(MATERIALX_BUILD_GEN_OSL)
mark_as_advanced(MATERIALX_BUILD_GEN_MDL)
mark_as_advanced(MATERIALX_BUILD_GEN_MSL)
Expand Down Expand Up @@ -527,8 +534,8 @@ endif()

# Add shader generation subdirectories
add_subdirectory(source/MaterialXGenShader)
if(MATERIALX_BUILD_GEN_GLSL OR MATERIALX_BUILD_GEN_OSL OR MATERIALX_BUILD_GEN_MDL OR MATERIALX_BUILD_GEN_MSL OR MATERIALX_BUILD_GEN_SLANG)
if(MATERIALX_BUILD_GEN_GLSL OR MATERIALX_BUILD_GEN_MSL OR MATERIALX_BUILD_GEN_SLANG)
if(MATERIALX_BUILD_GEN_GLSL OR MATERIALX_BUILD_GEN_OSL OR MATERIALX_BUILD_GEN_MDL OR MATERIALX_BUILD_GEN_MSL OR MATERIALX_BUILD_GEN_SLANG OR MATERIALX_BUILD_GEN_WGSL)
if(MATERIALX_BUILD_GEN_GLSL OR MATERIALX_BUILD_GEN_MSL OR MATERIALX_BUILD_GEN_SLANG OR MATERIALX_BUILD_GEN_WGSL)
add_subdirectory(source/MaterialXGenHw)
endif()
if (MATERIALX_BUILD_GEN_GLSL)
Expand All @@ -539,6 +546,10 @@ if(MATERIALX_BUILD_GEN_GLSL OR MATERIALX_BUILD_GEN_OSL OR MATERIALX_BUILD_GEN_MD
add_definitions(-DMATERIALX_BUILD_GEN_SLANG)
add_subdirectory(source/MaterialXGenSlang)
endif()
if (MATERIALX_BUILD_GEN_WGSL)
add_definitions(-DMATERIALX_BUILD_GEN_WGSL)
add_subdirectory(source/MaterialXGenWgsl)
endif()
if (MATERIALX_BUILD_GEN_OSL)
add_definitions(-DMATERIALX_BUILD_GEN_OSL)
add_subdirectory(source/MaterialXGenOsl)
Expand Down
Loading
Loading