-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathFICCaptureCamera.cpp
More file actions
75 lines (63 loc) · 2.95 KB
/
FICCaptureCamera.cpp
File metadata and controls
75 lines (63 loc) · 2.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#include "Runtime/FICCaptureCamera.h"
#include "CineCameraComponent.h"
#include "FGGameViewportClient.h"
#include "FGSettings.h"
#include "Blueprint/GameViewportSubsystem.h"
#include "Components/SceneCaptureComponent2D.h"
#include "Components/WorldPartitionStreamingSourceComponent.h"
#include "Engine/Engine.h"
#include "Engine/TextureRenderTarget2D.h"
#include "Settings/FGUserSetting.h"
AFICCaptureCamera::AFICCaptureCamera() {
SetRootComponent(CreateDefaultSubobject<USceneComponent>(TEXT("RootComponent")));
StreamingSource = CreateDefaultSubobject<UWorldPartitionStreamingSourceComponent>(TEXT("StreamingSource"));
CaptureComponent = CreateDefaultSubobject<USceneCaptureComponent2D>(TEXT("CaptureComponent"));
CaptureComponent->AttachToComponent(RootComponent, FAttachmentTransformRules::KeepRelativeTransform);
RenderTarget = CreateDefaultSubobject<UTextureRenderTarget2D>(TEXT("RenderTarget"));
RenderTarget->TargetGamma = 1;
RenderTarget->InitCustomFormat(100, 100, PF_R8G8B8A8, false);
RenderTarget->bGPUSharedFlag = true;
CaptureComponent->TextureTarget = RenderTarget;
CaptureComponent->bCaptureEveryFrame = false;
CaptureComponent->bCaptureOnMovement = false;
CaptureComponent->bUseRayTracingIfEnabled = true;
CaptureComponent->bAlwaysPersistRenderingState = true;
//CaptureComponent->PrimitiveRenderMode;
//CaptureComponent->CaptureSortPriority;
//CaptureComponent->DetailMode = EDetailMode::DM_Epic;
//CaptureComponent->MaxViewDistanceOverride;
//CaptureComponent->CachedLevelCollection;
CaptureComponent->CaptureSource = ESceneCaptureSource::SCS_FinalColorLDR;
//CaptureComponent->CaptureSource = ESceneCaptureSource::SCS_SceneColorHDR;
if (GEngine) CaptureComponent->ShowFlags = *GEngine->GameViewport->GetEngineShowFlags();
// Kinda performance intense
CaptureComponent->LODDistanceFactor = 0.01;
CaptureComponent->PrimitiveRenderMode = ESceneCapturePrimitiveRenderMode::PRM_RenderScenePrimitives;
}
void AFICCaptureCamera::SetCamera(bool bEnabled, bool bCinematic) {
if (Camera) {
Camera->DestroyComponent();
Camera = nullptr;
}
if (bEnabled) {
if (bCinematic) {
Camera = NewObject<UCineCameraComponent>(this);
} else {
Camera = NewObject<UCameraComponent>(this);
}
Camera->AttachToComponent(RootComponent, FAttachmentTransformRules::KeepRelativeTransform);
}
}
void AFICCaptureCamera::UpdateCaptureWithCameraData(UCameraComponent* InCamera) {
if (!InCamera) InCamera = Camera;
SetActorLocation(InCamera->GetComponentLocation());
SetActorRotation(InCamera->GetComponentRotation());
FMinimalViewInfo ViewInfo;
InCamera->GetCameraView(0, ViewInfo);
CaptureComponent->SetCameraView(ViewInfo);
CaptureComponent->PostProcessSettings.AutoExposureSpeedDown = 100.0f;
CaptureComponent->PostProcessSettings.AutoExposureSpeedUp = 100.0f;
CaptureComponent->PostProcessSettings.bOverride_AutoExposureSpeedDown = true;
CaptureComponent->PostProcessSettings.bOverride_AutoExposureSpeedUp = true;
CaptureComponent->PostProcessBlendWeight = 1.0f;
}