# My UCanvasRenderTarget object only draws black shapes

**URL:** <https://forums.unrealengine.com/t/my-ucanvasrendertarget-object-only-draws-black-shapes/422516>\
**Category:** Rendering\
**Tags:** rendertarget, draw, canvas, unreal-engine, CPP, question\
**Created:** [April 13, 2018, 10:08am UTC](https://forums.unrealengine.com/t/my-ucanvasrendertarget-object-only-draws-black-shapes/422516 "2018-04-13T10:08:26Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![FrancescoDeso](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@FrancescoDeso](https://forums.unrealengine.com/u/FrancescoDeso)\
**Post date:** [April 13, 2018, 10:08am UTC](https://forums.unrealengine.com/t/my-ucanvasrendertarget-object-only-draws-black-shapes/422516/1 "2018-04-13T10:08:26Z")

</div>

I’m trying to use a UCanvasRenderTarget to draw some shapes into a texture that is a applied to a material, assigned to a simple plane mesh. It kinda works, except that everything I draw is always pitch black, like this:

 ![237327-render.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/2/1/a210f11aaf2924401b99e6f9686792c0c1a8a78b.png)

(the blue color is just the “clear color” I’m using for the render target).

This is what the code looks like:

```
void UMyObject::BeginPlay()
{
    Super::BeginPlay();

    // Creating my render target and binding the function that is called on draw
    mCanvasRenderTarget = Cast<UCanvasRenderTarget2D>(UCanvasRenderTarget2D::CreateCanvasRenderTarget2D(mOwner, UCanvasRenderTarget2D::StaticClass(), 4096, 4096));
    mCanvasRenderTarget->OnCanvasRenderTargetUpdate.AddDynamic(this, &UMyObject::DrawToCanvasRenderTarget);

    mCanvasRenderTarget->ClearColor = FLinearColor::Blue;

    // Forcing it to draw
    mCanvasRenderTarget->UpdateResource();

    // Skipping the part where I assing the render target to a material...
}

void UMyObject::DrawToCanvasRenderTarget(UCanvas* Canvas, int32 Width, int32 Height)
{
    // My "blue" rectangle, which is black
    FCanvasTileItem BlueBox(FVector2D(Width * 0.3f, Height * 0.3f), mCanvasRenderTarget->Resource, FVector2D(Width * 0.4f, Height * 0.4f), FLinearColor(0.0f, 0.0f, 1.0f));
    Canvas->DrawItem(BlueBox);
}

```

Even if I add “Canvas-\>SetDrawColor = FColor::Blue” before the DrawItem call, the rectangle is still black… what am I missing?
