Download

Dynamic Camera Blending

I’m trying to figure out how to get render targets for an active camera.

I have a dynamic camera system that moves itself with physics based on the current/desired size and position of actors on the visible screen. To determine actor size and position on screen, I use projections from world space to the local space of the camera. These projections use the standard FSceneView code that is floating all over the UE4 codebase:


FSceneViewFamilyContext ViewFamily(FSceneViewFamily::ConstructionValues(
         LocalPlayer->ViewportClient->Viewport,
         GetWorld()->Scene,
         LocalPlayer->ViewportClient->EngineShowFlags)
         .SetRealtimeUpdate(true));
 
FVector ViewLocation;
FRotator ViewRotation;
FSceneView* sceneView = LocalPlayer->CalcSceneView(&ViewFamily, /*out*/ ViewLocation, /*out*/ ViewRotation, LocalPlayer->ViewportClient->Viewport);

I need my screen projections for my dynamic camera to only ever use the POV from my dynamic camera. The issue comes up when doing view target blends from a static camera to my dynamic camera, where the dynamic camera is calculating a new position based on the current Viewport rather than his current view.

Looking at what I have to work with, I’ve determined I either need a way to grab a render target from the camera so I can feed that into the FSceneViewFamily::ConstructionValues or I need a way to perform projections directly from a given camera. Crawling through the source, I only see projection functions on 4 classes (UCanvas, FSceneView, AHud, FOrientedBox). It’s starting to look like I’ll have to write my own projection function for UCameraComponent.

EDIT What’s preventing me from writing my own projection function is I can’t find out how to get the camera projection matrix.

Any useful things I may have missed that could make this easier?

I’ve asked an answerhub questionon this.