13 #include "Components/SceneCaptureComponent2D.h"
14 #include "NVSceneCapturerUtils.h"
15 #include "NVTextureReader.h"
16 #include "Engine/TextureRenderTarget2D.h"
17 #include "NVSceneCaptureComponent2D.generated.h"
19 DECLARE_LOG_CATEGORY_EXTERN(LogNVSceneCapturerComponent2D, Log, All)
22 UCLASS(Blueprintable, ClassGroup = (NVIDIA), meta = (BlueprintSpawnableComponent),
23 HideCategories = (Replication, ComponentReplication, Cooking, Events, ComponentTick,
24 Actor, Input, Collision, PhysX, Activation, Sockets,
25 MobileTonemapper, PostProcessVolume,
26 Projection, Rendering, Transform, PlanarReflection, LOD))
34 typedef TFunction<void(const FNVTexturePixelData&)> OnFinishedCaptureScenePixelsDataCallback;
40 virtual void UpdateSceneCaptureContents(FSceneInterface* Scene)
override;
43 static FMatrix BuildProjectionMatrix(
const FNVImageSize& RenderTargetSize, ECameraProjectionMode::Type ProjectionType,
44 float FOV,
float OrthoWidth);
47 static FMatrix BuildViewProjectionMatrix(
const FTransform& ViewTransform,
49 ECameraProjectionMode::Type ProjectionType,
52 FMatrix& ProjectionMatrix);
55 static FMatrix BuildViewProjectionMatrix(
const FTransform& ViewTransform,
const FMatrix& ProjectionMatrix);
57 FMatrix GetProjectionMatrix()
const;
62 void CaptureSceneToPixelsData(UNVSceneCaptureComponent2D::OnFinishedCaptureScenePixelsDataCallback Callback);
64 UFUNCTION(BlueprintCallable, Category =
"Exporter")
65 void StartCapturing();
66 UFUNCTION(BlueprintCallable, Category =
"Exporter")
70 void BeginPlay()
override;
71 void EndPlay(
const EEndPlayReason::Type EndPlayReason)
override;
72 void TickComponent(
float DeltaTime,
enum ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
override;
75 virtual bool GetEditorPreviewInfo(
float DeltaTime, FMinimalViewInfo& ViewOut)
override;
79 void CaptureSceneToTexture();
86 void ReadPixelsDataFromTexture(OnFinishedCaptureScenePixelsDataCallback Callback);
88 bool ShouldCaptureCurrentFrame()
const;
89 bool ShouldReadbackPixelsData()
const;
91 void OnSceneCaptured();
92 void InitTextureRenderTarget();
97 UPROPERTY(VisibleAnywhere, Category =
"SceneCapture")
102 UPROPERTY(EditAnywhere, Category = "SceneCapture")
103 TEnumAsByte<ETextureRenderTargetFormat> TextureTargetFormat;
105 UPROPERTY(EditAnywhere, Category = "SceneCapture")
106 TEnumAsByte<EPixelFormat> OverrideTexturePixelFormat;
109 UPROPERTY(EditAnywhere, Category = "SceneCapture")
110 bool bIgnoreReadbackAlpha;