Unfortunately, there isn’t a direct replacement for InvalidationBox::CacheRelativeTransforms in UE 5.6. That flag was deprecated around UE 4.24 and completely removed in UE5. The behavior it provided, where child draw elements were cached and only transform deltas applied during movement, has been reworked and is now automatically handled by the Slate invalidation system. The new bCanCache variable in UInvalidationBox allows you to control whether the SInvalidationPanel widget caches its content.
If you’re seeing invalidation every frame when the camera moves, it may help to mark frequently updating widgets as Volatile. To mark a widget as Volatile, toggle the Performance > Is Volatile setting of the widget in the widget’s Details panel. There is additional info about the Invalidation system in the documentation here.
Thanks Francisco. We have implemented what you suggested, and it gives a good speed bump.
However the problem is that whenever the player moves the camera, the widgets’ onscreen positions change which forces an invalidation for the entire hierarchy. So performance is fine unless the player rotates the camera (which is all the time), then the FPS drops significantly.
For context, the widgets in question are MMO-style nameplates appearing above other players and NPCs. There can be hundreds of them onscreen at any given time.
From what I’ve been reading, it sounds like CacheRelativeTransforms is exactly what we need to solve this. Can you recommend an alternative? Or maybe it would be best to implement that behavior on our own?
You’re right, a similar implementation to CacheRelativeTransform would help your case. Unfortunately, that exact behavior was deprecated/removed and reworked but you could implement a similar behavior by taking the old approach into consideration.
const FMatrix2x2& RenderTransformMatrix = AllottedGeometry.GetAccumulatedRenderTransform().GetMatrix();
const FMatrix2x2& LastRenderTransformMatrix = LastAllottedGeometry.GetAccumulatedRenderTransform().GetMatrix();
// If the container we're in has changed in the rotation matrix
if (RenderTransformMatrix != LastRenderTransformMatrix)
{
return true;
}
When bCacheRelativeTransforms was enabled, the comparison was done on the render transform matrices via GetMatrix(). This logic was removed in UE 4.24.
For more context, here is the commit that introduced the change.