Quick answer: Render Targets persist across frames. Call UKismetRenderingLibrary::ClearRenderTarget2D before each draw to start fresh. The clear color comes from the function call, not the asset.
Here is how to fix Unreal Canvas Render Targets that accumulate drawings frame after frame, producing trailing or smearing artifacts. RTs do not auto-clear; you must explicitly clear before each draw cycle.
The Symptom
Per-frame drawings on a Canvas Render Target produce a trail or smear. Procedural maps fill up over time. Particle traces draw on top of previous ones forever.
What Causes This
RT persists. Unreal does not clear RTs between frames; you draw on top of last frame’s output.
Begin/End without Clear. Calling BeginDrawCanvasToRenderTarget without first clearing leaves prior content.
ClearColor on asset only at creation. The asset’s ClearColor is the initial state; subsequent drawings are not auto-cleared.
The Fix
Step 1: Clear before each draw cycle.
void AMyDrawer::Tick(float dt)
{
Super::Tick(dt);
UKismetRenderingLibrary::ClearRenderTarget2D(this, RT, FLinearColor::Black);
UCanvas* canvas; FVector2D size; FDrawToRenderTargetContext ctx;
UKismetRenderingLibrary::BeginDrawCanvasToRenderTarget(this, RT, canvas, size, ctx);
canvas->DrawText(GEngine->GetSmallFont(), TEXT("Hello"), 10, 10);
UKismetRenderingLibrary::EndDrawCanvasToRenderTarget(this, ctx);
}
Step 2: For accumulating effects, do not clear. Trail effects, paint maps, accumulating heatmaps are intentionally non-clearing. Skip ClearRenderTarget2D and accept persistence.
Step 3: Use UpdateResource if reset is needed.
RT->ClearColor = FLinearColor::Transparent;
RT->UpdateResourceImmediate(true); // resets to ClearColor
Equivalent to manual clear; the RT’s ClearColor is used.
Step 4: For SceneCapture2D, set CaptureSource appropriately. SCC captures the scene each frame implicitly. Set bCaptureEveryFrame = true for continuous; false for manual control via CaptureScene().
Step 5: Test on the actual surface. Apply the RT to a material and view in PIE. The RT’s state per frame is what you see. If trails appear unexpectedly, check the clear call.
“Clear, then draw. Or skip clearing if you want trails. Render Targets persist by design.”
Related Issues
For Niagara on RT, see Niagara Not Rendering. For decal rendering, see Decal on Translucent.
ClearRenderTarget2D each tick. Begin/Draw/End. The trails clear.