RealDocs

UKismetRenderingLibrary::CreateRenderTarget2D

function Engine Blueprint Since 4.0
#include "Kismet/KismetRenderingLibrary.h"
Access: public Specifiers: staticUFUNCTIONBlueprintCallable

Description

Creates a new render target and initializes it to the specified dimensions, format, and clear color.

Caveats & Gotchas

  • This allocates a new UObject and GPU resource every call — creating one per frame (e.g. in Tick) will churn memory and cause hitches; create once and reuse via ClearRenderTarget2D or ResizeRenderTarget2D instead.
  • The returned object is garbage-collected like any other UObject; hold a strong reference (e.g. a UPROPERTY) or it can be collected while still bound to a material.
  • bSupportUAVs must be true if you intend to write to the target from a compute shader; leaving it false and doing so will fail silently or assert depending on platform.

Signature

static UTextureRenderTarget2D* CreateRenderTarget2D(UObject* WorldContextObject, int32 Width = 256, int32 Height = 256, ETextureRenderTargetFormat Format = RTF_RGBA16f, FLinearColor ClearColor = FLinearColor::Black, bool bAutoGenerateMipMaps = false, bool bSupportUAVs = false);

Parameters

Name Type Description Default
WorldContextObject UObject* Object used to resolve the current world.
Width int32 Width of the new render target in pixels. 256
Height int32 Height of the new render target in pixels. 256
Format ETextureRenderTargetFormat Pixel format of the render target. RTF_RGBA16f
ClearColor FLinearColor Default clear color used when the target is cleared. FLinearColor::Black
bAutoGenerateMipMaps bool Whether mips are generated automatically after rendering. false
bSupportUAVs bool Whether the render target's resource supports unordered access views for compute shader writes. false

Return Type

UTextureRenderTarget2D*

Example

Create and store a render target C++
UTextureRenderTarget2D* RT = UKismetRenderingLibrary::CreateRenderTarget2D(this, 512, 512, RTF_RGBA8, FLinearColor::Black);

Version History

Introduced in: 4.0

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.