Record & Play Garment Cache
发布于:2024-11-21
Updated Records
Update Time | Updated Content | SDK Version | Content Search |
2023-11-07 | Add Pause Play Garment Cache, and Go on Play Garment Cache node | V1.6.0 | |
2023-01-12 | Support Load From Absolute Path | V1.3.0 | |
2022-12-06 | New Configuration Items: You can configure the garment cache to force single-thread use, reducing loading on other resources | V1.1.2 | |
2022-11-17 | New interface for Unload Garment Cache | V1.0.3 | |
2022-09-29 | Record & Play Garment Cache | V1.0.0 |
1、Preparation Work
First, you need to check ControlRuntimeModeInBlueprint in the editor, which will disable the Garment Cache configuration in the editor. RuntimeMode is set to GarmentSimulate mode by default.
Then, you need to get the Style3DComponent in the blueprint.
2、Generate Garment Cache
Step1. The StartRecordGarmentCache method is called in the blueprint.
After calling this method, the RuntimeMode will be set to GarmentCacheRecord.
Cache Name
Record Setting:
Cache Frame Rate: The number of frames recorded per second while the cache is generated.
Simulate Rate Scale: The scaling is relative to the normal play rate while the cache is generated.
Step2.The blueprint is called the StopRecordGarmentCache method.
If this method has never been called, the save will be automatically triggered at the end of the game run.
After calling this method, the RuntimeMode will be restored to GarmentSimulate.
3、Play Garment Cache
Step1. The Blueprint uses LoadGarmentCache. Garment caches must be loaded first and played later. It is also possible to load multiple caches at BeginPlay, and then play them on demand in the blueprint.
Cache Name
LoadingFinished
LoadSuccess
Message: If the loading was unsuccessful, the exact reason will be told.
New Configuration Items
Force Single Thread Load
For scenarios with many caches and long loading times, you can force a single thread load without generating to the main thread.
You can configure the load garment cache to force the use of a single thread to load slowly, reducing the consumption of loading on the resources of other threads.
Loading Absolute Path
In Make Style3DGarmentCacheLoadSetting
Check Load From Absolute Path
Absolute Path is filled with the local absolute path (cascading to the clothing folder)
In Load Garment Cache
Set the Cache Name
Unload Garment Cache
Attention: The garment cache in use cannot be unloaded.
Step2. After successful loading, use PlayGarmentCache.
Cache Name To Play
Make Style3DGarmentCachePlaySetting
Cache Play Rate Scale
Apply Play Rate Scale To Avatar
Return value CacheLoaded: If the play finds that the garment cache has not been loaded yet, the value returns false with failure to play.
Attention: There is currently no model information stored in the garment cache. To make the garment cache play consistent with the model animation, the model animation needs to be reset to match the cached animation.
Pause & Go on Play Garment Cache
Support to Pause Play Garment Cache and Go on Play Garment Cache.
Step3. Callback event when the play ends.
After playing, RuntimeMode will be restored to GarmentSimulate.
The garment cache callback event can be configured by binding to GarmenCachePlayEndEvent, as shown in the image below.
Step4. Call StopPlayGarmentCache if you want to stop the garment cache play earlier during the play process.
After stopping, the RuntimeMode will be restored to GarmentSimulate.
When stopped, the GarmenCachePlayEndEvent event is triggered.
Points for Attention
1. Adjust PoseFitting before Record Garment Cache
Firstly, set up the animation for the model so that the model's pose changes to the pose of the first frame of the animation, then call the PoseFitting.
2. Record a cache of the same duration as the animation
Configure the animation as an animated montage, and stop the recording cache at the end of the montage in the blueprint.
3. The first frame skips, when you start playing the garment cache
Check the Use Avatar Pose in Cache in the Make Style3DGarmentCachePlaySetting to apply the pose in the first frame.
4. Garemnt Cache Loop Transition Unsmoothness Issue
Set the Blend Time for Loop Start End in the Make Style3DGarmentCachePlaySetting to blend between the first and last frames of the loop.
5. Garment Cache Play is 1 frame faster than character animation
Blueprint Method 1(better)
Call the LoadingFinishedEvent, then connect Paly Animation and Paly GarmentCache.
Delay One Frame is not required to be checked in the Make Style3DGarmentCachePlaySetting.
Blueprint Method 2
Call the Dealy event (to allow time for loading garment cache), then connect Paly Animation and Paly GarmentCache.
In this case, you need to check Delay One Frame, because the end of Delay will cause a delay of one frame in the animation play.
6. No increase in frame rate Issue after garment cache stops
After the garment cache stops, it will automatically switch to simulation mode, when the frame rate is lower than garment cache play mode.
You need to manually set Runtime Mode to Garment Cache Play after stopping the garment cache.
7. Failed to load garment cache
Failed to load garment cache via the following blueprint
Reason:
The value passed to C++ by Load Setting is not the same as shown in the blueprint.
Solution:
Creating variables inside the blueprint and then loading them is no problem.