I have a UMaterialInstanceDynamic
and a UCanvasRenderTarget2D
.
The UMaterialInstanceDynamic
works fine with AHUD::DrawMaterial
and SetBrushToMaterial
on a UMG UImage
.
Likewise UCanvasRenderTarget2D
works fine when I draw it with AHUD::DrawTexture
or SetBrushResourceObject
on a UMG UImage
.
However when I try to draw the UMaterialInstanceDynamic
to the UCanvasRenderTarget2D
it writes transparent pixels (I assume like FColor(0,0,0,0)
) to its rect:
void UMyObject::OnMyRenderTargetUpdate(UCanvas* Canvas, int32 Width, int32 Height)
{
Canvas->K2_DrawMaterial(MyMaterialInstanceDynamic,
FVector2D(0,0),
FVector2D(100,100),
FVector2D(0,0),
FVector2D(1,1));
// draws a transparent rect ???
}
Any idea why that would be? Can you not use dynamic material instances to draw to render targets?