Hardware skinning needed

Started by kkl, May 08, 2014, 06:22:10 PM

Previous topic - Next topic

kkl

Hi Raft,

Is it doable for Bones to have hardware skinning? I checked from orge3d.org and they seem to have it. http://www.ogre3d.org/forums/viewtopic.php?f=4&t=66907#p440560

I have 6 animated models with bones and it seems to takes a lot of CPU usage and slow down Android main UI (I'm doing live wallpaper).

raft

yes, it is possible but i dont have any plans or time to implement it. sorry

kkl

Is it possible if we do it without editing the Bones library? I'll try to implement it if no editing required.

raft

no, you need to modify Bones' source. but modification will not be that much. i'm not completely sure about this but I suppose, you should leave calculation of skeleton poses as it is and intervene at applyAnimation method. you should upload poses to GPU and calculate new positions of vertices via shaders.

if you intend to do it, jME2's relevant part may help. it's included in Bones distribution.

also note, with hw skinning, jPCT's polygon level collision detection will not work correctly (unless of course you download vertex positions from GPU). but you can still use sphere or ellipsoid collision detection.

kkl

#4
Quoteyou should leave calculation of skeleton poses as it is and intervene at applyAnimation method
Does it mean animateSkin() method is to be processed by CPU and applyAnimation() by GPU? Can we put the animateSkin() calculation to shader as well? Hoping we could just put all calculations to GPU so CPU would process as less as possible.

QuotejME2's relevant part may help. it's included in Bones distribution
It seems like jME2 is a really huge library, but it's open-sourced. I guess I can try to find the needle in the ocean ;P

raft

Quote
Does it mean animateSkin() method is to be processed by CPU and applyAnimation() by GPU?
yes, that is what I meant
QuoteCan we put the animateSkin() calculation to shader as well? Hoping we could just put all calculations to GPU so CPU would process as less as possible.
that is also possible but it requires much more modification to Bones' code. calculation of skeleton pose is relatively cheaper. the expensive part is applying skeleton pose to mesh. I will suggest starting with porting applyAnimation() to shader. this will have a couple of benefits:

* it wil be easier to implement
* if something does not work, you can be sure the problem is in applyAnimation

Quote
It seems like jME2 is a really huge library, but it's open-sourced. I guess I can try to find the needle in the ocean ;P
yes, jME2 is a huge library but Bones comes with only relevant parts. particularly have a look at com.jmex.model.ogrexml.anim.MeshAnimationController update method

EgonOlsen

If you manage to do the skinning on the GPU, it would be great if the required shader code is designed as a kind of plugin, so that it's possible to inject it into other shaders by doing some simple insert operation. Because otherwise, it would require everybody who is going to use this to write and manage his/her own shaders and the default shaders would be useless.

kkl

Hi Raft,

Yea. I think I can start from applyAnimation(). BTW, I checked by calculating time taken for animateSkin() and applyAnimation() respectively, and found out the time taken for animateSkin() is higher than applyAnimation(). The result is, animateSkin() = ~450000 ns and applyAnimation() = ~45000 ns in average. Since it's taking more process in animateSkin(), just hope we can put both in shader too. But I guess that will deeply involve library editing.

kkl

Hi Egon,

Yea. I guess the hardware skinning is somewhat important. I'll try to implement it. If it works, I'll let y'all know.

raft

Quote from: kkl on May 11, 2014, 04:11:52 PM
Yea. I think I can start from applyAnimation(). BTW, I checked by calculating time taken for animateSkin() and applyAnimation() respectively, and found out the time taken for animateSkin() is higher than applyAnimation(). The result is, animateSkin() = ~450000 ns and applyAnimation() = ~45000 ns in average. Since it's taking more process in animateSkin(), just hope we can put both in shader too. But I guess that will deeply involve library editing.
oops, sorry, skin animation is actually applied at applySkeletonPose method, applyAnimation only says jPCT new mesh is ready to upload to GPU.

animateSkin also calls applySkeletonPose so the time you saw is combined time of both

kkl

In this case, does it mean we have to rewrite the whole animateSkin() to shader? Still doable w/o editing the library?

raft

yes, almost the same thing. have a look at the code, you will see it.

kkl

Ok, I'll have a look at it and keep you guys posted ;)

kkl

I started reading the code and I just wonder if I can access SkinClipSequence animate() by making it a public method, so I can separate recode the animateSkin and take the applySkeletonPose() to shader and leave the rest to CPU.

raft