Author Topic: Crowd animation  (Read 16904 times)

Offline kkl

  • float
  • ****
  • Posts: 291
    • View Profile
Crowd animation
« on: July 07, 2014, 05:29:46 pm »
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?
« Last Edit: July 07, 2014, 05:36:05 pm by kkl »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Crowd animation
« Reply #1 on: July 07, 2014, 07:38:43 pm »
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.

Offline kkl

  • float
  • ****
  • Posts: 291
    • View Profile
Re: Crowd animation
« Reply #2 on: July 08, 2014, 02:30:54 am »
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.

Offline raft

  • Moderator
  • quad
  • *****
  • Posts: 1993
    • View Profile
    • http://www.aptalkarga.com
Re: Crowd animation
« Reply #3 on: July 08, 2014, 09:08:31 am »
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.

Offline kkl

  • float
  • ****
  • Posts: 291
    • View Profile
Re: Crowd animation
« Reply #4 on: July 08, 2014, 10:33:16 am »
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.

Quote
maybe 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.

Offline raft

  • Moderator
  • quad
  • *****
  • Posts: 1993
    • View Profile
    • http://www.aptalkarga.com
Re: Crowd animation
« Reply #5 on: July 08, 2014, 11:15:25 am »
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.

Offline kkl

  • float
  • ****
  • Posts: 291
    • View Profile
Re: Crowd animation
« Reply #6 on: July 08, 2014, 12:15:37 pm »
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.

Quote
can 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.

Offline raft

  • Moderator
  • quad
  • *****
  • Posts: 1993
    • View Profile
    • http://www.aptalkarga.com
Re: Crowd animation
« Reply #7 on: July 08, 2014, 12:36:15 pm »
i would expect 20 objects of 250 polygon perform good enough even with software skinning.

Offline kkl

  • float
  • ****
  • Posts: 291
    • View Profile
Re: Crowd animation
« Reply #8 on: July 08, 2014, 03:43:44 pm »
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.

Offline raft

  • Moderator
  • quad
  • *****
  • Posts: 1993
    • View Profile
    • http://www.aptalkarga.com
Re: Crowd animation
« Reply #9 on: July 08, 2014, 04:18:25 pm »
yes, correct. i havent tried but modern devices can handle them IMHO

Offline kkl

  • float
  • ****
  • Posts: 291
    • View Profile
Re: Crowd animation
« Reply #10 on: July 09, 2014, 02:33:05 am »
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.
« Last Edit: July 09, 2014, 03:03:40 am by kkl »

Offline raft

  • Moderator
  • quad
  • *****
  • Posts: 1993
    • View Profile
    • http://www.aptalkarga.com
Re: Crowd animation
« Reply #11 on: July 09, 2014, 08:59:41 am »
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?

Offline kkl

  • float
  • ****
  • Posts: 291
    • View Profile
Re: Crowd animation
« Reply #12 on: July 09, 2014, 05:12:02 pm »
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