In my project, I’m trying to design a material that will only display when viewed through a particular window frame (almost like a portal effect). To do this, I am dynamically calculating a custom view frustum based off of the player’s camera position and empty actors placed at the corners of the window frame to define the edges. I want to use opacity masking to set the material up so that, at each pixel, if it is within the bounds I have set (on the correct side of each of the four planes), then it will draw; if not, it will be masked.
Please note that, due to technical limitations in the project, I cannot use Render Textures or any Post Processing effect (like Custom Render Depth) to achieve similar results.
I am calculating the planes in the level blueprint like so:
Then, I am passing that information to the material using a global Material Parameter Collection, and setting up the opacity mask like this:
However, the material is not behaving correctly, and is giving me anomalous results that I can’t quite understand. I’ve tried splitting up the planes individually to observe their behavior, and each seems to be failing in a different, inconsistent manner. Using various debugging tests, I can confirm that the planes are calculating correctly for exactly what I want, so I know that my math checks out (the result of the dot product should be positive if it’s on the side of the plane that I want, and negative if it’s on the other side). I’m starting to suspect that the data somehow isn’t getting parsed properly when it gets passed to the material, but I’m frankly not familiar enough with the Material Editor to understand what’s happening.
Can anyone help me understand how to make this work properly, or spot anything I’m missing? Any help you can provide would be greatly appreciated. Thanks!