f3d-app / f3d

Fast and minimalist 3D viewer.
https://f3d.app
BSD 3-Clause "New" or "Revised" License
2.93k stars 215 forks source link

A specific USD Mesh is missing parts because of GeomSubset #1675

Open tonpix opened 1 month ago

tonpix commented 1 month ago

Describe the bug Exported as .usdc from blender 4.4, then imported into blender and opened in F3D for comparison. Mesh in F3D is missing some parts - look at screenshot. f3d_fa3eQp2vIq

To Reproduce

  1. open roof.usdc

Expected behavior Mesh should be identical in blender and F3D

System Information:

F3D Information Version: 2.5.0. Build date: 2024-07-01 21:30:06. Build system: Windows 64-bits. Compiler: MSVC 19.40.33811.0. External rendering module: ON. Raytracing module: ON. VTK version: 9.3.0-3457-gecf3646d64 (date: 20240620).

Additional context Attached roof.usdc roof.zip

Meakk commented 1 month ago

There is a GeomSubset under the Plane_042 mesh node. It defines a submesh by selecting only a few faces. When this GeomSubset node is removed, it works well:

image

geomsubset removed: roof.zip

I don't know what's the expected behavior though.

tonpix commented 1 month ago

There is a GeomSubset under the Plane_042 mesh node. It defines a submesh by selecting only a few faces. When this GeomSubset node is removed, it works well: image

geomsubset removed: roof.zip

I don't know what's the expected behavior though.

How did you delete GeomSubset?

Expected behaviour is that loading .usdc file into F3D would show everything, just like when importing same .usdc file into blender or Unreal Engine - both blender and UE5 show missing mesh parts without any modifications.

Meakk commented 1 month ago

How did you delete GeomSubset?

I used Omiverse Create. Where is your file exported from?

tonpix commented 1 month ago

blender 4.4. I noticed also that if I delete custom split normals data in blender and export to .usdc, F3D shows mesh correctly

Meakk commented 1 month ago

Related code: https://github.com/f3d-app/f3d/blob/38054ab51a4a6bf4a42cb482aefc74ee36b57009/plugins/usd/module/vtkF3DUSDImporter.cxx#L661-L698

I don't remember why I did that, but I think it was needed. Maybe it's a Blender exporter issue?

Meakk commented 1 month ago

Ok I do remember now. It was implemented to fix https://github.com/f3d-app/f3d/issues/1186 where materials were assigned per geomsubset. But in this case, the subsets combined make the whole mesh, which is not the case for you.
It's still unclear if it's a Blender issue, or if it's expected that the subsets cover only a part of the mesh.

snoyer commented 1 month ago

not sure what the implications are but here's the orginal model in usdview for reference: roof-usdview

Meakk commented 1 month ago

Yes I tried too. It seems like the important parameter is subsetFamily on the mesh:

image

In the USD documentation, I can read:

When multiple subsets belonging to a prim have the same familyName, they are said to belong to the family. A familyType value can be encoded on the owner of a family of subsets as a token using the static method UsdGeomSubset::SetFamilyType(). "familyType" can have one of the following values: UsdGeomTokens->partition: implies that every element of the whole geometry appears exactly once in only one of the subsets belonging to the family. UsdGeomTokens->nonOverlapping: an element that appears in one subset may not appear in any other subset belonging to the family, and appears only once in the subset in which it appears. UsdGeomTokens->unrestricted: implies that there are no restrictions w.r.t. the membership of elements in the subsets. They could be overlapping and the union of all subsets in the family may not represent the whole.

I guess partition is the current behavior (loop on subsets and draw them individually).
But what about nonOverlapping? Display subsets and keep track of elements excluded from subsets to draw them in a single actor?
And unrestricted? Looks odd to me, so maybe we can just skip that and draw the whole mesh?