[investigation]
When SceneCapture2D uses the main renderer, it gets added to the CustomRenderPass based on what it captures.
// SceneCaptureRendering.cpp
// Func : FScene::UpdateSceneCaptureContents(USceneCaptureComponent2D* CaptureComponent)
// As optimization for depth capture modes, render scene capture as additional render passes inside the main renderer.
if (GSceneCaptureAllowRenderInMainRenderer &&
CaptureComponent->bRenderInMainRenderer &&
(CaptureComponent->CaptureSource == ESceneCaptureSource::SCS_SceneDepth || CaptureComponent->CaptureSource == ESceneCaptureSource::SCS_DeviceDepth ||
CaptureComponent->CaptureSource == ESceneCaptureSource::SCS_BaseColor || CaptureComponent->CaptureSource == ESceneCaptureSource::SCS_Normal)
)
{
// ... other things...
AddCustomRenderPass(nullptr, PassInput);
}
In AllViews, the FViewInfo from CustomRenderPassInfos is added after the original FViewInfo of the main renderer.
// SceneRendering.cpp
// Func : FSceneRenderer::FSceneRenderer(const FSceneViewFamily* InViewFamily, FHitProxyConsumer* HitProxyConsumer)
AllViews.Empty(Views.Num() + NumAdditionalViews);
for (int32 i = 0; i < Views.Num(); ++i)
{
AllViews.Add(&Views[i]);
}
for (FCustomRenderPassInfo& PassInfo : CustomRenderPassInfos)
{
for (FViewInfo& View : PassInfo.Views)
{
AllViews.Add(&View);
}
}
The visibility tasks are processed sequentially using a for loop, so the viewInfo added by CustomRenderPass is processed afterwards. As a result, the ViewInfo that comes later ends up being used as the final one.
// SceneVisibility.cpp
// Func : void FVisibilityTaskData::LaunchVisibilityTasks(const UE::Tasks::FTask& BeginInitVisibilityPrerequisites)
for (int32 ViewIndex = 0; ViewIndex < Views.Num(); ++ViewIndex)
{
// Each view gets its own visibility task packet which contains all the state to manage the task graph for a view.
FVisibilityViewPacket& ViewPacket = ViewPackets.Emplace_GetRef(*this, Scene, *Views[ViewIndex], ViewIndex);
...
}
The View information is passed to SkeletalMeshSceneProxy and used for LOD calculation.
// SkeletalMesh.cpp
FPrimitiveViewRelevance FSkeletalMeshSceneProxy::GetViewRelevance(const FSceneView* View) const
I want to use MainRenderer for SceneCapture due to optimization concerns.
To solve this issue, I’m trying to add a flag member to the FSceneView structure that determines whether it should be used for LOD calculations.
I found a value bUseFieldOfViewForLOD in FViewInfo, but it doesn’t seem to be used anywhere.
I would appreciate any advice regarding this issue.
Thanks.