Can we make a line trace pass through masked portions of a material?

I want to set clickable zones on the screen from an alpha texture. White would be clickable (block the trace) and black would let the trace through (in this case for the “hit result under cursor”) to get blocked by other objects for other purposes.

I tried in a widget but since the image takes all the screen it is always considered hovered.

I tried with a plane in front of the camera with the alpha texture using screen-aligned UVs but the mask is not taken into account so the cube is completely blocking the trace.

I mostly want to know if it’s even possible!