I’ve made a very rudimentary system where I make a grid of points and each point fires a line trace (with bFindInitialOverlaps set to true). If a line trace hits, the value of the grid is set to 1, effectively creating a mask. All this works fine, but the image is at a resolution of 128 which obviously means thousands of line traces every frame (as long as the number of overlapping actors > 0) and thus lower FPS.
One alternative I’m thinking about is only fire two line traces for each column (so in this example that will be 128 * 2, as opposed to 128 * 128). Then I detect the hits for each object to find the points that are between the hits and therefore inside the object. However, multi line traces don’t register where they stop overlapping, and also don’t register if they overlap with the same object again later (if it’s a convex mesh, like a trace going through a foot and then hitting an arm).
Another idea that I had, but which I wouldn’t know how to implement, is based on what Ryan Brucks did for the volumetric effects in the Fortnite cinematic. He basically created four scene capture 2d components to render a mesh from all sides and then multiplied some result to create a volume texture. I would then only need a single slice of that volume. But again, I don’t know how to implement that, and if it can be done in realtime for any number of meshes within a small area.
At this point, I don’t know of any other solutions to create a mask where specific meshes overlap with the plane. The final result will have to basically be a 2D signed distance field in a compute shader that I have written. I then want to process it to create a mask that is used in the shader for computations as well as output to a texture that can be used in a material (similar to the image shows).
The only other solution I can see that could work, and may not be difficult to implement, is to fill an object with invisible particles (when Niagara becomes available, if it’s possible) and basically use the particle collisions to “paint” on a render target, using the draw to render target method.
EDIT: I wonder, based on the creative solutions for the work he did, could @RyanB give any suggestions?