tinyusdz icon indicating copy to clipboard operation
tinyusdz copied to clipboard

Finish "vw" vertex weight TinyObjLoader extension support

Open PierceLBrooks opened this issue 1 year ago • 8 comments

  • https://github.com/syoyo/tinyusdz/blob/dev/src/usdObj.cc#L257
  • https://github.com/syoyo/tinyusdz/blob/dev/doc/usdObj.md?plain=1#L26

I would be super enthusiastic to see this loose tendril of a feature finalized! My desire is to use this conjunction with https://github.com/meshonline/Surface-Heat-Diffuse-Skinning to marry BVH & OBJ formatted asset files together gracefully with automatically assigned vertex weights for the skeleton bones in a minimal runtime. If there is some particular means of direct sponsorship or perhaps even assistance I could provide myself towards this end to accelerate progress, please let me know.

PierceLBrooks avatar Jan 08 '24 04:01 PierceLBrooks

What you want is either...

  • Load USD model(with skeleton) + load .obj model with skin weights as usdObj, combine it and write to USDA.
  • Load it in Blender and use Surface-Heat-Diffusion-Skinning blender add-on to assign vertex weights.
  • Simply implement loading vertex weight support in usdObj suffice?

or

  • No Blender involved version(so minimal runtime?)
  • Load USD model(with skeleton) + load .obj model with skin weights as usdObj
  • Combine it in your app which uses Surface-Heat-Diffuse-Skinning
    • Or we may able to implement it as a tool on top of TinyUSDZ
    • Since I am planning to use BVH to find similar vertices for tangent/binormal basis computation https://github.com/syoyo/tinyusdz/blob/5319fb85a2605f00e115e242cee98a9210e45d4c/src/tydra/render-data.cc#L759 , extending it to support Surface-Heat-Diffuse-Skinning(or similar algorithm) would be possible(For example, implement BVH construction/traversal over USD GeomMesh with custom callback to Tydra https://github.com/syoyo/tinyusdz/tree/dev/src/tydra)

In either case, things will happen after finishing this task(ETA is this month(2024/Jan)) ( https://github.com/syoyo/tinyusdz/issues/109 )

syoyo avatar Jan 08 '24 13:01 syoyo

My apologies, I meant BVH as in the Biovision Hierarchy format for expressing motion capture data, not in the ray-tracing context of that term. So in the first scenario you mentioned, rather than loading a USD model that already has the skeleton onto which the OBJ skin weights would be applied, I would load a BVH asset file and then manually construct the USD scene object with an equivalent skeleton using the TinyUSDZ API before mixing in the mesh/skin information from a usdObj import. Avoiding the involvement of Blender at all is the primary goal. Simply implementing support for loading vertex weight in usdObj is probably sufficient. There is no specific timeline in mind so near the end of the month here is perfectly fine.

PierceLBrooks avatar Jan 08 '24 19:01 PierceLBrooks

@PierceLBrooks Thank you. Ah, understand: BVH as motion data.

So probably you want to do something like https://github.com/dopomoc/Skinning with TinyUSDZ API and BVH(motion data) file + .obj file(with skin weights)

I guess you'll also want usdBVH(BVH motion load(Convert BVH to USD SkelAnimation)) 😸

syoyo avatar Jan 08 '24 23:01 syoyo

I have not found that repository before myself, but if its purpose can be achieved solely through C++, then yes, that is the eventual goal. Would something like usdBvh be considered within the scope of TinyUSDZ? It is fine otherwise because manual construction of a scene with only a skeletal animation entity inside seems fairly doable through the existing API afforded by these headers. However, I'd be happy to sponsor/assist in the creation of both features ( i.e. usdBvh and supporting TinyObjLoader's vertex weight extension for usdObj ).

PierceLBrooks avatar Jan 08 '24 23:01 PierceLBrooks

@PierceLBrooks I'd like to support some de-factor and open file format on top of TinyUSDZ. For example I made a usdFbx placeholder https://github.com/syoyo/tinyusdz/blob/dev/src/usdFbx.cc ) so that people can load industry (de-facto) standard FBX animation/skinning file format on top of TinyUSDZ without writing loader/converter for it(priority is low and not yet implemented though)

So, yes usdBVH will be considered within the scope of TinyUSDZ! BVH motion format is somewhat de-facto & open standard, and it looks there are some demand(including you) to load BVH & obj model in USD workflow.

Sponsoring&assisting usdObj and usdBvh is much appreciated!(At least I need some test/sample BVH/.obj files)

syoyo avatar Jan 09 '24 17:01 syoyo

In that case, I think I will soon begin working towards a draft implementation of usdBvh myself since that would be an entirely new facility requiring less finesse over existing API functionality expectations among users, and wait for the end of the month to approach to hear about whether prioritization with sponsorship of the usdObj vertex weight extension support has become more realistic schedule-wise. Thank you very much for conferring with me so diligently on this matter! I look forward to the progress ahead.

PierceLBrooks avatar Jan 11 '24 00:01 PierceLBrooks

I went ahead and put together a few preliminary test assets using Blender, MakeHuman, plus CMU motion capture data ( http://mocap.cs.cmu.edu/resources.php ). It took a bit of effort but there were at least some fun opportunities to generate some contributions in various projects along the way. The base scene is expressed in GLTF format, but the real meat for further developing both usdBvh and usdObj have had the appropriate extensions appended with the GLTF file's path as a prefix.

  • https://github.com/PierceLBrooks/tinyobjloader/tree/plb/vw-test
  • https://github.com/PierceLBrooks/BlenderMeshSplit/commit/9745a713bd49712abdf42a2b2993b1958956b288
  • https://github.com/makehumancommunity/makehuman/commit/20a8e9a69d5953b7e3b60fcdff8330c54a2a3e22
  • https://projects.blender.org/blender/blender-addons/pulls/105120

untitled.zip

PierceLBrooks avatar Jan 14 '24 23:01 PierceLBrooks

@syoyo Just got a converter working for going from GLTF to USDZ ( https://github.com/PierceLBrooks/usd_from_gltf/tree/pierce ), and so here is the equivalent asset as above but in the right format for setting up some unit tests with eventually perhaps :)

untitled.usdz.zip

PierceLBrooks avatar Jan 25 '24 06:01 PierceLBrooks