Skip to content

Commit 585b578

Browse files
mrdoobclaude
andcommitted
USDLoader: Apply UsdUVTexture scale to material colors
The UsdUVTexture inputs:scale was being stored but not applied to material color properties, causing textures with color-encoded scales (e.g. blue tint via scale) to render as white. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 34c4e01 commit 585b578

1 file changed

Lines changed: 50 additions & 1 deletion

File tree

examples/jsm/loaders/usd/USDComposer.js

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2524,6 +2524,18 @@ class USDComposer {
25242524
}
25252525
);
25262526

2527+
// Apply UsdUVTexture scale to diffuse color (output = texture * scale + bias)
2528+
if ( material.map && material.map.userData.scale ) {
2529+
2530+
const scale = material.map.userData.scale;
2531+
if ( Array.isArray( scale ) && scale.length >= 3 ) {
2532+
2533+
material.color.setRGB( scale[ 0 ], scale[ 1 ], scale[ 2 ], SRGBColorSpace );
2534+
2535+
}
2536+
2537+
}
2538+
25272539
// Emissive
25282540
applyTexture(
25292541
'inputs:emissiveColor',
@@ -2542,7 +2554,20 @@ class USDComposer {
25422554

25432555
if ( material.emissiveMap ) {
25442556

2545-
material.emissive.set( 0xffffff );
2557+
if ( material.emissiveMap.userData.scale ) {
2558+
2559+
const scale = material.emissiveMap.userData.scale;
2560+
if ( Array.isArray( scale ) && scale.length >= 3 ) {
2561+
2562+
material.emissive.setRGB( scale[ 0 ], scale[ 1 ], scale[ 2 ], SRGBColorSpace );
2563+
2564+
}
2565+
2566+
} else {
2567+
2568+
material.emissive.set( 0xffffff );
2569+
2570+
}
25462571

25472572
}
25482573

@@ -2620,6 +2645,18 @@ class USDComposer {
26202645
}
26212646
);
26222647

2648+
// Apply UsdUVTexture scale to specular color
2649+
if ( material.specularColorMap && material.specularColorMap.userData.scale ) {
2650+
2651+
const scale = material.specularColorMap.userData.scale;
2652+
if ( Array.isArray( scale ) && scale.length >= 3 ) {
2653+
2654+
material.specularColor.setRGB( scale[ 0 ], scale[ 1 ], scale[ 2 ], SRGBColorSpace );
2655+
2656+
}
2657+
2658+
}
2659+
26232660
// Clearcoat
26242661
if ( fields[ 'inputs:clearcoat' ] !== undefined ) {
26252662

@@ -2702,6 +2739,18 @@ class USDComposer {
27022739
}
27032740
);
27042741

2742+
// Apply UsdUVTexture scale to base color
2743+
if ( material.map && material.map.userData.scale ) {
2744+
2745+
const scale = material.map.userData.scale;
2746+
if ( Array.isArray( scale ) && scale.length >= 3 ) {
2747+
2748+
material.color.setRGB( scale[ 0 ], scale[ 1 ], scale[ 2 ], SRGBColorSpace );
2749+
2750+
}
2751+
2752+
}
2753+
27052754
// Base metalness
27062755
applyTexture(
27072756
'inputs:base_metalness',

0 commit comments

Comments
 (0)