Widget Custom Stencil Masking - Offset with render scaling

Hello, I am working on masking out some UI when any player is “in front“ of the UI.

The screen space widget uses a custom UI Shader that makes use of the Stencil Mask for masking. It works great when the render scale is at 100, but lower than that results in an offset between the mask and the actual UI.

I figured I could just scale it by the screen percentage but (and several other options) didn’t pan out.

Here is a debug I set up to try to figure it out.
r.ScreenPercentage 100

r.ScreenPercentage 50

Ahha! Looks like I just needed to set up an MPC and pass the screen percentage in manually. For some reason the screen percentage value in the shader graph is wrong.

Probably getting rendered at a different time since its a UI material.

To fix the issue with the shader I just created an MCP with a scalar value and assigned it the r.ScreenPercentage value from a console variable float.

It is worth noting that the mask is not upscaled so at low resolutions it gets pretty pixely.

ALSO! The default viewport will not work with this unless you full screen it! (hit f11). It seems to be a bug with the rendered area vs the window size.