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:
(the blue color is just the "clear color" I'm using for the render target).
This is what the code looks like:
// Creating my render target and binding the function that is called on draw
mCanvasRenderTarget = Cast<UCanvasRenderTarget2D>(UCanvasRenderTarget2D::CreateCanvasRenderTarget2D(mOwner, UCanvasRenderTarget2D::StaticClass(), 4096, 4096));
mCanvasRenderTarget->ClearColor = FLinearColor::Blue;
// Forcing it to draw
// 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));
Even if I add "Canvas->SetDrawColor = FColor::Blue" before the DrawItem call, the rectangle is still black... what am I missing?
Apr 13 '18 at 10:08 AM