Using the Stencil in a Retainer Box material

Hello,

I’m trying to use the custom stencil buffer in the material of a retainer box but it doesn’t seem to work properly. The UVs used to fetch the stencil are broken (wrong scale and translation).

This can be seen in the repro project. It seems to be influenced by the screen percentage, the potential UI aspect ratio constraint and the Editor UI (the stencil viewport starts at the top left of the editor window).

Is it a known issue? I’m trying other UVs/Custom nodes to fix this issue without success.

Thank you

Steps to Reproduce

  1. Open the repro project
  2. Play In Editor in the default map
  3. The blue color doesn’t cover the cube
  4. The issue is worse if r.ScreenPercentage is not 100

Hey there! Sorry for the delay getting back to you. There’s quite a stack of issues when it comes to sampling the scene itself in UI materials. We’ve begun work on User Scene Textures, which can potentially help you pass through CustomStencil properly to UMG materials.

We’ve had a couple of questions come up about this over the years, and in [Issue with a Widget Containing and Image with Stencil [Content removed] my colleague goes into the whys of the issue.

More recently, the engineer behind User Scene Textures and I were chatting on [Problems Masking a UI/UMG material with CustomStencil (works in standalone, but not in [Content removed] about potential fixes and solutions.

I also highlighted the SceneTextureForUMG plugin on Fab as a potential avenue, although in the aforementioned EPS thread there were concerns about the performance impacts of their approach.

Thoughts?