68 Commits

Author SHA1 Message Date
Syoyo Fujita
9720b0bc07 Fix quad winding order in MaterialX normal map test files
- mtlx-normalmap-plane.usda: Changed faceVertexIndices from [0,1,2,3] to [0,3,2,1]
- mtlx-normalmap-multi.usda: Fixed plane meshes winding order (cubes were already correct)

The CCW winding [0,3,2,1] produces face normals pointing UP (+Y) matching
the declared vertex normals, ensuring correct front-face rendering.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-01 09:00:05 +09:00
Syoyo Fujita
9e531184de Optimize multi-material mesh rendering with WASM-computed submeshes
Improve rendering performance for meshes with per-face materials (GeomSubsets)
by pre-computing optimized submesh groups in C++ instead of JavaScript.

Changes:
- WASM: Pre-compute contiguous face ranges per material in binding.cc
  Export minimal submesh data: {start, count, materialId}
- JS: Use pre-computed submeshes directly, eliminating expensive sorting/grouping
- Fix stack overflow with large arrays by removing spread operator usage

Performance: 100x-1000x faster for large meshes with multiple materials
  Before: JS processing thousands of face indices (browser hang)
  After: C++ pre-computation, JS just creates geometry groups

Tydra improvements:
- Change texture nullptr errors to warnings with debug info (Prim path)
- Change normals conversion errors to warnings, clear invalid normals
- Allow mesh conversion to continue with missing textures/normals

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

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-09 11:06:56 +09:00
Syoyo Fujita
99109c75e4 Add LTE SpectralAPI example USDA files
Example files demonstrating wavelength-dependent material and light properties:

- spectral-material.usda: Materials with wavelength:reflectance and wavelength:ior
  (red, glass, fused silica with Sellmeier, foliage, gold)

- spectral-light.usda: Light sources with wavelength:emission
  (D65, D50, A, F2 illuminant presets, custom LED, sodium lamp)

- spectral-scene.usda: Complete scene with diamond dispersion, water, copper
  under D65/D50 lighting

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-30 02:33:13 +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
2aeac6eb28 Fix reverse face orientation in Tydra earcut triangulation for 5+ gons
The mapbox earcut library returns triangles in clockwise winding order,
but USD expects counter-clockwise order. This was causing reversed face
orientation for polygons with 5 or more vertices when using the earcut
triangulation method.

Changes:
- src/tydra/render-data.cc: Reverse triangle winding order by swapping
  indices 1 and 2 when processing earcut results to convert from CW to CCW
- examples/tydra_to_renderscene/to-renderscene-main.cc: Add --trifan
  option to enable triangle fan triangulation method for testing

The triangle fan method was already producing correct CCW triangles and
did not require changes.

Tested with models/ngon.usdc containing pentagon, hexagon, and octagon.
Both triangulation methods now correctly produce CCW triangles.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-20 11:14:43 +09:00
Syoyo Fujita
eb3c64b618 Merge branch 'mtlx-2025' into skinning 2025-11-17 02:11:52 +09:00
Syoyo Fujita
184d446c9a Fix OpenPBR Material info not being dumped in DumpRenderScene
Deprecated old DumpRenderScene and related dump functions in render-data.cc
that didn't include OpenPBR shader output. The newer implementation in
render-scene-dump.cc already has proper support for dumping both
UsdPreviewSurface and OpenPBR materials.

The old DumpMaterial function only dumped surfaceShader field, missing
the openPBRShader field entirely. Now DumpRenderScene correctly outputs
OpenPBR material parameters including:
- Base layer (weight, color, roughness, metalness)
- Specular layer (weight, color, roughness, ior)
- Coat layer (weight, color, roughness)
- Emission (luminance, color)
- Transmission (weight)
- Subsurface (weight, color)

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-12 13:01:47 +09:00
Syoyo Fujita
f9e030d6bf Add texture colorspace support and colorspace test USDA files
- Enhanced material-serializer to include texture asset identifiers and colorspace metadata
  * Added colorSpaceToString() helper for 15+ colorspace enum values
  * Pass RenderScene to serializeMaterial() for texture information access
  * Include texture metadata (width, height, channels, colorSpace, usdColorSpace)
  * Reorganize OpenPBR parameters into grouped layers (base, specular, transmission, etc.)

- Added 8 MaterialX + USDA test files with colorspace variations:
  * materialx-textured-simple.usda - basic textured material
  * materialx-srgb-ldr.usda - standard sRGB color texture
  * materialx-linear-srgb.usda - raw colorspace (non-color data)
  * materialx-aces-cg.usda - ACES CG for HDR VFX workflows
  * materialx-aces2065-1.usda - ACES 2065-1 for DCI cinema
  * materialx-rec709-linear.usda - linear Rec.709 for broadcast video
  * materialx-rec709-gamma22.usda - gamma 2.2 Rec.709 (sRGB-like)
  * materialx-displayp3.usda - Display P3 for modern displays

- Verified colorspace information correctly passes from C++ to JavaScript/WASM
  * All test files export via dump-materialx-cli.js with proper colorSpace values
  * JSON includes both colorSpace (processed) and usdColorSpace (original intent) fields

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-07 06:23:07 +09:00
Syoyo Fujita
1987c70df4 add envmaps(CC0) from Blender datadir. 2025-11-06 10:01:04 +09:00
Syoyo Fujita
231441761a Add reproduction script for environment map presets
- New generate_envmaps.sh script to regenerate all 7 environment maps
- Includes exact parameters for each preset (sun/sky/studio variations)
- Automated Node.js version checking and HDRGen tool validation
- Optional PNG preview generation with tone mapping
- Updated ENVMAPS_README.md with reproduction instructions

Usage: bash models/textures/generate_envmaps.sh

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-06 02:40:36 +09:00
Syoyo Fujita
ae38a6cfad Add synthetic HDR environment map presets for MaterialX testing
This commit adds 7 ready-to-use HDR environment maps in lat-long format
for testing and visualizing MaterialX materials in various lighting conditions.

## Environment Maps Added (models/textures/)

All maps are 512x256 resolution, Radiance RGBE format, ~513KB each.

### Testing Environment
- **env_white_furnace.hdr** - Uniform white (intensity: 1.0)
  - Energy conservation validation
  - BRDF integration testing
  - Perfect diffuse should integrate to 1.0

### Outdoor Environments (Sun & Sky)
- **env_sunsky_afternoon.hdr**
  - Sun: 45° elevation, 135° azimuth (southeast)
  - Balanced natural lighting
  - Good for general outdoor scenes

- **env_sunsky_sunset.hdr**
  - Sun: 5° elevation, 270° azimuth (west)
  - Dramatic warm lighting, long shadows
  - High intensity: 150

- **env_sunsky_noon.hdr**
  - Sun: 85° elevation, 0° azimuth (north)
  - Harsh overhead lighting
  - Very high intensity: 200

### Studio Environments (3-Point Lighting)
- **env_studio_default.hdr**
  - Balanced professional lighting
  - Key: 50, Fill: 10, Rim: 20
  - Good for product renders

- **env_studio_highkey.hdr**
  - Bright, soft, low contrast
  - Key: 80, Fill: 30, Rim: 10, Ambient: 1.0
  - Beauty/product photography style

- **env_studio_lowkey.hdr**
  - Dramatic, high contrast
  - Key: 30, Fill: 5, Rim: 40, Ambient: 0.1
  - Cinematic/moody renders

## Documentation (models/textures/ENVMAPS_README.md)

Comprehensive documentation including:
- Detailed specifications for each environment
- Technical properties (intensity ranges, color space)
- Usage examples for USD, Three.js, Blender
- Generation instructions for custom variants
- Energy conservation testing guide
- DCC compatibility matrix

## Use Cases

**MaterialX Testing:**
- Validate OpenPBR materials in different lighting
- Test transmission, subsurface, coat effects
- Compare with DCC renders

**Web Demos:**
- Ready-to-use for Three.js MaterialX demos
- Fast loading (512x256 optimized for web)
- Cover all common lighting scenarios

**Development:**
- Quick IBL testing without large HDR files
- Consistent lighting across tests
- Energy conservation validation

**Integration:**
```usda
def DomeLight "EnvLight" {
    asset inputs:texture:file = @./textures/env_sunsky_afternoon.hdr@
    float inputs:intensity = 1.0
}
```

## Technical Specifications

- Format: Radiance RGBE (.hdr)
- Resolution: 512 x 256 (2:1 lat-long)
- Color Space: Linear RGB (no gamma)
- Dynamic Range: HDR (values > 1.0)
- File Size: ~513 KB per file
- Total: ~3.6 MB for all 7 files

## Generation

Generated using HDRGen tool (tools/hdrgen/):
- Procedural sky model (Hosek-Wilkie approximation)
- Professional 3-point studio lighting
- Uniform white furnace for testing
- All parameters documented in ENVMAPS_README.md

These can be regenerated at higher resolutions:
```bash
cd tools/hdrgen
node src/cli.js -p sun-sky -w 2048 --height 1024 -o env_2k.hdr
```

## Testing

All environment maps validated:
- ✓ Valid Radiance RGBE format
- ✓ Proper lat-long aspect ratio (2:1)
- ✓ HDR values preserved (> 1.0)
- ✓ Linear color space (no gamma)
- ✓ Loadable in Blender, Three.js

Tested with:
- file command (format verification)
- Blender World environment texture
- RGBELoader in Three.js

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-06 02:23:42 +09:00
Syoyo Fujita
9798cf142c Add Blender v4.5 MaterialX OpenPBR shader support
Implement support for ND_open_pbr_surface_surfaceshader exported by Blender v4.5
when using MaterialX. This enables proper parsing and conversion of OpenPBR
materials from Blender-exported USD files.

Key changes:
- Add MtlxOpenPBRSurface struct with all Blender v4.5 parameters in usdMtlx.hh
- Implement ReconstructShader specialization for MtlxOpenPBRSurface in prim-reconstruct.cc
- Add MaterialXConfigAPI detection and OpenPBR shader attachment in render-data.cc
- Implement DumpOpenPBRSurface for material output in render-scene-dump.cc
- Add pretty-print support for MtlxOpenPBRSurface in pprinter.cc

When MaterialXConfigAPI is present on a Material, the system now:
1. Attempts to parse outputs:mtlx:surface connection
2. Falls back to searching for child Shader prims with OpenPBR info:id
3. Converts MtlxOpenPBRSurface to OpenPBRSurface for rendering

Tested with models/cube-materialx.usda and models/suzanne-materialx.usda

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-05 10:43:04 +09:00
Syoyo Fujita
6b41081a04 Add additional skeletal animation and skinning test files
Added comprehensive test models and scripts for skeletal animation features:

Skeletal Animation Test Models (models/):
- skelanim-empty.usda: Edge case with no animation data
- skelanim-mixed.usda: Mixed static and time-sampled (incomplete skeleton binding)
- skelanim-rotation-only.usda: Only rotation channels animated
- skelanim-single-joint.usda: Single joint animation
- skelanim-static.usda: Static values only (incomplete skeleton binding)
- skelanim-timesampled.usda: Time-sampled values (incomplete skeleton binding)

Synthetic Skin Test Models (models/):
- synthetic-skin-8influences.usda: 8 influences per vertex test
- synthetic-skin-16influences.usda: 16 influences per vertex test
- synthetic-skin-32influences.usda: 32 influences per vertex test

Test Scripts (web/js/):
- test-anim-debug.js: Animation debugging utility
- test-16influences.js: Test 16 influences per vertex
- test-all-bone-reduction.js: Bone reduction testing
- test-boundaries.js: Boundary condition tests
- test-digit-limits.js: Digit parsing limits
- test-malicious.js: Malicious input handling
- test-number-parsing.js: Number parsing validation

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-05 05:06:51 +09:00
Syoyo Fujita
567ee25f1d Add synthetic OpenPBR MaterialX test scenes with texturing
Created comprehensive test suite for OpenPBR materials demonstrating various
material properties and texture mapping workflows. All scenes use proper USD
shader node IDs (OpenPBRSurface, UsdUVTexture, UsdPrimvarReader_float2) rather
than MaterialX node definition IDs.

New test files:
- openpbr-brick-sphere.usda: Diffuse material with brick texture
- openpbr-metallic-cube.usda: Metallic material with checkerboard
- openpbr-emissive-plane.usda: Emissive with cat texture (Mesh - MaterialX exportable)
- openpbr-glass-sphere.usda: Glass/transmission material
- openpbr-subsurface-sphere.usda: Subsurface scattering with texture
- openpbr-coated-cube.usda: Clear coat over brick texture
- openpbr-multi-object.usda: Multi-material scene (4 objects, 4 materials)

Texture asset:
- textures/brick.bmp: 64x64 red brick pattern with gray mortar
- create_brick_texture.py: Python script to generate brick texture

Documentation:
- OPENPBR_TESTS_README.md: Comprehensive guide covering material structure,
  shader node IDs, Tydra conversion limitations, and testing procedures

Material features demonstrated:
- Base layer (color, metalness, roughness)
- Specular (weight, roughness, IOR)
- Transmission (weight, color, thin_walled)
- Emission (color, luminance)
- Subsurface scattering (color, weight, radius, radius_scale)
- Coat (weight, roughness, IOR, color)
- Texture mapping with UV coordinates
- Multiple texture formats (BMP, PNG, JPG)

Note: Materials bound to parametric primitives (Sphere, Cube) are not
currently converted by Tydra RenderScene. Use explicit Mesh primitives
for MaterialX export compatibility.

Tested: All files parse correctly, emissive-plane exports to MaterialX XML/JSON

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-05 01:50:24 +09:00
Syoyo Fujita
8fdfa376da Move synthetic SkelAnimation test files to tests/feat/skinning
Relocated skelanim-complete-*.usda test files from models/ to tests/feat/skinning/
to organize feature-specific test files separately from general model assets.

Updated test-synthetic-anims.js to load files from the new location.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-04 22:45:03 +09:00
Syoyo Fujita
3a48d5b714 Add synthetic test models for SkelAnimation verification
Created comprehensive synthetic USD files to test SkelAnimation conversion:

- skelanim-complete-static.usda: Tests static (non-time-sampled) values
  * 2 joints with static translations, rotations, scales
  * Verifies single keyframe at time 0.0 conversion

- skelanim-complete-timesampled.usda: Tests time-sampled values
  * 2 joints with animated translations, rotations, scales
  * 3 keyframes at times [0, 1, 2]

- skelanim-complete-mixed.usda: Tests mixed static and time-sampled
  * 3 joints with static translations/scales, animated rotations
  * Verifies proper handling of mixed property types
  * 5 keyframes for time-sampled properties

All models include proper SkelRoot, Skeleton, and skinned Mesh setup with
skel:animationSource and skel:skeleton relationships required for animation
binding.

Added test-synthetic-anims.js to verify skeletal animation data exposure in
WASM, confirming channels and samplers are properly accessible with skeletal
metadata (target_type, skeleton_id, joint_id, path).

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-04 22:40:20 +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
a58c48e105 add test models for SkinAnimation.
improve a bit for skinning-anim.js demo.
2025-11-04 08:57:12 +09:00
Syoyo Fujita
08733fa608 add mtlx sample scene 2025-10-01 09:25:43 +09:00
Syoyo Fujita
1b03cf0dc0 Improve MCP tools. 2025-07-28 14:55:03 +09:00
Syoyo Fujita
0ceb63b0dc mcp w.i.p. 2025-07-24 12:54:35 +09:00
Syoyo Fujita
13a29e7ebd initial pbr shading support.
various improvements.
2025-06-02 13:47:04 +09:00
Syoyo Fujita
83c8434d10 test file for explicit-joint-orders(w.i.p) 2025-02-04 21:51:06 +09:00
Syoyo Fujita
4e31d4ecf3 add USD 'reference' example. 2024-08-20 03:24:43 +09:00
Syoyo Fujita
03bc930f81 [tydra] Fix connected texture outputChannel was not considered when
constructing tydra::UVTexture.
2024-06-10 06:32:23 +09:00
Syoyo Fujita
b0523414ba [Tydra] [RenderScene] Fix node's xform is not setup correctly 2024-05-12 06:51:06 +09:00
Syoyo Fujita
df8d04655a add timesampled primvar test scene. 2024-04-29 23:24:33 +09:00
Syoyo Fujita
007468c72c Merge branch 'dev' into rendermesh-refactor 2024-04-29 02:57:54 +09:00
Syoyo Fujita
4861193a7d Fix varname typo. 2024-04-29 02:57:27 +09:00
Syoyo Fujita
2124307948 Merge branch 'dev' into rendermesh-refactor 2024-04-29 02:01:11 +09:00
Syoyo Fujita
cb6b4f3ddb add indexed primvar UV test scenes. 2024-04-29 02:00:50 +09:00
Syoyo Fujita
79f9eb9aea Disable non-working examples
Add indexed primvar example scenes.
2024-04-29 01:40:56 +09:00
Syoyo Fujita
8ef7ad3e6b [Test scene] Fix exporting SkelAnimation data. 2024-04-26 08:51:12 +09:00
Syoyo Fujita
8cea4a2055 add test scene for BlendShape + SkelAnimation 2024-04-25 09:44:42 +09:00
Syoyo Fujita
267a05bb8d [Tydra] USD export: Support some GeomSubset export(W.I.P) 2024-04-25 09:09:32 +09:00
Syoyo Fujita
6fa0aadb19 Update texture-cat-plane scene(exported from Blender 4.1) 2024-04-25 07:52:29 +09:00
Syoyo Fujita
2e35feb398 [Tydra] Fix BlendShape Prim export. 2024-04-24 09:57:12 +09:00
Syoyo Fujita
aa851e2c92 [Tydra] USD export: Initial support of exporting skinning data. 2024-04-24 06:58:31 +09:00
Syoyo Fujita
5e70dd1186 small refactor.
add attribute connection from string to token type example.
2024-04-16 23:36:39 +09:00
Syoyo Fujita
8220339cfc add USDZ version of texture-cat-plane scene. 2024-04-16 07:14:06 +09:00
Syoyo Fujita
6c54abec65 Fix reordering 'mesh.point' related attribute when the vertex indices is
being built.
2024-04-16 04:39:36 +09:00
Syoyo Fujita
93cc5589c2 add a skin test scene. 2024-04-15 07:01:41 +09:00
Syoyo Fujita
f442ce6e69 add BlendShape test scene. 2024-04-15 06:53:24 +09:00
Syoyo Fujita
8d3a5dc50a Fix facevarying attribute was incorrectly converted as 'vertex'
variability.
2024-04-15 02:57:09 +09:00
Syoyo Fujita
f302c8e03f add test scene for facevarying vertex attribute. 2024-04-15 01:30:20 +09:00
Syoyo Fujita
f9d9824754 Remove exec permision of a file. 2024-04-14 22:12:21 +09:00
Syoyo Fujita
9f3ead591d add tetra test model. 2024-04-14 08:12:38 +09:00
Syoyo Fujita
41d98b1f3e add some test USDA files. 2024-04-14 08:05:43 +09:00
Syoyo Fujita
a1f1a06eac Initial success of converting texcoords of triangulated plane. 2024-04-14 07:34:22 +09:00
Syoyo Fujita
7c1484f2a9 Fix materialsubset conversion. 2024-04-14 05:42:13 +09:00