usd2glb icon indicating copy to clipboard operation
usd2glb copied to clipboard

Crash on UV access

Open MootoolsSoftware opened this issue 2 years ago • 3 comments

Hello,

I tried out usd2glb, and I found some crash on some meshes coming from the apple quick look gallery.

Gramophone.zip

For example on this gramophone, the crash occurs on

if (diffuse_connection.has_value())
{
...
	if (uv_connection.has_value())
	{
		std::string path_uv = uv_connection.value().prim_part();
		const tinyusdz::Prim* pshader2 = stage.GetPrimAtPath(tinyusdz::Path(path_uv, "")).value(); 💣💣💣

It seems that there is a problem in the way the different UV set are accessed.

Thanks, Manuel

MootoolsSoftware avatar Apr 10 '24 08:04 MootoolsSoftware

Sorry that I haven't been maintaining this for some time.

By a brief look, the direct cause of the crash is that there isn't a primitive called "/gramophone/Looks/pxrusdpreviewsurface1sg/file4_T2D", which is reference by "/gramophone/Looks/pxrusdpreviewsurface1sg/file4".

Noticed that the USD model uses "MaterialBindingAPI", and I don't remember I ever implemented it at all. Not sure if they are related.

Note that the code is developed against a very limited set of USD samples, so there bound to be a lot of unsupported features. I don't have a plan to improve it. PRs are welcome.

fynv avatar Apr 10 '24 11:04 fynv

You are right that the model file uses a different way to define the UV set, like:

 string inputs:file4:varname = "st"
 string inputs:file5:varname = "st"
 string inputs:file6:varname = "st"
 string inputs:file7:varname = "st"
 string inputs:file8:varname = "st"

What I assumed in the code is that "/gramophone/Looks/pxrusdpreviewsurface1sg/file4_T2D" should be shader, like:

def Shader "file4_T2D"
(
)
{
  uniform token info:id = "UsdPrimvarReader_float2"
  token inputs:varname = "st"
  float2 outputs:result
}

fynv avatar Apr 10 '24 12:04 fynv

Note that the code is developed against a very limited set of USD samples, so there bound to be a lot of unsupported features. I don't have a plan to improve it.

Too bad, because I find the project interesting and, in a way, it's also a good way of testing the TinyUSD library. It seemed to me that the project was close to working properly. Anyway that's a nice job.

MootoolsSoftware avatar Apr 10 '24 15:04 MootoolsSoftware