kcoley / gltf2usd

command-line utility for converting glTF 2.0 models to USD
MIT License
263 stars 39 forks source link

Strange Rendering Issue #17

Closed ox closed 6 years ago

ox commented 6 years ago

I am having trouble figuring out why this USDZ file (I used gltf2usd to make a USDA, then zip'd with usdzip) is rendering incorrectly. Using usdview I'm getting a fully black model, and when I try to open it with iOS 12 Beta 9, the model is tiny and invisible. I've combed through the Materials and they seem fine, as do the Meshes. I'm fairly new to USD so I'm not sure where else to look. Is there a better way to check the model's textures?

Here is the original gltf: carrothead.gltf.zip.txt

And here is the generated USD file: carrothead.usdz.txt

kcoley commented 6 years ago

Hi @ox. I’ll take a look and investigate.

kcoley commented 6 years ago

@ox

def Xform "root"
{
    float3 xformOp:scale = (100, 100, 100)
    ...
}

I mentioned in another issue that I could make this a command line parameter, so I will track that too in case source glTF models are actually not in meters.

kcoley commented 6 years ago

I forgot to address the usdview issue. It was mentioned on the USD interest forum that usdview currently expects all PreviewSurface parameters to be explicitly defined, which this tool does not currently do. There are plans to update usdview to not require all parameters to be set, but I can create an issue to track this one too.

ox commented 6 years ago

@kcoley Ahh yea, I forgot to mention that I had to return a (transform, lambda m: m) (or something like that) when the tool had to parse weights. I'm going to try disabling the animations and trying again. I think it's doable since USD also supports Blendshapes (weights) from what I can tell by playing with ARKit.

What forums are these? Also, would defining all of the params (guessing this?) cause the rendering to show up correctly? I was having trouble rendering the sample plane from that page with one of the carrot's textures, maybe that's why.

kcoley commented 6 years ago

@ox

I think it's doable since USD also supports Blendshapes (weights) from what I can tell by playing with ARKit.

Yep, USD does support blend shapes in the latest release, so I would just need to implement it

What forums are these?

There is a USD interest Google group: https://groups.google.com/forum/#!forum/usd-interest You'll just need to sign in with a Google account.

Also, would defining all of the params (guessing this?) cause the rendering to show up correctly?

Yes, that was mentioned in one of the threads in the group. I have not tried it myself, but I will implement it after fixing the bigger skeleton/blend shape animations.

ox commented 6 years ago

Hmm no dice on getting a single PreviewSurface to render properly. I edited the pbrmaterial_6 Material here and am still getting a black body for the carrot. I then tried to use a primvar to somehow get the normals passed into the PreviewSurface but kind of got lost.

What's interesting is that Apple's models (like this red chair) come out looking gray, and use normal maps and primvar shaders to extract the normals from a png rather than specifying normals on the Mesh.

wave-electron commented 6 years ago

@ox

I didn't have any issues with the render, used xcode beta 6. Viewable in IOS 12 beta 10.

carrothead.usdz

carrothead

ox commented 6 years ago

@wave-electron Hmm strange. By render I meant in usdview, which I was assuming would be the definitive tool on USD rendering. Glad to see that it works, but I'm on iOS 12 Beta 11 (16A5365b) and I don't even get the preview.

How is your USDZ 400kb smaller than the USDZ I provided here? The only difference reported by usddiff between the two is that mine has assets in a dir called 0 and yours does not. Did you use usdzip or the usdz_converter?

ox commented 6 years ago

Ok I think I figured it out! turns out usdzip is very naive in how it constructs the usdz files. Some changes I had to make:

I was circling around it until I started dumping the contents of @wave-electron's model. I'm now able to get the model to show up in the Files app! Thank you for your help y'all.