Crowd animation

Started by kkl, July 07, 2014, 05:29:46 PM

Previous topic - Next topic

kkl

Hi Raft,

I have been trying with the hardware skinning and it works pretty well so far, despite of few bugs :P, but it takes alot of computing power if it's drawing the same object for >20. Just wonder if it's a good idea to move all objects animation into shader so all animations are done in hardware instead. Do you have any plan implementing this in the future?

EgonOlsen

Are you sure that this is caused by the animation? It's more likely the additional amount of polygons and draw calls that cause a performance drop.

kkl

Hi Egon,

Yes. It is caused by the number of draw calls. If we squeeze all meshes into one draw call, probably we need to move all animation calculations into shader, so it animates each of the meshes, right? Would love to hear from you guys on more recommendations.

raft

as Egon, i doubt the performance caused by animation. maybe you can profile it to see what slows it down?

btw, profiling also have a overhead and can be a bit misleading especially when you profile a java-native mixed app. i.e. profiler considers native part as a single method invocation so it does not suffer from overhead which creates the illusion that java part consumes much more cpu than it actually does.

kkl

Hi Raft,

Sorry for confusing. It's not animation that cost performance. It's the draw calls, caused by drawing too many objects.

To reduce draw calls, we could combined the all meshes into one (thus calling only one draw call). But this way it's hard to calculate bone animation as all object mesh data is in shader.

Quotemaybe you can profile it to see what slows it down?
It doesn't slow down, to be exact. It just takes alot of computing power. I'm working on live wallpaper and computing consumption is quite critical, or else the battery will drain pretty fast.
From the previous testing in hardware skinning post, we have one object with ~1ms to animate. If 20 objects, which would take ~20ms to process. I think that 1ms is roughly spent on draw call.

raft

well as you noticed, there is a overhead of sorting objects on jPCT layer. if you can fix object count you can treat them as a single object and animate altogether (all is attached to same skeleton)

alternatives are: do you really need 20 objects for a wall paper? can you lower polygon counts? do you need to animate all of them? if memory is enough you can even consider converting skeletal animation to regular keyframe animation (ninja demo has code to do that). that will reduce cpu usage but increase memory consumption.

kkl

I'm making a school of fish swimming around a curved path under the ocean, and it sure looks nice if there are more objects. Initially, I thought of putting the fishes as a single object and animate altogether, but the skeleton has to be remade in Blender for each fish and it might be a bit time consuming. If there's more skeletons joints, it might cost a lot of memory too.

I was thinking of putting all fishes into one mesh, then pass in the one shared skeleton and apply to each fish one by one in shader by using instance id. This would be best case, but I think it would be hard to implement.

Quotecan you lower polygon counts? do you need to animate all of them?
Yea, I think I could go ahead n reduce poly count further (now 250 tris each after rough remesh). Maybe some objects don't have to be animated too.

raft

i would expect 20 objects of 250 polygon perform good enough even with software skinning.

kkl

CMIIW, did you mean total 250 tris in 20 objects? I meant each of them has 250 tris, total up with 20 objects = 5000 tris.

raft

yes, correct. i havent tried but modern devices can handle them IMHO

kkl

#10
I'd tried with Galaxy Trend Plus and Galaxy S4. They seems to have good fps ~58fps. But the CPU usage is relatively high, accordingly to the reading after enabling 'CPU usage' in 'Developer Setting' in Android. Just wish there's another way to reduce CPU usage.

raft

that's quite good for a game but for a wallpaper cpu consumption is important as you said. may be you can limit it to 25-30 fps?

kkl

Yup, I agree. We could own most CPU resources in game. Live Wallpaper is a bit tricky, where it has to be battery optimized while giving decent performance.

I tried forcing it to ~30fps. When the fishes are out of screen, the CPU usage is ok. But when they are in the screen, CPU is as high as usual.

Maybe I should turn some of the 3D objects to 2D, so it doesn't take too much of CPU for draw calls. Else, I might need to look into hardware crowd animation. There's a gem I found that might does it; http://http.developer.nvidia.com/GPUGems3/gpugems3_ch02.html