251 Commits

Author SHA1 Message Date
Syoyo Fujita
896303432e fix MSVC warnings and Win32 build
- CMakeLists.txt: Skip libatomic linking on MSVC (atomics built into runtime)
- crate-reader.cc: Use std::transform with explicit cast to fix C4244 warning
- pprinter.cc: Remove duplicate to_string(DomeLight::TextureFormat) to fix LNK4006

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-08 04:47:00 +09:00
Syoyo Fujita
3c1b1735b7 raise C++ version requirement from C++14 to C++17
Update all CMakeLists.txt, Makefiles, meson.build, setup.py,
and documentation files to use C++17 standard.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-08 03:39:41 +09:00
Syoyo Fujita
7ac01267d4 Add TinyEXR v3 API with backward compatible v1 fallback
- Copy TinyEXR v3 source files from upstream tinyexr repository
- Add new CMake option TINYUSDZ_USE_TINYEXR_V3 (default ON)
- V3 provides modern C17/C++17 API with Vulkan-style interface
- V1 API functions remain available for backward compatibility
- Backup original v1 header as tinyexr_v1.h

New files:
- tinyexr_c.h, tinyexr_c_impl.c: Pure C API
- tinyexr_v3.hh: C++17 RAII wrapper
- tinyexr_v2.hh, tinyexr_v2_impl.hh: V2 implementation
- tinyexr_huffman.hh, tinyexr_piz.hh: Compression codecs
- tinyexr_simd*.{hh,h,cc}: SIMD optimizations
- exr_reader.hh, streamreader.hh, streamwriter.hh: Utilities

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-02 08:38:01 +09:00
Syoyo Fujita
39fbeca468 Add --inspect option to tusdcat for USD Layer/Stage inspection
Adds a new inspection feature similar to pxrUSD's sdfdump, providing
YAML-like tree output of USD Layer structure. New files:
- src/usd-dump.hh/cc: InspectLayer/InspectStage implementation
- GlobMatch/GlobMatchPath functions in str-util for pattern matching

New CLI options:
- --inspect: YAML-like Layer inspection output
- --inspect-json: JSON output (placeholder, not yet implemented)
- --value=MODE: Value printing mode (none/snip/full)
- --snip=N: Number of items to show in snip mode
- --path=PATTERN: Filter prims by path glob pattern (supports **)
- --attr=PATTERN: Filter attributes by name glob pattern
- --time=T or --time=S:E: TimeSamples time query

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-06 06:35:17 +09:00
Syoyo Fujita
f2885be974 Add ColorSpace API support for OpenUSD color management
Implements ColorSpace API infrastructure following OpenUSD color management specification:
- Define ColorSpace tokens and enums (18 canonical color spaces: linear, sRGB, gamma 2.2/1.8)
- Add ColorSpaceAPI schema with colorSpace:name attribute
- Utility functions: to_token(), from_token(), is_linear(), is_data()
- Default color space: Linear Rec.709 (lin_rec709_scene)

MaterialX JSON integration:
- Add colorspace metadata to MaterialX input serialization
- Omit colorspace field when value is default (lin_rec709_scene) for clean JSON output
- Access colorspace via MtlxElement::GetColorSpace() from extra_attributes

References:
- https://openusd.org/dev/user_guides/color_user_guide.html

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-29 03:46:04 +09:00
Syoyo Fujita
da8329e573 Add raytracing infrastructure to Tydra with quad and analytic primitive support
Implements raytracing-optimized data structures and converter for Tydra:

- RTGeometry with multiple geometry types:
  * Triangle/Quad/Mixed meshes (ray-quad intersection, no tessellation)
  * Analytic primitives (Sphere, Cylinder, Capsule, Cone) with native ray intersection
- RaytracingScene container with validation and BVH support
- RaytracingSceneConverter framework (placeholder implementations)
- Primvars fetched at intersection time (no variability preprocessing)

Configuration options:
- allow_quads: Use ray-quad intersection to save tessellation cost
- convert_primitives_to_analytic: Direct ray intersection for geometric shapes

Test assets:
- ColorChecker Classic 24-patch in sRGB, linear sRGB, ACEScg, and spectral
- Chrome ball reference geometry with MaterialX metal shader

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-28 03:51:49 +09:00
Syoyo Fujita
5a1bbe4987 Add MaterialX NodeGraph to JSON converter for node-based shading reconstruction
Implements MaterialX node graph serialization to JSON format for easy
reconstruction of node-based shaders in JavaScript/WebAssembly (Three.js, etc.)

New Features:
- nodeGraphJson member added to OpenPBRSurfaceShader class in render-data.hh
- Stores complete MaterialX node graph as JSON string
- Schema follows MaterialX XML structure for compatibility
- Empty string when no node graph exists (direct parameter values only)

New Files:
- src/tydra/materialx-to-json.hh - Header with converter API
- src/tydra/materialx-to-json.cc - Implementation

JSON Schema Design:
{
  "version": "1.38",  // MaterialX version
  "nodegraph": {
    "name": "NG_shader1",
    "nodes": [          // Array of nodes (image, multiply, mix, etc.)
      {
        "name": "image1",
        "category": "image",
        "type": "color3",
        "inputs": [...],
        "outputs": [...]
      }
    ],
    "outputs": [...]    // NodeGraph outputs
  },
  "connections": [      // Shader input connections
    {
      "input": "base_color",
      "nodegraph": "NG_shader1",
      "output": "base_color_output"
    }
  ]
}

Converter Functions:
- ConvertNodeGraphToJson() - Convert USD NodeGraph Prim to JSON
- ConvertShaderWithNodeGraphToJson() - Convert shader + nodegraphs
- ConvertMtlxNodeGraphToJson() - Convert MaterialX DOM NodeGraph
- Helper functions for JSON escaping and type conversion

Integration:
- ConvertOpenPBRSurfaceShader() now populates nodeGraphJson field
- Automatically detects and converts MaterialX node graph connections
- Works with both OpenPBRSurface and MtlxOpenPBRSurface
- Non-blocking: empty nodeGraphJson if no node graphs found

Benefits:
- Enables node-based shader reconstruction in Three.js
- Preserves complex MaterialX shading networks
- Easy to parse in JavaScript (native JSON support)
- Compatible with MaterialX XML schema
- No runtime overhead (conversion happens during USD load)

Use Cases:
- Three.js MaterialX node-based material system
- WASM shader graph visualization
- Material editor UIs
- Blender v4.5+ MaterialX export compatibility

CMake Integration:
- Added materialx-to-json.{cc,hh} to CMakeLists.txt build list

Implementation Details:
- Handles input connections (nodename + output references)
- Supports direct input values (float, color3, string, etc.)
- Proper JSON escaping for special characters
- Type-safe value conversion from USD attributes
- Works with MaterialXConfigAPI materials

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-21 21:05:21 +09:00
Syoyo Fujita
88a6b424c6 Add material serializer and enhance MaterialX web demo with Three.js integration
- Add Tydra material serializer for WASM/JS bindings (JSON/XML export)
- Enhance MaterialX web demo with Three.js module imports and improved material handling
- Add support for normal visualization, bounding boxes, and up-axis conversion in demo
- Update CMakeLists to include new material serializer in Tydra build
- Minor updates to shape-to-mesh header and web bindings

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-05 11:29:08 +09:00
Syoyo Fujita
99e05822cc Merge branch 'release' into mtlx-2025 with compilation fixes
Resolved merge conflicts and fixed compilation errors introduced by animation system refactoring and API changes:
- Updated AnimationClip API usage in threejs-exporter (channels/samplers)
- Fixed PropertyMap const-correctness in MaterialX shader reconstructors
- Fixed 32-bit build warnings (sign conversion, variable shadowing)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-04 21:55:27 +09:00
Syoyo Fujita
fef740e343 fix compile. 2025-11-02 12:23:30 +09:00
Syoyo Fujita
310d017a7e Add advanced bone reduction with modular bone-util library
Implements sophisticated bone influence reduction algorithms in a standalone
module (bone-util.hh/cc) for better code organization and reusability.

Features:
- Multiple reduction strategies:
  * Greedy: Simple top-N weight selection (baseline)
  * ErrorMetric: Minimize deformation error using weight-based metrics
  * Hierarchical: Preserve bone chain relationships (when hierarchy available)
  * Adaptive: Auto-select best strategy per vertex based on weight distribution

- Configurable parameters:
  * target_bone_count (default: 4 for Three.js/WebGL compatibility)
  * min_weight_threshold for early filtering
  * error_tolerance for quality/performance tradeoff
  * Strategy selection per use case

- Quality metrics:
  * Weight normalization to preserve total influence
  * L2 error tracking for validation
  * Statistics output (avg/max error, vertices modified)

- Bone hierarchy utilities:
  * Calculate bone depths in skeleton hierarchy
  * Find chain distance between bones
  * Support for hierarchical-aware reduction

MeshConverterConfig additions:
- enable_bone_reduction: Toggle feature on/off
- target_bone_count: Configure max influences per vertex

The ErrorMetric strategy is used by default, providing good balance between
quality and GPU efficiency. Falls back gracefully when no hierarchy info available.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-01 02:31:03 +09:00
Syoyo Fujita
53a21e0331 Add matrix decomposition support for Transform xformOp animations
Implement TRS decomposition to enable animated matrix transforms in Tydra
render-scene conversion. Transform xformOps with time samples are now
decomposed into separate Translation/Rotation/Scale animation channels
compatible with glTF and Three.js.

Changes:
- Add decompose() function to xform.cc using Shepperd's method for stable
  quaternion extraction from rotation matrices
- Extend ExtractXformOpAnimation() to handle Transform xformOps by
  decomposing each matrix time sample into TRS components
- Fix TimeSamples API usage: change ts.get_as<T>() to sample_value.as<T>()
  for correct access pattern with FOREACH_TIMESAMPLES_BEGIN macro
- Fix atomic library linking in CMakeLists.txt for Emscripten builds
- Fix AnimationChannel validation method call (valid -> is_valid)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-27 23:34:51 +09:00
Syoyo Fujita
d637cc5a3f Fix 32-bit build: Add explicit casts and libatomic linkage
- Add static_cast for uint64_t to size_t conversions in timesamples-pprint.cc
- Add static_cast for atomic queue size calculations in task-queue.hh
- Link libatomic on 32-bit systems for 64-bit atomic operations

Fixes implicit conversion errors with -Wshorten-64-to-32 and undefined
reference to __atomic_load/__atomic_compare_exchange on i386.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-26 09:42:45 +09:00
Syoyo Fujita
90608d364c Add parallel prim/primspec printing using task queue
Implemented parallel printing for Prim and PrimSpec to speed up
Stage::ExportToString() and Layer print_layer() functions using
the lock-free task queue.

Features:
- Parallel printing controlled by optional `parallel` parameter
- Only enabled when TINYUSDZ_ENABLE_THREAD is defined
- Auto-detects number of CPU cores (std::thread::hardware_concurrency())
- Configurable minimum prims threshold (default: 4 prims)
- Falls back to sequential printing when not beneficial
- Preserves original ordering of output

Changes:
- Added src/prim-pprint-parallel.hh: Parallel printing interface
- Added src/prim-pprint-parallel.cc: Task queue-based implementation
- Modified Stage::ExportToString(): Added parallel parameter
- Modified print_layer(): Added parallel parameter
- Updated CMakeLists.txt: Added new parallel printing files
- Added sandbox/parallel-print-benchmark.cc: Benchmark tool

Implementation:
- Uses TaskQueue for lock-free work distribution
- Worker threads consume tasks from queue
- Each Prim/PrimSpec printed to separate buffer
- Results concatenated in original order

Testing:
- Sequential printing: 9873ms (258MB output)
- Parallel printing: 10345ms (258MB output)
- ✓ Outputs match exactly
- ✓ All unit tests pass

Note: For files with few root prims, parallel overhead may exceed
benefits. The min_prims_for_parallel threshold prevents this.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-23 05:02:06 +09:00
Syoyo Fujita
4dbb0ca2d8 Integrate lock-free task queue into TinyUSDZ core
Integrated the task queue implementation from sandbox into the main
TinyUSDZ source tree with proper naming conventions and testing.

Changes:
- Added src/task-queue.hh: Lock-free MPMC task queue implementation
- Added src/task-queue.cc: Placeholder for header-only implementation
- Added tests/unit/unit-task-queue.cc: Comprehensive unit tests
- Added tests/unit/unit-task-queue.h: Unit test declarations
- Updated CMakeLists.txt: Added task-queue source files
- Updated tests/unit/CMakeLists.txt: Added task-queue unit test
- Updated tests/unit/unit-main.cc: Registered 5 task queue tests

Features:
- Lock-free CAS-based implementation using __atomic builtins (GCC/Clang)
- Automatic fallback to std::mutex + std::atomic for other compilers
- Two variants: TaskQueue (C function pointers) and TaskQueueFunc (std::function)
- No C++ exceptions or RTTI required
- Thread-safe MPMC (multiple producer, multiple consumer)
- Fixed-size ring buffer with monotonic 64-bit counters
- Follows TinyUSDZ naming conventions (_member_vars)

Test Results:
 task_queue_basic_test - Basic push/pop operations
 task_queue_func_test - std::function lambda support
 task_queue_full_test - Queue capacity handling
 task_queue_multithreaded_test - 2P+2C, 1000 tasks
 task_queue_clear_test - Clear operation
 All existing unit tests still pass

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-23 03:22:30 +09:00
Syoyo Fujita
f5e57a4daa add xml output option to MaterialX setting.
Update MaterialX setup for Three.js
2025-10-13 23:32:54 +09:00
Syoyo Fujita
77ea9c4d23 Split crate-reader.cc to improve compilation time
Extract TimeSamples functionality (~2,400 lines) into separate
crate-reader-timesamples.cc file. Add crate-reader-common.inc for
shared macro definitions. Add explicit template instantiations for
types used across translation units.

This reduces crate-reader.cc compilation time from 56.5s to 24.4s
(-57%) and overall build time from 1620s to 956s (-41%).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-08 04:23:55 +09:00
Syoyo Fujita
1058f7e53c Optimize TimeSamples parsing and storage with POD types
- Add templated ParseTypedTimeSamples for efficient POD type parsing in ASCII parser
- Implement PODTimeSamples with array support and offset table for memory efficiency
- Add backward compatibility through get_samples_converted() method
- Optimize blocked/None values to avoid memory allocation (using SIZE_MAX marker)
- Fix pprint functions to handle new offset-based storage correctly
- Add comprehensive unit tests for sorting, blocked values, and arrays
- Fix get_sample_at() bug that always returned false

The optimizations provide significant memory savings by:
- Avoiding value::Value wrapping overhead for POD types
- Not allocating memory for blocked/None samples
- Using offset tables for efficient sorting without moving large data blocks
- Supporting both scalar and array POD types efficiently

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-03 03:02:42 +09:00
Syoyo Fujita
aeb702dc19 Use PODTimeTimesamples in crate-reader.
Add timesamples-pprint
2025-10-02 11:45:36 +09:00
Syoyo Fujita
19f88d4ed4 Add Remotery profiling library support
- Add Remotery v1.2.1 to src/external/Remotery
- Add CMake option TINYUSDZ_WITH_REMOTERY (defaults to OFF)
- Configure build to include Remotery when enabled
- Set appropriate platform flags for Windows/macOS/Linux

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-23 20:46:20 +09:00
Syoyo Fujita
f9e316ca74 Working BuildIndicesFast. 2025-09-20 12:57:05 +09:00
Syoyo Fujita
cdde6d2239 meshoptimzier experiment. 2025-09-10 04:14:30 +09:00
Syoyo Fujita
90e1855b04 Merge branch 'js_mem_reduction' into async 2025-09-04 06:40:00 +09:00
Syoyo Fujita
3d5b8307aa fix non with_json build. 2025-09-02 23:31:12 +09:00
Syoyo Fujita
88ca3a08e9 refactor. create layer.cc 2025-09-02 10:04:35 +09:00
Syoyo Fujita
a3483f08a1 Merge branch 'progress-callback' into js_mem_reduction 2025-09-02 01:56:47 +09:00
Syoyo Fujita
0ec0449dde fix compile. 2025-09-01 09:54:39 +09:00
Syoyo Fujita
701d99240a Add Layer-to-RenderScene. 2025-09-01 08:22:47 +09:00
Syoyo Fujita
731e458ae1 typedarrayview. 2025-08-31 04:04:27 +09:00
Syoyo Fujita
15e54cf15b Add TINYUSDZ_WITH_COROUTINE CMake option and nonstd::generator implementation
- Add TINYUSDZ_WITH_COROUTINE option to enable C++20 coroutine support
- When enabled, sets C++20 standard and defines TINYUSDZ_WITH_COROUTINE preprocessor flag
- Add src/nonstd/generator.hh: C++20 implementation of C++23's std::generator
  - Header-only implementation compatible with C++23 standard
  - Supports range-based for loops and iterator interface
  - Proper exception handling and move semantics
  - Automatic coroutine support detection with fallback
  - Includes type traits for template metaprogramming

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-31 03:10:15 +09:00
Syoyo Fujita
ace24c2149 improve chunk-reader 2025-08-30 23:00:48 +09:00
Syoyo Fujita
14ec29a86a fix compile. 2025-08-23 08:52:42 +09:00
Syoyo Fujita
f85b4664d3 Implement USD Layer diff functionality and usddiff command-line tool
## Features Added

### Core diff-and-compare implementation:
- Complete rewrite of src/tydra/diff-and-compare.cc with full diff algorithm
- Hierarchical PrimSpec comparison (added/deleted/modified primitives)
- Property comparison for attributes and relationships
- Recursive traversal with depth limits for security
- Memory-safe implementation using standard containers

### Text and JSON output formats:
- DiffToText(): Unix diff-style output with +/- symbols
- DiffToJSON(): Structured JSON format for programmatic use
- Proper JSON escaping and formatting
- Sorted output for consistent results

### usddiff command-line tool:
- Full-featured CLI application in examples/usddiff/
- Support for --json and --help options
- USD file loading with error handling
- Support for all USD formats (.usd, .usda, .usdc, .usdz)
- Comprehensive documentation and usage examples

## Implementation Details

- Path-based diff organization using USD scene graph paths
- Efficient O(n log n) sorting for consistent output
- Configurable depth limits (default: 1M levels) for security
- Proper error handling and input validation
- CMake integration with TinyUSDZ build system

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-21 03:21:43 +09:00
Syoyo Fujita
944e7e46ae add some JS script executing feature. 2025-08-19 03:23:51 +09:00
Syoyo Fujita
70d4ffd183 Add WAMR (WebAssembly Micro Runtime) support to TinyUSDZ Tydra framework
This commit integrates WAMR into TinyUSDZ to enable WebAssembly execution
capabilities within the Tydra framework for advanced USD processing.

Changes:
- Add TINYUSDZ_WITH_WAMR CMake option to enable/disable WAMR support
- Copy WAMR core runtime to src/external/wamr/ with all necessary files
- Create WasmRuntime class in src/tydra/wasm-runtime.{hh,cc} with:
  * loadAndExecuteWasm() for executing WASM binaries from memory
  * loadAndExecuteWasmFromFile() for loading WASM files from filesystem
  * Proper error handling and resource cleanup
  * Platform-specific configuration support
- Configure CMake build system to:
  * Include WAMR core sources when TINYUSDZ_WITH_WAMR=ON
  * Set up platform-specific include directories (Linux/Windows)
  * Add proper compile definitions for WAMR integration
  * Link WAMR sources with TinyUSDZ static library

The integration provides a foundation for executing WebAssembly modules
within USD processing workflows, enabling custom processing logic to be
implemented in WASM and executed efficiently within the Tydra framework.

Usage: cmake -DTINYUSDZ_WITH_WAMR=ON -DTINYUSDZ_WITH_TYDRA=ON ..

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-18 08:09:42 +09:00
Syoyo Fujita
4e345a578a Merge branch 'mcp' of github.com:syoyo/tinyusdz into mcp 2025-08-18 01:29:16 +09:00
Syoyo Fujita
e5359305c2 add quickjs-ng 2025-08-17 09:01:15 +09:00
Syoyo Fujita
4d15618eda Merge branch 'dev' into usd-json 2025-08-15 01:41:24 +09:00
Syoyo Fujita
2677160b12 add profiler framework. 2025-08-13 09:41:00 +09:00
Syoyo Fujita
2a49cfc7db Merge branch 'release' into fast-string 2025-07-25 04:11:52 +09:00
Syoyo Fujita
1dd9c88e20 mcp w.i.p. 2025-07-14 12:00:25 +09:00
Syoyo Fujita
651e9d5b03 mcp w.i.p. 2025-07-12 11:51:18 +09:00
Syoyo Fujita
792d1e3751 [tydra] Add Layer/PrimSpec version of EvalAttribute()
Implement some MCP code(w.i.p)
2025-07-12 08:43:56 +09:00
Syoyo Fujita
5d4610b447 add diff-and-compare 2025-07-08 05:42:29 +09:00
Syoyo Fujita
89e4dce269 json w.i.p 2025-07-07 07:41:22 +09:00
Syoyo Fujita
a8553dc4c1 add libsais for suffix array 2025-07-03 10:13:36 +09:00
Syoyo Fujita
c99b12fd97 add arg-parser 2025-07-03 04:10:26 +09:00
Syoyo Fujita
0747e87a61 add civetweb for http server.
mcp w.i.p.
2025-07-02 09:55:17 +09:00
Syoyo Fujita
c807b78a52 add mcp placeholder. 2025-07-01 05:23:01 +09:00
Syoyo Fujita
346fd3302a add JsonWriter(w.i.p.) 2025-06-30 08:22:17 +09:00