-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Conversation
// 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()) { |
There was a problem hiding this comment.
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)); | ||
} |
There was a problem hiding this comment.
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"), |
There was a problem hiding this comment.
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
There was a problem hiding this 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
Filed as internal issue #161427. |
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 :)
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 !) |
-
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 ?
Yes, or even a method on the context, like context->AddPrimvar(), which
would always check for indexing?
-
-
about the dereferencing, it should already be taken care of, see :
https://github.com/PixarAnimationStudios/USD/blob/
7229566/pxr/usd/plugin/
usdAbc/alembicReader.cpp#L472
<https://github.com/PixarAnimationStudios/USD/blob/722956654a7090c23ac33d6e52ae93e05e38f94b/pxr/usd/plugin/usdAbc/alembicReader.cpp#L472>
Ah, yes - thanks for pointing that out!
-
-
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 ?
It's taken care of by _GetUVTypeName()
-
-
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)
Got it. As long as you can generate the USD file corresponding to your
abc test asset, you can just follow the pattern of testUsdAbcInstancing,
which does a baseline comparison, and we can make any corrections needed to
ensure the test runs properly.
--spiff
|
a _ReadProperty templated helper has been introduced, allowing to extract indexed Alembic properties while preserving indices.
Hi @spiffmon I updated my pull request. I went the 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) Also, if you prefer the commits to be squashed, I can do that too. |
Looks awesome, @ix-dcourtois - thanks much! We'll get this in the PR queue! |
[usdAbc] texture coordinates' topology (e.g. indices) is now preserved (Internal change: 1864671)
…lve/dev auto sync origin/dev to adsk/dev
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)