Hello,
As already mentioned in [Content removed]
Having dynamic shadows disabled on scene captures results in the VSM cache being invalidated each frame. Unfortunately, this behaviour still occurs in UE 5.6 EA.
In our project, we use `SceneCaptureComponent2D` as a mirror and cannot disable them. For performance reasons, shadows in the scene capture are only enabled on Epic Quality settings, having them enabled all the time is not a great option.
This puts us in a dilemma: either accept the performance cost of shadows or the performance hit caused by VSM cache invalidation.
After some investigation, we found a workaround that seems to consistently fix the VSM cache invalidation when our mirrors are active. In `FVirtualShadowMapArray::Initialize`, we pass a boolean flag to indicate if the current view is a SceneCapture. If so, we force the full initialisation logic to run—even when `bEnabled` is false.
modifications:
[Image Removed]
[Image Removed]
[Image Removed]
[Image Removed]
With these changes, we avoid the cache invalidation, resulting in ~2.4-2.6 ms `ShadowDepths` savings in our main render.
first trace, scene capture on, vanilla - 8.2 ms
[Image Removed]
first trace, scene capture on, with modifications - 5.8 ms
[Image Removed]
second trace, scene capture on, vanilla - 10 ms
[Image Removed]
second trace, scene capture on, with modifications - 7.4 ms
[Image Removed]
Although we have not detected any issues, I would appreciate your feedback on whether this modification could lead to any unforeseen problems.
Thanks!