Repository navigation
Playback optimization (SMH 3.0‐4.0)
GMod's systems, physics simulation, NPC logic, even some rendering, inherently runs single-threaded on your CPU. Stop Motion Helper tries to optimize playback as much as possible (see this thread). Nonetheless, playback performance is always limited by the bottleneck that is GMod. Regardless, if you render an animation to frames or use software to record a video out of the playback, you will playback an animation to preview how it all looks, and playback lag can be inconvenient in your animation process. This article will explain some ways to help increase playback performance.
This article contains the following sections
- Modifiers: reduce modifiers to improve performance
- Entities: reduce entity count and complexity to improve performance
- Miscellaneous: other performance tips that don't fit anywhere
SMH 3.0 introduced the timeline system, which enabled independent keyframing of modifiers: Physical Bones in Timeline 1 and Facial Flexes in Timeline 2. These not only increased animation complexity, but also allowed animators to select the modifiers that they wanted to record. We will use this information for the following details:
- SMH saves modifier data if the modifier can save it. If an entity can change colors or bodygroups, then the corresponding modifiers for color and bodygroups can store that data for animation.
- SMH loads any modifier data that the entity has, regardless if the modifier is visible on the timeline.
During playback, SMH has to iterate through all entity's modifiers and load them per frame. The more modifiers an entity contains, the longer SMH takes to process and load the modifiers. The longer SMH takes to process the frame, the longer GMod has to process that frame. Longer frame times mean lower framerates.
Hence, one can help improve playback performance by reducing the modifiers on an entity. Do the following:
- Determine which modifiers are important in your scene. If your character has a consistent color or bodygroup, you might not need these.
- Go to the properties menu and add a timeline.
- On the new timeline, check all the modifiers that you don't need (color or bodygroup)
- Close the properties menu and go to the timeline you just created.
- Remove all the keyframes from that timeline.
While less numbers always results in faster playback performance, it also helps to remove modifiers that take longer to process. In one case from developer experience, removing the material and submaterial modifiers consistently improves performance by 6 times on average.
To help with ensuring low modifier counts, you can create timeline presets. If you normally animate a human, you can create a timeline preset that only includes physical bones, nonphysical bones, eye target, and facial flex modifiers. These ensure playback performance is close to optimal.
Stop Motion Helper playback performance is always tied to the number of entities in a scene; more entities means more processing time. If you want to increase playback performance, reduce the entity count, or reduce modifier count per entity.
Even then, the number of entities might not be enough; the type of entity could matter. Assuming you have all modifiers checked, the following list orders the entity classes with respect to playback performance, in descending order.
- Physics props
- Scripted physics props (Advanced Lights, Advanced Camera, Ragdoll Puppeteer)
- Ragdolls
- Scripted ragdolls
- Ragdolls with cosmetics
- Scripted ragdolls with cosmetics
In general, physics props always win over the other entities because these typically have less (physics) bones versus other entities. When recording keyframes, SMH as a baseline only records physics bone transform, bone manipulations (nonphysical bones), and color and bodygroup data. Down the list, you either include more data to record, or more bones. More data to process means increased frame processing time.
The above is a general list; some cases may make other classes win over others. For instance, a ragdoll with two physical bones might be more performant than a physics prop with one physics bone and 255 nonphysical bones. You have to play the numbers game when it comes to animating an entity.
If you specialize only in animation, usually WYSIWYG. But if you have picked up a 3D modeling skill, you might be able to improve playback optimization by making an entity "animation-friendly." That usually involves a few questions to ask yourself:
- Would it be worth having at most 255 bones to process if one of the bones could be merged together?
- Is it worth including the entity into SMH if I can use another tool to move the entity (such as Animated Props)?
- Is it also worth adding jigglebones to a ragdoll so that I don't have to create keyframes for secondary motion?
Internal changes to a model or edits to an entity may be helpful to improving playback performance. If you need to preserve some details, you can also switch out between different models. For example, a close-up of a character might necessitate a highly detailed model with lots of bones, while other shots of the character can use lower detail. Creative ways to improve performance can help in the long run.
It might be of use to also show the bonemerge tools with respect to playback performance, in descending order:
- Easy Bonemerge Tool
- Composite Bonemerge Tool
- Advanced Bonemerge Tool
Easy Bonemerge Tool (EBT) is at the top because of its simplicity. GMod (Source Engine) handles the bonemerging underneath, so we would consider this as our baseline.
Composite Bonemerge Tool (CBT) could either perform better than Advanced Bonemerge Tool (ABT) or worst. It includes its own SMH support (sv_compositeentities_childboneediting), but SMH beta offers a more compatible route which allows you to animate bonemerged entities. Still, it offers more customization than EBT in terms of modifying position, rotation, or scale of bonemerged cosmetics, or having the cosmetic following a different bone.
ABT is at the low end of this list because of the amount of processing that it has to do on each frame of animation. In addition to the features that CBT has, it also includes compatibility for many different entity types (NPCs, Animated Props, etc.), which results in a higher degree of complexity. If an entity moves its limb, cosmetics bonemerged by ABT perform more processing in order to properly fit itself on the entity. ABT offers advbonemerge_sleep, a console variable which governs how long to wait before processing; this can help improve playback performance when testing an animation.
An alternative to animating multiple entities could involve not having all of the entities in the scene at the same time. For example, instead of animating a group of people all at once, you can render out individual parts of the crowd, with proper masks for depth sorting, and then place them in your compositing program. While this helps improve playback performance, the tradeoff tends to be more busywork.
In addition to the above methods, there are other ways to help improve playback performance.
- If you are previewing an animation in a laggy scene, you can reduce your graphics settings. Then during render time, you can set your graphics settings back to the standard used by you or your team.
- Animate entities one at a time. Then in the final render, load all entities into the same scene.