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

Extend skinning for >4 bones per vertex #6772

Merged
merged 31 commits into from
Sep 21, 2023
Merged

Conversation

fvbj
Copy link
Contributor

@fvbj fvbj commented Apr 26, 2023

Improve bone skinning for more than four bones per vertex

@google-cla
Copy link

google-cla bot commented Apr 26, 2023

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

Copy link
Collaborator

@pixelflinger pixelflinger left a comment

Choose a reason for hiding this comment

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

In addition the the inline comments, please try to keep the line length to 100.

filament/include/filament/RenderableManager.h Outdated Show resolved Hide resolved
filament/include/filament/RenderableManager.h Outdated Show resolved Hide resolved
filament/include/filament/RenderableManager.h Outdated Show resolved Hide resolved
filament/include/filament/RenderableManager.h Outdated Show resolved Hide resolved
filament/include/filament/RenderableManager.h Outdated Show resolved Hide resolved
filament/src/components/RenderableManager.cpp Outdated Show resolved Hide resolved
filament/src/details/SkinningBuffer.cpp Outdated Show resolved Hide resolved
filament/src/details/VertexBuffer.cpp Outdated Show resolved Hide resolved
filament/src/details/VertexBuffer.cpp Outdated Show resolved Hide resolved
libs/filabridge/include/private/filament/SibStructs.h Outdated Show resolved Hide resolved
@pixelflinger
Copy link
Collaborator

can you sign the CLA btw -- I know it's moot, but this way we can commit the changes.

filament/include/filament/RenderableManager.h Outdated Show resolved Hide resolved
filament/include/filament/RenderableManager.h Outdated Show resolved Hide resolved
filament/src/details/VertexBuffer.cpp Outdated Show resolved Hide resolved
filament/include/filament/RenderableManager.h Outdated Show resolved Hide resolved
filament/src/components/RenderableManager.cpp Outdated Show resolved Hide resolved
filament/src/components/RenderableManager.cpp Outdated Show resolved Hide resolved
filament/src/components/RenderableManager.cpp Outdated Show resolved Hide resolved
filament/src/components/RenderableManager.cpp Outdated Show resolved Hide resolved
filament/src/components/RenderableManager.cpp Outdated Show resolved Hide resolved
filament/src/components/RenderableManager.cpp Outdated Show resolved Hide resolved
filament/src/RenderPass.cpp Outdated Show resolved Hide resolved
filament/src/components/RenderableManager.cpp Outdated Show resolved Hide resolved
filament/src/components/RenderableManager.cpp Outdated Show resolved Hide resolved
filament/src/components/RenderableManager.cpp Outdated Show resolved Hide resolved
filament/src/components/RenderableManager.cpp Outdated Show resolved Hide resolved
shaders/src/getters.vs Outdated Show resolved Hide resolved
filament/src/components/RenderableManager.cpp Outdated Show resolved Hide resolved
filament/src/details/SkinningBuffer.cpp Outdated Show resolved Hide resolved
filament/src/details/VertexBuffer.cpp Outdated Show resolved Hide resolved
filament/src/details/VertexBuffer.cpp Outdated Show resolved Hide resolved
filament/include/filament/RenderableManager.h Outdated Show resolved Hide resolved
filament/src/components/RenderableManager.cpp Outdated Show resolved Hide resolved
filament/src/components/RenderableManager.cpp Outdated Show resolved Hide resolved
filament/include/filament/RenderableManager.h Outdated Show resolved Hide resolved
shaders/src/getters.vs Outdated Show resolved Hide resolved
shaders/src/getters.vs Outdated Show resolved Hide resolved
shaders/src/getters.vs Outdated Show resolved Hide resolved
filament/include/filament/RenderableManager.h Outdated Show resolved Hide resolved
shaders/src/getters.vs Outdated Show resolved Hide resolved
filament/src/components/RenderableManager.cpp Outdated Show resolved Hide resolved
filament/include/filament/RenderableManager.h Outdated Show resolved Hide resolved
filament/include/filament/RenderableManager.h Outdated Show resolved Hide resolved
filament/src/components/RenderableManager.cpp Show resolved Hide resolved
filament/src/components/RenderableManager.cpp Outdated Show resolved Hide resolved
filament/src/components/RenderableManager.cpp Outdated Show resolved Hide resolved
filament/src/components/RenderableManager.h Show resolved Hide resolved
@pixelflinger
Copy link
Collaborator

Would you be able to rebase the change so it builds on main again? thanks!

Copy link
Collaborator

@pixelflinger pixelflinger left a comment

Choose a reason for hiding this comment

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

ushort is not a standard type, make sure to remove all usage and remplace by uint16_t. This should fix the android build.

samples/helloskinningbuffer.cpp Outdated Show resolved Hide resolved
filament/src/components/RenderableManager.cpp Outdated Show resolved Hide resolved
filament/src/components/RenderableManager.cpp Outdated Show resolved Hide resolved
filament/src/details/VertexBuffer.cpp Outdated Show resolved Hide resolved
filament/src/details/VertexBuffer.cpp Outdated Show resolved Hide resolved
Copy link
Collaborator

@pixelflinger pixelflinger left a comment

Choose a reason for hiding this comment

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

I'd like a better fix for the calloc/free, they too far from each other, this is a case where unique_ptr might be a better/safer choice.

filament/src/components/RenderableManager.cpp Outdated Show resolved Hide resolved
Copy link
Collaborator

@pixelflinger pixelflinger left a comment

Choose a reason for hiding this comment

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

Change boneIndicesAndWeights to pass the vector by value, this can be a lot more efficient in that case.

@pixelflinger
Copy link
Collaborator

Also please add a line in NEW_RELEASE_NOTES.md. I think we're getting very close :-)

filament/src/components/RenderableManager.cpp Outdated Show resolved Hide resolved
filament/src/details/SkinningBuffer.cpp Outdated Show resolved Hide resolved
filament/src/details/SkinningBuffer.cpp Outdated Show resolved Hide resolved
Copy link
Collaborator

@pixelflinger pixelflinger left a comment

Choose a reason for hiding this comment

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

lgtm (except for the std::transform that I think could be a memcpy)

filament/src/details/SkinningBuffer.cpp Outdated Show resolved Hide resolved
@pixelflinger
Copy link
Collaborator

@poweifeng @bejado I think we're super close to being able to land this PR, I'd like a one last round of going over it, since it's such a large change. Thank you!

@bejado
Copy link
Member

bejado commented Aug 29, 2023

@poweifeng @bejado I think we're super close to being able to land this PR, I'd like a one last round of going over it, since it's such a large change. Thank you!

Will take another look

for (auto iBonePair = mBonePairs.begin(); iBonePair != mBonePairs.end(); ++iBonePair) {
auto primitiveIndex = iBonePair->first;
auto bonePairsForPrimitive = iBonePair->second;
if (bonePairsForPrimitive.size()) {
Copy link
Member

Choose a reason for hiding this comment

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

nit: invert the condition and do a continue to reduce nesting

if (!bonePairsForPimiritve.size()) {
    continue;
}

Copy link
Contributor Author

@fvbj fvbj Aug 30, 2023

Choose a reason for hiding this comment

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

That's clearer, thank you. Done

auto bonePairsForPrimitive = iBonePair->second;
if (bonePairsForPrimitive.size()) {
size_t vertexCount = mEntries[primitiveIndex].vertices->getVertexCount();
std::unique_ptr<uint16_t[]> skinJoints(
Copy link
Member

Choose a reason for hiding this comment

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

Use std::make_unique here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done, sorry I forgot to reply, thank you

filament/include/filament/VertexBuffer.h Outdated Show resolved Hide resolved
filament/src/components/RenderableManager.cpp Outdated Show resolved Hide resolved
filament/src/components/RenderableManager.cpp Outdated Show resolved Hide resolved
filament/src/details/SkinningBuffer.cpp Outdated Show resolved Hide resolved
filament/src/details/SkinningBuffer.cpp Outdated Show resolved Hide resolved
shaders/src/getters.vs Show resolved Hide resolved
@pixelflinger
Copy link
Collaborator

@fvbj the android/ios (GLES shader issue) and windows builds are failing (C++ issue), FYI.

# Conflicts:
#	NEW_RELEASE_NOTES.md
@fvbj
Copy link
Contributor Author

fvbj commented Sep 12, 2023

@pixelflinger Everything looks good, what can I do to finalize the PR? Thank you.

@pixelflinger
Copy link
Collaborator

@poweifeng @romainguy @bejado @fvbj I'm planning to merge this on Monday after we branch the release. Let me know if there are any concerns.

@pixelflinger
Copy link
Collaborator

@fvbj it looks like several targets are not building.

@romainguy
Copy link
Collaborator

The failures seem due to a reliance on an implicit conversion:

ERROR: lit_opaque.mat:857: '!=' :  wrong operand types: no operation '!=' exists that takes a left-hand operand of type ' temp highp int' and a right operand of type ' const uint' (or there is no acceptable conversion)

@fvbj fvbj requested review from pixelflinger and bejado September 18, 2023 13:12
@pixelflinger
Copy link
Collaborator

@fvbj can you rebase one more time, hopefully there won't be conflicts tomorrow morning when I try to merge it. Thanks!

@pixelflinger pixelflinger merged commit 5d30435 into google:main Sep 21, 2023
8 checks passed
plepers pushed a commit to plepers/filament that referenced this pull request Dec 9, 2023
* Add skinning and morphing samples to check functionality
* Implement skinning for more than four bones pair vertex

The API allows defining an unlimited number of bone indices and weights of primitives. Data is defined in building process of the renderable manager. Backward compatibility with the original solution.
Skinning of vertices is calculated on GPU, data is transferred to the vertex shader in the texture.
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