0

I am trying to take a Scene capture of an Unreal Project 5 Scene and send its pixel content to a compute shader to do some transformations on the rendered image. The goal of that shader would be to send a standard resolution and a high resolution image to the shader.

After some research, I came across USceneCaptureComponent2D that could be used to generate a Texture2D element that could be used to extract the pixel data from the image (https://www.reddit.com/r/unrealengine/comments/dwu3sf/get_output_in_pixels_from_camera/)

However, it appears that I cannot manipulate the Render Target since it has an incomplete type: error

Right now, on the TickComponent method, I am getting the user's camera and setting the scene capture camera view to the latest POV of the player's camera:

void UComputeShaderTestComponent::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
{
    Super::TickComponent(DeltaTime, TickType, ThisTickFunction);

    if (UWorld* World = GetWorld())
    {
        APlayerCameraManager* PlayerCameraManager = World->GetFirstPlayerController()->PlayerCameraManager;
        SceneCapture->SetCameraView(PlayerCameraManager->GetLastFrameCameraCachePOV());
    }
}

I was wondering if those changes were coming from UE5 and if so, is there a better way I can send all the pixels displayed on the screen to a shader?

Source code of the model I am using: https://github.com/mortmaire/Unreal-Engine-Access-Render-Target

Modules I am using in the Build.cs file:

PublicDependencyModuleNames.AddRange(new string[] {
            "Core",
            "CoreUObject",
            "Engine",
            "InputCore",
            "RenderCore",
            "RHI"
        });
    

The following post suggests it could be caused by a missing module in the above list. I tried adding Renderer and it did not work. Pointer to incomplete class type is not allowed Unreal Engine 4.26

Thanks!

vitonimal
  • 453
  • 7
  • 17
  • 1
    You probably need to include the header [`Engine/TextureRenderTarget2D.h`](https://docs.unrealengine.com/4.27/en-US/API/Runtime/Engine/Engine/UTextureRenderTarget2D/). – vandench Jan 26 '22 at 20:03
  • seems like it did it! Thanks ^^' Thought that the include that allowed me to use the type would do it all – vitonimal Jan 26 '22 at 20:14

0 Answers0