Hello.
I’m using UCanvasRenderTarget2D to Draw some text and some texture in a canvas and then Create a texture that will be use for a material in the game. The problem I;m having is that I don’t know how to render the transparency of the texture as well.
When I have the material and the texture just in the material editor it Draws with transparency. Just like a normal material that has input pins from a Sprite.
CanvasRenderTarget = Cast<UCanvasRenderTarget2D>(UCanvasRenderTarget2D::CreateCanvasRenderTarget2D(GetWorld(), UCanvasRenderTarget2D::StaticClass(), 4096, 4096));
CanvasRenderTarget->OnCanvasRenderTargetUpdate.AddDynamic(this, &AMainCharacter::DrawToCanvasRenderTarget);
CanvasRenderTarget->UpdateResource();
if(MaterialToEdit){
myMaterialInstance = UMaterialInstanceDynamic::Create(MaterialToEdit, this);
myMaterialInstance->SetTextureParameterValue(FName("TextureMaterial"), CanvasRenderTarget);
gunDescMesh->SetMaterial(0, myMaterialInstance);
CanvasRenderTarget->UpdateResource();
}
void AMainCharacter::DrawToCanvasRenderTarget(UCanvas* Canvas, int32 Width, int32 Height)
{
//Drawing code with UCanvas goes here...
Canvas>DrawTile(myNewTexture,0,0,1024,1024,0,0,1024,1024,BLEND_Translucent);
}
iI’ve tried all combinations of blend mode on the DrawTile function (or DrawTexture). Lit or Unlit. It either draws the background black when is unlit or obviously shaded when is Lit.
I know the texture is not the issue because if I use it separately (manually) it does work with transparency.
Thank you