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

[usdAbc] texture coordinates' topology (e.g. indices) is now preserved #520

Merged
merged 3 commits into from
Jun 19, 2018

Conversation

ix-dcourtois
Copy link
Contributor

Description of Change(s)

This pull request fixes texture coordinates loaded through the Alembic plugin. Previously the UVs were expanded, meaning that the topology information (basically the indices) were lost, resulting in bad UVs when using subdivisions.

The pull request introduces a way to read indices from indexed Alembic properties, and use it on texture coordinates.

Fixes Issue(s)

// special case for texture coordinates: we want to preserve the topology,
// so we need to extract the indices properties if they exist.
auto uvProperty = context->ExtractSchema("uv");
if (uvProperty.Cast<IV2fGeomParam>().isIndexed()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not super familiar with the Alembic API, but if there's any chance that Cast() can fail, maybe test the result before dereferncing?

_GetUVPropertyName(),
_GetUVTypeName(),
_CopyGeneric<IV2fGeomParam, GfVec2f>(uvProperty));
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a nice chunk of code that:
a) is duplicated below
b) since UsdGeom and AbcGeom both support indexing for all primvars, we might want to apply to other primvars in the future...

Can you factor it out into a templated helper function, please?

_GetUVTypeName(),
_CopyGeneric<IV2fGeomParam, GfVec2f, false>(uvProperty));
context->AddProperty(
TfToken(_GetUVPropertyName().GetString() + ":indices"),
Copy link
Member

@spiffmon spiffmon Jun 1, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a UsdGeomTokens->indices, which you can use in combination with SdfPath::JoinIdentifier

Copy link
Member

@spiffmon spiffmon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Damien!
A couple of notes in the code, and also it would be really really great to add a simple unit test for this with a small abc file as input - it can be a simple baseline compare with a usda file, or a manual expectations test. Also please make sure you run your change against the existing tests in usdAbc in case it induces (desirable!) baseline diffs.

Btw, did you notice we have introduced an SdfValueTypeRole TexCoord? We're guarding the use of the new role/typeNames behind an environment variable until the reader code has been out awhile, but it's now available in 0.8.5!

Thank you,
--spiff

@jtran56
Copy link

jtran56 commented Jun 1, 2018

Filed as internal issue #161427.

@ix-dcourtois
Copy link
Contributor Author

Hi @spiffmon

Thanks for taking the time to review the code. I knew it was going to need a lot of modifications, but I didn't know where to start :)

  • about the duplication of code and generic primvars: are you suggesting a _ReadGenricPrimvars generic method that I could just invoke in both _ReadPolyMesh and _ReadSubd and would take care of indices ?

  • about the dereferencing, it should already be taken care of, see : https://github.com/PixarAnimationStudios/USD/blob/722956654a7090c23ac33d6e52ae93e05e38f94b/pxr/usd/plugin/usdAbc/alembicReader.cpp#L472

  • Yes, I did notice the arrival of the texture coordinate role, greatly appreciated :) But I didn't notice a role API in the Alembic plugin. If it's not too complicated, I could add an optional role to the _ReadGenricPrimvars helper ?

  • And for the tests, I'll add one. It's just that I'm building USD against our libs, and I do not have Python support enabled (we're using a static boost build, which causes a lot of problems on Windows with Python)

Thanks again for the feedback (not sure how long it will take to fix the aforementioned problems, I do not have much time allocated for this issue currently, but I'll do my best !)

@sunyab sunyab added the blocked Issue fix or pull request blocked until questions are answered or pending notes are addressed label Jun 4, 2018
@spiffmon
Copy link
Member

spiffmon commented Jun 5, 2018 via email

a _ReadProperty templated helper has been introduced, allowing to extract indexed Alembic properties while preserving indices.
@ix-dcourtois
Copy link
Contributor Author

Hi @spiffmon

I updated my pull request. I went the _ReadProperty way because it seemed to follow more closely the existing code (I tried creating a AddPrimvar method to the reader context, but it was forcing me to move code around a lot to be able to check if the Alembic property was indexed, and also the code was a lot different than the other Add* methods)

But if you feel this should be the way to go, let me know, I'll modify it.

I also added the test, and I could successfully run them (I had to switch to Linux)
It's named testUsdAbcIndexedProperties because even though for the moment only the uv's are using this, in the future user Alembic properties might also use this, and more tests might be needed

Also, if you prefer the commits to be squashed, I can do that too.

@spiffmon
Copy link
Member

spiffmon commented Jun 8, 2018

Looks awesome, @ix-dcourtois - thanks much! We'll get this in the PR queue!

@sunyab sunyab added pending push and removed blocked Issue fix or pull request blocked until questions are answered or pending notes are addressed labels Jun 11, 2018
@pixar-oss pixar-oss merged commit df5fcd8 into PixarAnimationStudios:dev Jun 19, 2018
pixar-oss added a commit that referenced this pull request Jun 19, 2018
[usdAbc] texture coordinates' topology (e.g. indices) is now preserved

(Internal change: 1864671)
AdamFelt pushed a commit to autodesk-forks/USD that referenced this pull request Apr 16, 2024
…lve/dev

auto sync origin/dev to adsk/dev
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.

5 participants