PixarAnimationStudios / OpenUSD

Universal Scene Description
http://www.openusd.org
Other
6.18k stars 1.23k forks source link

UDIMs in MaterialX shaders appears to be broken. #3277

Open ld-kerley opened 2 months ago

ld-kerley commented 2 months ago

Description of Issue

UDIM support when using MaterialX nodes appears to be broken.

UsdPreview shaders work as expected usdview udims_ps.usdz

UsdPreview shader nodes

MaterialX shaders do not correctly resolve the UDIMs usdview udims.usdz

MaterialX shader nodes

Using MaterialX shader nodes emits the following shader compilation errors on MacOS.

Warning: in _ValidateCompilation at line 212 of ../../pxr/imaging/hdSt/glslProgram.cpp -- Failed to compile shader (FRAGMENT_SHADER): program_source:4961:21: error: use of undeclared identifier 'HdGetSampler_N1_file'; did you mean 'HdGetScalar_N1_file'?
    mx_image_color3(N1_file, N1_layer, N1_default, geomprop_UV0_out1, N1_uaddressmode, N1_vaddressmode, N1_filtertype, N1_framerange, N1_frameoffset, N1_frameendaction, N1_uv_scale, N1_uv_offset, N1_out);
                    ^
program_source:3263:30: note: expanded from macro 'N1_file'
#define N1_file MetalTexture{HdGetSampler_N1_file(), samplerBind_N1_file}
                             ^
program_source:1670:7: note: 'HdGetScalar_N1_file' declared here
float HdGetScalar_N1_file() { return HdGet_N1_file(0).x; }
      ^
program_source:4961:21: error: no viable conversion from 'float' to 'texture2d<float>'
    mx_image_color3(N1_file, N1_layer, N1_default, geomprop_UV0_out1, N1_uaddressmode, N1_vaddressmode, N1_filtertype, N1_framerange, N1_frameoffset, N1_frameendaction, N1_uv_scale, N1_uv_offset, N1_out);
                    ^~~~~~~
program_source:3263:30: note: expanded from macro 'N1_file'
#define N1_file MetalTexture{HdGetSampler_N1_file(), samplerBind_N1_file}
                             ^~~~~~~~~~~~~~~~~~~~~~
/System/Library/PrivateFrameworks/GPUCompiler.framework/Versions/32023/Libraries/lib/clang/32023.335/include/metal/__bits/metal_texture2d:2652:14: note: candidate constructor not viable: no known conversion from 'float' to 'const metal::texture2d<float, metal::access::sample> &' for 1st argument
  METAL_FUNC texture2d(const thread  texture2d &) thread = default;
             ^
/System/Library/PrivateFrameworks/GPUCompiler.framework/Versions/32023/Libraries/lib/clang/32023.335/include/metal/__bits/metal_texture2d:2654:14: note: candidate constructor not viable: no known conversion from 'float' to 'const device metal::texture2d<float, metal::access::sample> &' for 1st argument
  METAL_FUNC texture2d(const device  texture2d &) thread = default;
             ^
/System/Library/PrivateFrameworks/GPUCompiler.framework/Versions/32023/Libraries/lib/clang/32023.335/include/metal/__bits/metal_texture2d:2664:14: note: candidate constructor not viable: no known conversion from 'float' to 'const constant metal::texture2d<float, metal::access::sample> &' for 1st argument
  METAL_FUNC texture2d(const constant  texture2d &) thread = default;
             ^
/System/Library/PrivateFrameworks/GPUCompiler.framework/Versions/32023/Libraries/lib/clang/32023.335/include/metal/__bits/metal_texture2d:2673:14: note: candidate constructor not viable: no known conversion from 'float' to 'const metal::texture2d<float, metal::access::sample> &' for 1st argument
  METAL_FUNC texture2d(const thread  texture2d &) constant = default;
             ^
/System/Library/PrivateFrameworks/GPUCompiler.framework/Versions/32023/Libraries/lib/clang/32023.335/include/metal/__bits/metal_texture2d:2676:14: note: candidate constructor not viable: no known conversion from 'float' to 'const device metal::texture2d<float, metal::access::sample> &' for 1st argument
  METAL_FUNC texture2d(const device  texture2d &) constant = default;
             ^
/System/Library/PrivateFrameworks/GPUCompiler.framework/Versions/32023/Libraries/lib/clang/32023.335/include/metal/__bits/metal_texture2d:2686:14: note: candidate constructor not viable: no known conversion from 'float' to 'const constant metal::texture2d<float, metal::access::sample> &' for 1st argument
  METAL_FUNC texture2d(const constant  texture2d &) constant = default;
             ^
/System/Library/PrivateFrameworks/GPUCompiler.framework/Versions/32023/Libraries/lib/clang/32023.335/include/metal/__bits/metal_texture2d:2893:14: note: candidate constructor not viable: no known conversion from 'float' to '__metal_texture_2d_t' for 1st argument
  METAL_FUNC texture2d(__metal_texture_2d_t t) thread : t(t) {}
             ^

ERROR: Usdview encountered an error while rendering.
    Error in '&pxrInternal_v0_24__pxrReserved__::HdSt_DrawBatch::_GetDrawingProgram' at line 391 in file ../../pxr/imaging/hdSt/drawBatch.cpp : 'Failed to compile shader for prim /udims/geo/udims.'

Also tested on linux with the same result.

Steps to Reproduce

  1. Download and extract udims_example.zip
  2. Contains two USDZ files, udims.usdz uses MaterialX nodes in the material, and udims_ps.usdz uses UsdPreviewSurface nodes.
  3. View the files in usdview using Storm.

System Information (OS, Hardware)

Tested on both Alma Linux and MacOS

Package Versions

USD 24.8

jesschimein commented 2 months ago

Filed as internal issue #USD-10092