Multiple World - SceneCaptureComponent

Hi,
I’m currently trying to instantiate a separate world, and add an USceneCaptureComponent2D to it.

I try to create the new world like so:

    UPackage *WorldPackage = FindPackage(nullptr, *LevelName);
    if (WorldPackage == nullptr)
    {
        WorldPackage = LoadPackage(nullptr, *LevelName, LOAD_None);
    }

    UWorld *NewWorld = UWorld::FindWorldInPackage(WorldPackage);

    FWorldContext &WorldContext = GEngine->CreateNewWorldContext(EWorldType::None); // ?
    WorldContext.SetCurrentWorld(NewWorld);
    NewWorld->WorldType = WorldContext.WorldType;
    NewWorld->SetGameInstance(WorldContext.OwningGameInstance);

    NewWorld->InitWorld();

    FURL URL;
    NewWorld->InitializeActorsForPlay(URL);
    NewWorld->BeginPlay();

Iterating over the Actors in the newly created world yields that all the actors of the level to load are present.
The actor that holds the capture component also gets ticked as it should.

The problem that i encounter is, that bCaptureEveryFrame does not result in the capture components UpdateContent() to be called.
This is because the capture components MarkedForEndOfFrameUpdateState is wrong.

When calling UpdateContent() manually in my actors Tick(), it gets rendered, but the render target is still black.

any hints and

Update

I noticed that void USceneCaptureComponent2D::UpdateDeferredCaptures( FSceneInterface* Scene ) is not called for NewWorld, since there is no window rendered for it.

Calling UpdateDeferredCaptures() explicitly in my actor’s Tick() function, results in the scene captures in NewWorld for which bCaptureEveryFrame = true being rendered.
However, the corresponding render targets are still black.

void AMyActor::Tick(float DeltaTime)
{
    // ...

    // Improvised code to force update of capture components...
    NewWorld->SendAllEndOfFrameUpdates();
    USceneCaptureComponent2D::UpdateDeferredCaptures(NewWorld->Scene);
}

Any hints or ideas are appreciated.

Did you ever get this working?

No not directly… I ended up just using a single world and instancing a level multiple times in the same world.
Then, for each USceneCaputureComponent I specified light sources and geometry that should be visible to that specific USceneCaptureComponent.

In retrospective I would add the following:
While implementing the required functionality for the above aproach, I noticed that the USceneCaputreComponents are rendered when the “window”/“viewport” associated to the world gets rendered. Note that there currently is no “window”/“viewport” assigned to my world.
However, It is possible to invoke the rendering of the capture components manually from the game thread:

		GetWorld()->SendAllEndOfFrameUpdates();
		USceneCaptureComponent2D::UpdateDeferredCaptures(GetWorld()->Scene);

I guess that this should solve the original issue.