Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
tonpix opened this issue Oct 23, 2024 · 8 comments
Open

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

tonpix opened this issue Oct 23, 2024 · 8 comments
Labels
source:usd type:bug Something isn't working

Comments

@tonpix
Copy link

tonpix commented Oct 23, 2024

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:

  • OS: Windows 10
  • GPU and GPU driver: GTX 1080, drivers 551.76

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

@mwestphal mwestphal added this to F3D Oct 23, 2024
@mwestphal mwestphal moved this to Investigate in F3D Oct 23, 2024
@Meakk
Copy link
Contributor

Meakk commented Oct 23, 2024

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
Copy link
Author

tonpix commented Oct 23, 2024

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
Copy link
Contributor

Meakk commented Oct 23, 2024

How did you delete GeomSubset?

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

@tonpix
Copy link
Author

tonpix commented Oct 23, 2024

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

@mwestphal mwestphal changed the title Mesh is missing parts A specific USD Mesh is missing parts because of GeomSubset Oct 23, 2024
@Meakk
Copy link
Contributor

Meakk commented Oct 23, 2024

Related code:

std::vector<pxr::UsdGeomSubset> subsets = pxr::UsdGeomSubset::GetGeomSubsets(geomPrim);
if (subsets.empty())
{
this->AddActor(renderer, path, geomPrim, prim, mat, polydata);
}
else
{
// split subsets
for (const pxr::UsdGeomSubset& subset : subsets)
{
pxr::UsdAttribute indicesAttr = subset.GetIndicesAttr();
pxr::VtArray<int> indices;
indicesAttr.Get(&indices, timeCode);
vtkNew<vtkPolyData> polydataSubset;
polydataSubset->SetPoints(polydata->GetPoints());
polydataSubset->GetPointData()->ShallowCopy(polydata->GetPointData());
vtkCellArray* mainPolys = polydata->GetPolys();
// add polygons
vtkNew<vtkCellArray> cells;
for (int cellId : indices)
{
vtkIdType cellSize;
const vtkIdType* cellPoints;
mainPolys->GetCellAtId(cellId, cellSize, cellPoints);
cells->InsertNextCell(cellSize, cellPoints);
}
polydataSubset->SetPolys(cells);
this->AddActor(renderer, path.AppendChild(pxr::TfToken(prim.GetName())), geomPrim,
subset.GetPrim(), mat, polydataSubset);
}
}

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

@Meakk
Copy link
Contributor

Meakk commented Oct 23, 2024

Ok I do remember now. It was implemented to fix #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
Copy link
Contributor

snoyer commented Oct 24, 2024

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

@Meakk
Copy link
Contributor

Meakk commented Oct 24, 2024

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
source:usd type:bug Something isn't working
Projects
Status: Investigate
Development

No branches or pull requests

4 participants