Download

Applying a texture mask on a canvas

Hi again

I’ve been writing a minimap. Got it all working lovely and then went to test it with a friend (first time outside the editor) and it crashed.

Inside the editor I see this

So after much debugging (eg comment out lines, run, see if it crashes) I narrowed it down to my mask rendering code

The line of code I’d written to generate the mask is



const FVector2D CanvasSize(Canvas->SizeX, Canvas->SizeY);
if (VisibleAreaMask != NULL)
{
    FCanvasTileItem Mask = FCanvasTileItem(FVector2D::ZeroVector, VisibleAreaMask->GetRenderProxy(false, false), CanvasSize);
    Canvas->DrawItem(Mask);
}


Removing the DrawItem line gets me a non-crashy game

but leaves me with an ugly looking minimap.

What is the correct way to apply a texture mask to a canvas?

Thanks

Bangs head against table… How do I do this sort of thing outside the editor?

OK. More digging.

Found K2_DrawTexture

K2_DrawTexture takes a blend mode, so I can pass it BLEND_Masked. My game doesn’t crash when I do this, but the drawn texture is just black…

So I thought maybe the texture I’m using isn’t set up right. A bit more googling found this -

I think the opacity mask is the colour of the pixel being investigated, but what is the OpacityMaskClipValue?