RealDocs

UKismetRenderingLibrary::ClearRenderTarget2D

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

Description

Clears the specified render target with the given ClearColor, filling every pixel.

Caveats & Gotchas

  • Marked UnsafeDuringActorConstruction — calling it from a construction script can crash or silently no-op; do it at BeginPlay or later instead.
  • If TextureRenderTarget is null, the call is a no-op rather than a crash, but nothing is cleared.
  • The clear happens via a render command enqueued to the render thread, so the visible result isn't guaranteed to be visible until the next frame is rendered.

Signature

static void ClearRenderTarget2D(UObject* WorldContextObject, UTextureRenderTarget2D* TextureRenderTarget, FLinearColor ClearColor = FLinearColor(0, 0, 0, 1));

Parameters

Name Type Description Default
WorldContextObject UObject* Object used to resolve the current world.
TextureRenderTarget UTextureRenderTarget2D* The render target to clear.
ClearColor FLinearColor The color to fill the target with. FLinearColor(0, 0, 0, 1)

Return Type

void

Example

Clear before drawing C++
UKismetRenderingLibrary::ClearRenderTarget2D(this, MyRenderTarget, FLinearColor::Black);
UKismetRenderingLibrary::DrawMaterialToRenderTarget(this, MyRenderTarget, MyMaterial);

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.