Search Unity

Question Which animation optimization method is better?

Discussion in 'Shaders' started by Zimaell, Feb 23, 2023.

  1. Zimaell

    Zimaell

    Joined:
    May 7, 2020
    Posts:
    409
    I'm trying to figure out the best way to bake and use animation, this will mainly be used to get good performance with a lot of animated NPCs...

    But I have already noticed in various articles that there are different ways, there are using vertex shaders, and there are also using computational ones, plus there are few examples, but nevertheless they differ.

    My task is to sometimes give instructions to NPCs (go there, dig there, stand there waiting), but there will be a lot of them, so I need to choose the best option for solving this problem with good optimization.

    Question - what method will suit better for realization of my task?
    (I don’t even ask for examples, which method is better to use so that I know exactly what I need, learning shaders is a rather difficult task)
    (URP project)
     
    Last edited: Feb 23, 2023
  2. burningmime

    burningmime

    Joined:
    Jan 25, 2014
    Posts:
    845
    How many is "a lot"?

    In general, you should have some profiling results which show you what's the bottleneck. Often, the bottleneck will be on the CPU side with something like Mecanim (or propogating updates to the SMR transforms, which you can optimize through hierarchy compression). You might be able to optimize parts of this by moving the animation the GPU, but you'll be giving up a lot of workflow advantages by doing so, so it's not something to take lightly.

    If animation itself were my bottleneck, I'd first look into some of the new ECS animation stuff before trying to compress skinned animations into textures.

    (EDIT: Original post was unclear)
     
    Last edited: Feb 24, 2023
  3. halley

    halley

    Joined:
    Aug 26, 2013
    Posts:
    2,445
    Have you measured your performance with a Profiler, and know that this is the slowest part of your scene graph? If not, this is premature.

    Once you determine with measurement data that this is your bottleneck, is it the RENDERING, the ANIMATING, or the COMMANDING of all those NPCs? That will determine your next step.
     
  4. Zimaell

    Zimaell

    Joined:
    May 7, 2020
    Posts:
    409
    with a thousand simple (200 polygons per unit) models with animation, the fps drops to 12, with different optimization methods, it increases to a maximum of 15-18 fps.

    in tests with baked animation, even 10,000 similar ones give out 50-60fps, I think that obviously we need to go in this direction...

    Or are there other options

    (on scene up to 2000 NPCs)