Create dynamic mask within overlapping volume

I’m trying to create a material that will be masked by a particular overlapping volume.

Basically, I want to do this ( but instead of using a sphere mask, I need to dynamically create a mask based on an overlapping volume.

How would I approach this? I’ve been searching an answer to no avail. I’m working in blueprints. I need to somehow mask my material on a per-pixel basis based on current worldlocation overlap.



If when you say volume you mean a square/rectangular shape mask, then you could use a box mask.
If you are trying to mask based on some irregular complex shape of an overlapping mesh, idk.

In most instances, a box mask should work! So thanks for that, I think that is what I am looking for.

However, I can think of a least one instance where I am going to need an irregular shape; not that irregular, a pyramid and triangular prism. I anyone else has an idea, I’m all ears.

You can use both sphere/box mask with distance fields to create that mask. the precision will go as much details you decided to have on the object with distance field set.

Thanks, NilsonLima. I’ve never used distance fields…not finding very much for how I’d use them as a mask. Would I use the DistanceToNearestSurface node?

I’ve also run into a new (obvious) problem with BoxMask - I can only apply one at a time. Hadn’t thought of that :confused:

Here is what I am trying to accomplish:


I need a system to place doors and windows into a wall. I need to mask the visibility of the wall for each door/window cutout. I was thinking boxMask would at least work for square doors and windows, but am realizing I can only place a single mask per material (obviously!) - so am feeling stuck again.

My first thought is to add a bunch (50?) of boxMasks to the material the add them all together. That sounds like a major headache, though. (I’d need separate parameter collections for each window/door instance). Memory-wise, I can’t imagine that would be very efficient either.

Am I missing an obvious solution to this problem? What would be the best way to cut multiple holes in geometry dynamically?

You would need to create a small bp for each window and which one will have material instance references and also the window. The blueprint knows the mesh for the window and can provide the data for the object position and fed into the material. Give me some time to setup this and upload the small project.

Didn’t make it work as I was expecting either… I remember having a solution for this, I will have to dig among my stuff and see if I can find it.

does this need to happen at runtime? cause if not geometry brushes would be the way to go.

Thanks for trying! Please do post if you find something.

It’s not happening at runtime, but I am creating functionality within blueprints - so I need meshes.

hmm I’m going to list out a couple possible solutions all of which are beyond my knowledge of how to actually implement. I just think that they may work, and you can have a few new avenues to look into.

you could make a window by making a portal type effect, but instead of the portal going some distance it would just go to the other side of the wall. usually this is done with render targets, there is a gdc talk for the game ‘budget cuts’ where another method was explained for performance purposes. I didn’t understand it though…
This video I saved awhile back could be useful for you if you go with portal windows.
you could make procedural meshes, or along the same lines look into voxels.

this guy is either using a bunch of masks or found a way around having to do that. not sure but he said he would be doing a breakdown of the effect eventually.