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

IECoreUSD : Alembic referenced in a USD stage places the indices of an indexed primitive variable into an attribute #1415

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

boberfly
Copy link
Contributor

Generally describe what this PR will do, and why it is needed.

  • Currently this is just a unit test to demonstrate an Alembic referenced in a USD stage will incorrectly place the indices of an indexed primitive variable into a cortex attribute instead
  • It could be an issue with usdAbc https://github.com/PixarAnimationStudios/OpenUSD/tree/release/pxr/usd/plugin/usdAbc the cube looks to load in usdview but I am not sure how it would tell me that it was smart enough to know about the indices (N visually looks the same in the attributes which is also the same indexed FaceVarying)
  • cube.usda has the unit test cube asset that I created with primvars:custom demonstrating the issue that I've put into alembicIndices.abc and referenced in alembicIndices.usda and the normal Gaffer SceneReader can read the attached cube.usda and alembicIndices.abc correctly when loaded directly
  • I've made an early test into this function by putting this code in, but I'm not too familiar with IECoreUSD so it doesn't fix the issue, and I have a feeling it's usdAbc or there needs to be some workaround in how the indices get applied because the primitive variable is invalid
Click to Expand

	// Check for `<name>:indices` primvar. When there is an Alembic cache
	// referenced in a USD stage, the indices for primvars need to stay as
	// a primvar side by side the matching primvar name.

	if( primVar.NameContainsNamespaces() && boost::ends_with( primVar.GetName().GetString(), ":indices" ) )
	{
		const TfToken origPrimvarName( boost::replace_last_copy( primVar.GetName().GetString(), ":indices", "" ) );
		if( auto origPrimVar = UsdGeomPrimvarsAPI( primVar.GetAttr().GetPrim() ).GetPrimvar( origPrimvarName ) )
		{
			if( origPrimVar.GetInterpolation() != pxr::UsdGeomTokens->constant )
			{
				return false;
			}
		}
	}

Related Issues

  • N/A

Dependencies

  • N/A

Breaking Changes

  • N/A

Checklist

  • I have read the contribution guidelines.
  • I have updated the documentation, if applicable.
  • I have tested my change(s) in the test suite, and added new test cases where necessary.
  • My code follows the Cortex project's prevailing coding style and conventions.

…n indexed primitive variable into an attribute
@boberfly boberfly force-pushed the fixes/alembicInUsdIndices branch from caf70ae to 16a16d9 Compare April 20, 2024 04:23
@johnhaddon
Copy link
Member

I expect we could add a workaround for this in Cortex, but to me this looks like a UsdAbc issue at core. The primvars:custom:indices attribute has IsCustom() == True, which would not be the case for primvars written using the standard UsdGeomPrimvars API :

image

@boberfly
Copy link
Contributor Author

I have a fix for usdAbc here: PixarAnimationStudios/OpenUSD#3473

Lets see how this goes!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants