UKismetRenderingLibrary::ReadRenderTarget
#include "Kismet/KismetRenderingLibrary.h"
Access: public
Specifiers: staticUFUNCTIONBlueprintCallable
Description
Reads the entire render target back as sRGB colors into a linear array, one entry per pixel, and returns whether the read succeeded.
Caveats & Gotchas
- • Described in engine source as "incredibly inefficient and slow" — this reads back the entire target from the GPU and stalls the calling thread; prefer calling it once rather than per-frame.
- • OutSamples is indexed row-major (Width * Height entries) — you must divide by the render target's own Width/Height to convert an index back to (X, Y).
- • If the read fails (e.g. invalid or zero-sized render target), the function returns false and OutSamples should not be trusted; always check the return value.
Signature
static bool ReadRenderTarget(UObject* WorldContextObject, UTextureRenderTarget2D* TextureRenderTarget, TArray<FColor>& OutSamples, bool bNormalize = true); Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| WorldContextObject | UObject* | Object used to resolve the current world. | — |
| TextureRenderTarget | UTextureRenderTarget2D* | The render target to read. | — |
| OutSamples | TArray<FColor>& | Receives one entry per pixel, each an 8-bit sRGB BGRA color, if the read succeeds. | — |
| bNormalize | bool | Whether HDR values are normalized/tonemapped before conversion to 8-bit color. | true |
Return Type
bool Example
Read back an entire heightmap render target C++
TArray<FColor> Samples;
if (UKismetRenderingLibrary::ReadRenderTarget(this, HeightmapRT, Samples, true))
{
const FColor& TopLeft = Samples[0];
} Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?