filament icon indicating copy to clipboard operation
filament copied to clipboard

SheenCloth sample model crashes gltf_viewer with assertion

Open bejado opened this issue 2 years ago • 4 comments

Describe the bug Debug builds of gltf_viewer crash when loading the SheenCloth.gltf sample model.

in void utils::panic(const char *, const char *, int, const char *):32
in file ../../libs/utils/src/debug.cpp
reason: ../../libs/gltfio/src/FilamentAsset.cpp:130: failed assertion `info.bindings.size() == 0 || info.flags == flags'

To Reproduce Steps to reproduce the behavior:

  1. Build gltf_viewer for debug
  2. Download the SheenCloth glTF 2.0 sample model.
  3. Load the SheenCloth.gltf model into gltf_viewer

Investigation

A comment above the assertion reads:

    // All bindings for a particular glTF texture must have the same transform function.

However, as seen with SheenCloth.gltf, this isn't always the case.

In the SheenCloth model, sheenColorMap (which wants a sRGB texture), and sheenRoughnessMap (which wants a linear texture) could both map to the same glTF texture.

In that case, one solution is to create two copies of the texture: one sRGB, and one linear. This, however, doubles the required texture memory.

Desktop (please complete the following information):

  • OS: macOS
  • Backend: All backends

bejado avatar Feb 10 '23 22:02 bejado

Or maybe we could do the conversion in the shader for one of the input when they are mixed. With spec constants, this could even be "free" when both match.

pixelflinger avatar Feb 13 '23 03:02 pixelflinger

Yeah, I was thinking of something along those lines could work too. I think this is a somewhat rare edge-case.

bejado avatar Feb 13 '23 18:02 bejado

maybe in the meantime, we could do something to avoid the crash (and I guess get bad roughnessMap instead), and downgrade this bug to "correctness" from "crash"?

pixelflinger avatar Feb 13 '23 19:02 pixelflinger

Yeah I'm fine with that

bejado avatar Feb 13 '23 19:02 bejado