Download

Reading pixel data from Cube Render Target

I’m attempting to get depths that have been rendered to a UTextureRenderTargetCube. The problem I’m facing is that I can only seem to get the bottom face of the cube. Ideally I’d be able to get the direction of the pixel and its depth for all directions.

Here’s a section of code I’ve been using to scan for min/max depths. The min and max I get are always the camera’s distance above the floor plane.



TArray<FLinearColor> SurfData;
FTextureRenderTargetCubeResource* Target =(FTextureRenderTargetCubeResource*)(CubeTarget->GameThread_GetRenderTargetResource());

for (int side = 0; side < 6; side++) {
    Target->ReadLinearColorPixels(SurfData, FReadSurfaceDataFlags(RCM_MinMax, (ECubeFace) side));
    for (int i = 0; i < Target->GetSizeXY().X; i++) {
        for (int j = 0; j < Target->GetSizeXY().Y; j++) {
            FLinearColor color = SurfData[j * Target->GetSizeXY().X + i];

           // ... Look for min/max in here...
        }
    }
}


Here’s the CubeTarget I’m reading from. It’s depth on the R channel.

[IMG2=JSON]{“data-align”:“none”,“data-size”:“full”,“src”:“https://forums.unrealengine.com/core/image/gif;base64,R0lGODlhAQABAPABAP///wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw==”}[/IMG2]​​​
For what it’s worth, the cube map does render correctly when used in a material with InteriorCubeMap.