PixarAnimationStudios / OpenUSD

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

glslProgram.cpp -- Failed to compile shader #1299

Open bdeda opened 4 years ago

bdeda commented 4 years ago

Description of Issue

When viewing in usdview any meshes that have a texture in the material, I am getting an error, and the mesh does not draw correctly in the viewport.

>>>usdview d:\texturedCube\texturedCube_relativeTexturePath.usda
Warning: in CompileShader at line 263 of C:\ci2\workspace\pkg-build-pipeline\bfdpkg\bfd\ext\usd\src\pxr\imaging\hdSt\glslProgram.cpp -- Failed to compile shader (GL_FRAGMENT_SHADER): 0(283) : error C0000: syntax error, unexpected '(', expecting "::" at token "("

Error Context:

  return vec4(shaderData[shaderCoord].fallback);
}
vec4 HdGet_fallback() { return HdGet_fallback(0); }
 HdGet_file(int localIndex) { <<< ERROR!
  int shaderCoord = GetDrawingCoord().shaderCoord;
  return (shaderData[shaderCoord].file);
}

ERROR: Usdview encountered an error while rendering.
        Error in 'pxrInternal_v0_20__pxrReserved__::HdResourceRegistry::AddSources' at line 159 in file C:\ci2\workspace\pkg-build-pipeline\bfdpkg\bfd\ext\usd\src\pxr\imaging\hd\resourceRegistry.cpp : 'Source Buffer for file is invalid'
        Error in 'pxrInternal_v0_20__pxrReserved__::HdResourceRegistry::AddSources' at line 159 in file C:\ci2\workspace\pkg-build-pipeline\bfdpkg\bfd\ext\usd\src\pxr\imaging\hd\resourceRegistry.cpp : 'Source Buffer for wrapT is invalid'
        Error in 'pxrInternal_v0_20__pxrReserved__::HdResourceRegistry::AddSources' at line 159 in file C:\ci2\workspace\pkg-build-pipeline\bfdpkg\bfd\ext\usd\src\pxr\imaging\hd\resourceRegistry.cpp : 'Source Buffer for wrapS is invalid'
        Error in 'pxrInternal_v0_20__pxrReserved__::HdSt_DrawBatch::_GetDrawingProgram' at line 241 in file C:\ci2\workspace\pkg-build-pipeline\bfdpkg\bfd\ext\usd\src\pxr\imaging\hdSt\drawBatch.cpp : 'Failed to compile shader for prim /pCube1/pCubeShape1.'
Warning: in CompileShader at line 263 of C:\ci2\workspace\pkg-build-pipeline\bfdpkg\bfd\ext\usd\src\pxr\imaging\hdSt\glslProgram.cpp -- Failed to compile shader (GL_FRAGMENT_SHADER): 0(279) : error C0000: syntax error, unexpected '(', expecting "::" at token "("
0(313) : error C0000: syntax error, unexpected '(', expecting "::" at token "("
0(317) : error C0000: syntax error, unexpected ';', expecting "::" at token ";"
0(342) : error C0000: syntax error, unexpected '=', expecting "::" at token "="
0(343) : error C1503: undefined variable "light"
0(890) : error C0000: syntax error, unexpected '(', expecting "::" at token "("

Error Context:

  return vec4(shaderData[shaderCoord].fallback);
}
vec4 HdGet_fallback() { return HdGet_fallback(0); }
 HdGet_file(int localIndex) { <<< ERROR!
  int shaderCoord = GetDrawingCoord().shaderCoord;
  return (shaderData[shaderCoord].file);
}

The zip file contains a simple textured cube in Maya that was used to produce the contained texturedCube.usda. The usda file may need to be hand edited to point to the unzipped file path of the texture. Relative file paths to the texture exhibit the same error. The error also happens in 20.02 and 20.08, on both Windows and Linux platforms.

Steps to Reproduce

  1. Open the included texturedCube.usda file with usdview
  2. See the errors in the shell

System Information (OS, Hardware)

This is happening on both Windows 10 and CentOS linux builds.

Package Versions

I have seen this error in both 20.02 and 20.08 versions of USD.

Build Flags

This is happening with a vanilla USD build using the included build_usd.py python script.

bdeda commented 4 years ago

texturedCube.zip The example files.

poljere commented 4 years ago

Thanks for filing this issue, however this looks like an issue with either the exporter or the scene in Maya. Seems like the material exported into Usd is not correct, it exports a texture reader and a primvar reader, but it does not export a surface node.

If you want to see an example of a Usd material using UsdPreviewSurface, please see http://graphics.pixar.com/usd/docs/UsdPreviewSurface-Proposal.html

We can't help you much with the exporter or Maya, please feel to reach out to their GitHub : https://github.com/Autodesk/maya-usd

Thanks!

bdeda commented 4 years ago

I am just trying to view that usd file with usdview and it's raising an exception and not drawing the shapes that have a material with a texture. Shapes that have a material without a texture are viewable in usdview, but the textured ones are not.

I should also note that I used the Pixar USD exporter plugin in Maya from the Autodesk github repo.

I do think usdview should be able to handle the error better, and not manifest as a shader compiler error. End users would not be able to debug that very well.

poljere commented 4 years ago

Absolutely, we need to provide better error messaging when the preview renderer receives an incorrect material network. Thanks for the feedback.

In terms of the asset itself, it looks like the exporter is not producing a Usd compliant material network. If you look at the usda asset, you will see that it has a UsdShade material prim that is bound to a "surface". However, that surface is not of type "UsdPreviewSurface" and instead of type "UsdUVTexture".

I would encourage you to reach out to the Autodesk GitHub specially if you are confident the Maya asset looks good, and that it should be exported correctly.

jtran56 commented 4 years ago

Filed as internal issue #USD-6303