Skip to content

Conversation

@kohakukun
Copy link

Description of Change(s)

Link to proposal (if applicable)

Fixes Issue(s)

Checklist

scotbrew added 30 commits April 4, 2025 10:45
copy pxr/usdImaging/bin/usdviewweb/ to pxr/extras/usd/web so can iterate and enhance a version that is javascript friendly without impacting the original.
Simplifying CMakeLists.txt and renaming files, tailoring to usdweb
…hardcode model.

Expose USD viewport functions to javascript
* init viewport
* set stage
* fit camera
* remove Knife.usda, instead use generated usd stage as default
* WrapJs for VariantSet and VariantSets
* Wrap additional functions in UsdPrim for variants.
* Update usdweb.html with sample use.
* Add action buttons:
    * hide/show prims
    * material variants
    * fitCamera
* single-action load CFB variants stage file (dependent file loads)
Switch from Camera to FreeCameraGL
FreeCameraGL is a C++ class ported from the python Usdview FreeCamera in freeCamera.py.
The behavior for camera manip is much improved and now better aligns with the camera manipulation in usdview.

TODO: remove camera.h and camera.cpp
wrap UsdGeomCamera, mostly just stubbed out.
* Support Z-Up for camera stages
* Move around functions (setupDefaults,  getStageBBox, fit_camera)
* encapsulate param setup when loading new stage with initParamsForWebStage()
scotbrew added 27 commits May 31, 2025 22:25
* Add contrib.glfw3 CMake option: EMSCRIPTEN_USE_CONTRIB_GLFW3
* Clean up headers in usdweb
* Add logging notes for debugging

NOTE: contrib.glfw3 still has errors, so more work needed.
* Add code comments
* WIP for EMSCRIPTEN_USE_CONTRIB_GLFW3
* Remove unneeded fit_camera() since already initialized elsewhere.
A fix was added to the experimental MaterialX 1.39.x branch that addresses the issue preventing more advanced MaterialX shaders like procedural brick from being displayed properly.

README.md docs updated to reflect this fix.
The WGSL pull request landed in the main branch of MaterialX today and slated for the full 1.39.4 release.  Update the README.md and build_usd.py to use the main branch as of that pull request.
Streamline the code and remove the need for additional tokenSubstitutions from MaterialX.
@kohakukun kohakukun requested a review from Copilot July 11, 2025 08:57
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Adds WebGPU and MaterialX support across USD's JavaScript bindings, shader generation, and a new browser-based USD Web Viewer.

  • Introduces new Emscripten wrappers for UsdUtils and various USD, UsdShade, and UsdGeom APIs
  • Extends HdSt MaterialX shader generator with a new templated base, WGSL support, and version‐based branching
  • Adds a complete WebGPU‐based web application (usdweb.html + usdweb.cpp) with UI, camera controls, and asset loading

Reviewed Changes

Copilot reviewed 59 out of 68 changed files in this pull request and generated 1 comment.

File Description
pxr/usd/usdUtils/wrapDependenciesJs.cpp New Emscripten wrapper for UsdUtilsExtractExternalReferences
pxr/imaging/hdSt/materialXShaderGen.h / materialXShaderGen.cpp Refactored MaterialX shader generator with WGSL support
extras/usd/web/usdweb.html / usdweb.cpp New WebGPU viewer HTML and Emscripten C++ entry points
Comments suppressed due to low confidence (4)

extras/usd/web/freeCameraGL.h:6

  • [nitpick] Duplicate inclusion of <pxr/base/gf/matrix4d.h>. You can remove one of the two identical includes to reduce redundancy.
// compliance with the Apache License and the following modification to it:

pxr/usd/usdUtils/wrapDependenciesJs.cpp:32

  • Consider adding unit tests for wrap_UsdUtilsExtractExternalReferences to verify the combined list of external references is returned correctly for various USD files.
std::vector<std::string> wrap_UsdUtilsExtractExternalReferences(const std::string &filePath)

extras/usd/web/usdweb.html:26

  • The CSS property translate is not valid. Use transform: translate(-50px, -50px); instead to correctly center the spinner.
        translate: -50px -50px;

extras/usd/web/usdweb.html:11

  • The CSS padding property does not accept none. Use padding: 0; for no padding.
        padding: none;

Comment on lines +36 to +38
//#define WGSL_MATERIALX_138_SHADERCODE_HACK
#ifdef WGSL_MATERIALX_138_SHADERCODE_HACK
#include <regex> // HACK [sbrew] for LightData.type -> LightData.lightType
Copy link

Copilot AI Jul 11, 2025

Choose a reason for hiding this comment

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

[nitpick] This large hack block guarded by WGSL_MATERIALX_138_SHADERCODE_HACK is difficult to maintain. Consider controlling it via a MaterialX version check or feature flag and document its intended removal.

Suggested change
//#define WGSL_MATERIALX_138_SHADERCODE_HACK
#ifdef WGSL_MATERIALX_138_SHADERCODE_HACK
#include <regex> // HACK [sbrew] for LightData.type -> LightData.lightType
// Feature flag to enable the MaterialX 1.3.8 shader code workaround.
#define ENABLE_MATERIALX_138_WORKAROUND 1
#if ENABLE_MATERIALX_138_WORKAROUND
#include <regex> // Workaround for LightData.type -> LightData.lightType in MaterialX 1.3.8
// TODO: Remove this workaround once MaterialX 1.3.9 or later is adopted.

Copilot uses AI. Check for mistakes.
Adding documentation for useful functions in usdweb.html.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants