Download

Masking material via intersection/overlap?

Here’s the idea, maybe someone can point me in the right direction:

I would like to choose some static mesh which specifies a three-dimensional shape. This shape overlaps various parts of the level geometry.

I need a function or some combination of functions (in a postprocess, probably) which returns white/1 for any rendered pixel which is inside of this shape, and black/0 for any pixel which does not.

Note that the shape ITSELF should not be returning white values; if the camera looks through it to pixels on the other side of it (but not INSIDE of it), they should appear normal. Effectively, it should “stain” the level geometry at all places where it intersects with objects, but NOT any vacant space within itself.

I know that you can get the absolute world position of a pixel, but I don’t know of any way of checking that location against some volume (the algorithms generally used in such calculations involve tracing through the point in question and counting the number of hits to determine if the point is inside of or outside of the material… and even if I could do such a thing in shader nodes, it would likely be ludicrously non-performant to calculate per-pixel.