Jump to content
  • Advertisement
Sign in to follow this  
d07RiV

Splitting up skinned mesh to reduce used bones

This topic is 1086 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have a model with about 2k vertices and 80 bones. I can render it (with WebGL) by loading the bone transforms as uniforms, but on mobiles max uniforms is 128 (which is 32 4x4 matrices) so I can't load all bones at the same time. UBO's are also not supported in webgl.

 

So it seems my only solution would be to split up the mesh, and I'm looking for the best way to do it.

Basically each triangle contains 3 vertices (doh) and each vertex references up to 3 bones. So basically each triangle uses up to 9 bones, and we want to break the model into as few sets of ~30 bones as possible (overlapping) such that each triangle can be rendered with one of the sets. I'm pretty sure its an NP-complete problem so I'm not sure if there's a good approach that will give an approximate solution. My best guess so far is just using a greedy algorithm to keep picking triangles that add as few bones as possible to the current group until it fills up, but maybe there's something that's known to work better?

Edited by d07RiV

Share this post


Link to post
Share on other sites
Advertisement

really sounds like a job for a 3d artist and 3d modeling software. split your 2K verts 80 bone skinned mesh into at least (80/32=2.5) 3 skinned meshes of 32 bones max each.

 

what kind of a skinned mesh model is it? the number of bones seems kind of high for the number of triangles.

 

needless to say, if you've already done the modeling, skinning, adjusted skin weights, and animated the single mesh, some of that may need to be redone.

 

its not uncommon when coming up with a workflow and suite of tools for implementing skinned meshes to encounter such gotchas that make you re-do work. eventually you figure out exactly what works and what doesn't, and how you have to do things to get all the tools and libs to work together, and then you can get on with content creation.

Edited by Norman Barrows

Share this post


Link to post
Share on other sites

They're not my models, I'm making a web model viewer for an existing game. The models are not super detailed, but they do have like 3 bones per finger.

 

I ended up splitting them up automatically, I'm getting about 4 chunks per model and up to 100 extra vertices (I have to duplicate some to fix the bone indices), so its quite all right.

 

I haven't thought about using textures to store matrices, maybe I'll try that as well. Idk how webgl is going to like that, though.

Share this post


Link to post
Share on other sites
Most objects require multiple draw calls to render (one per material per object).
It is standard to send only the bones that influence those specific parts of the model, not all of the bones for the whole model.

If however your model really is just one draw call and all bones are needed, and there are too many bones, it is standard to use textures instead of uniforms.
WebGL should have no problem with this, as the only necessity is texture-fetch in vertex shaders, which is widely supported today.


L. Spiro Edited by L. Spiro

Share this post


Link to post
Share on other sites

You can render the object with two draw calls after eachother, where the draw calls would differ only in matricies set and skip index, meaning you would interpolate skip instruction from vertex function (if vertex indexes an out of bound bone) to fragment function, and use discard on the pixels, each draw call will draw pixels exclusively.

Edited by JohnnyCode

Share this post


Link to post
Share on other sites

Yeah thanks, I would definitely try it with textures, but I already preprocessed all the models to only use 24 bones per chunk so I don't need to change anything. Would be useful if I run into it again, though. I don't use skips, instead I fix the bone indices in vertices themselves, and if a vertex is used in multiple chunks I simply duplicate it.

 

And yeah the original objects do use lots of bones for some single-material objects. I.e gloves alone use 41 bones due to all the fingers >.>

Edited by d07RiV

Share this post


Link to post
Share on other sites

Our engine uses a greedy algorithm that's basically what you described. I implemented it a long time ago for the exact same reasons that you're explaining, and it's worked fine. I'm sure that we occasionally end up with models needing one or two draw calls more than the optimal solution, but - as you've guessed - finding that is significantly more difficult, and definitely not worth the effort.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!