Get Opacity mask from material in C++?

Hello,

Is there a way to get the opacity mask used by a material from C++?
I’m rendering on UPanelCanvas and I need to hide all of the UImage
objects that are underneath the zero opacity area.

So basically if I have a mask like the one illustrated above,
everything within the white area shall be rendered and everything
outside it, thus being in the black area shall not be rendered.

Am I missing something? Is there perhaps a better solution to it?

Thanks in advance.

P.S.: [forum link][2]

Hey Alisaxy-

The material class has an opacity mask variable that you can access publicly. If you have a material pointer, you can use this to get the opacity mask as necessary:

UMaterial* MyMaterial;
MyMaterial->OpacityMask;

Cheers

I’ve actually solved the problem without needing an opacity mask at all using UCanvasRenderTarget2D instead of UCanvasPanel. I imagine a need to mess around with FMaterialCompiler to get the data I need from the opacity mask and even then I wouldn’t be able to partially hide the panel slots outside the mask as it’s an all or nothing deal that way.

Nice to know still. :slight_smile: Thanks!

Ah, found why I couldn’t find it myself. :smiley: I was confused by UMaterialInstanceDynamic & UMaterial, they’re on different inheritance branches! I was always looking at the former, not the latter. Dang it! :slight_smile: Well, the best experience is gained from making mistakes. Dully noted!