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

[QUESTION] Any reason morph targets count is sometimes 0 on a mesh? #208

Open
Smartkin opened this issue Dec 11, 2023 · 6 comments
Open
Labels
question Further information is requested

Comments

@Smartkin
Copy link

Currently using the library to export meshes with morph targets and I gotta say I love the library and the API for being so intuitive to use. However, one current problem I have is when loading the scene back to import back into my own format the amount of morph targets on a random mesh can be 0. What could be the reason for this?
image

@vpenades
Copy link
Owner

I'ts hard to tell without knowing more about what you're doing.

could you provide a reproducible example?

@Smartkin
Copy link
Author

I'ts hard to tell without knowing more about what you're doing.

could you provide a reproducible example?

Looking at the raw model file it seems like at some meshes the delta on all vertexes is 0. I assume then the library just clears the morph targets list if none of them change anything in the mesh?

@vpenades
Copy link
Owner

I assume then the library just clears the morph targets list if none of them change anything in the mesh?

Yes, that is the case, see

// if delta is all 0s, and it's not required, then do not use the accessor
return accessor.Data.All(b => b == 0) ? null : accessor;

Now, I am wondering whether this is right or not. From the data perspective, it's a waste of resources to add an effect-less morph target, but not adding it changes the morph targets sequence indexing so it can result in incorrect morph target assignment and animation...

But it also depends on how are you using this...

@Smartkin
Copy link
Author

I assume then the library just clears the morph targets list if none of them change anything in the mesh?

Yes, that is the case, see

// if delta is all 0s, and it's not required, then do not use the accessor
return accessor.Data.All(b => b == 0) ? null : accessor;

Now, I am wondering whether this is right or not. From the data perspective, it's a waste of resources to add an effect-less morph target, but not adding it changes the morph targets sequence indexing so it can result in incorrect morph target assignment and animation...

But it also depends on how are you using this...

The model format of the game requires that all meshes have the same amount of morph targets. It's not too hard to work around it by just adding zeroed out morphs though

@Smartkin
Copy link
Author

I assume then the library just clears the morph targets list if none of them change anything in the mesh?

Yes, that is the case, see

// if delta is all 0s, and it's not required, then do not use the accessor
return accessor.Data.All(b => b == 0) ? null : accessor;

Now, I am wondering whether this is right or not. From the data perspective, it's a waste of resources to add an effect-less morph target, but not adding it changes the morph targets sequence indexing so it can result in incorrect morph target assignment and animation...

But it also depends on how are you using this...

Maybe it could potentially be an optional flag? As I said it's not too hard to work around if such behavior is expected but it's also not really mentioned anywhere that this would happen. Don't know how GLTF standard dictates this though

@vpenades
Copy link
Owner

Don't know how GLTF standard dictates this though

Well, generally speaking, glTF specification does not like adding stuff that has "no effect" into the rendering... in fact, the gltf validator issues warnings if you do stuff like adding a mesh that is never used in the scene and so on

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

No branches or pull requests

2 participants