How do I render into a stenciled area?

As described here (Stuck with PostProcess settings CustomStencil for maksing - Rendering - Epic Developer Community Forums) but I don’t seem to be getting any traction.

Summary:
My game uses ‘tiles’ that are dynamic, but I’d like to set up the water tiles so that instead of rendering as individual tiles of water they are invisible, set a stencil value of 1, and then have a single continuous water texture/material/object rendered into the stenciled pixels.

I can successfully set the water tiles to be invisible and set the stencil values, but after that point I’m lost. How do I get something to render into the stenciled area?

Any advice would be greatly appreciated.

Hi Mayobe,

You are close but there are a few things you are missing. Namely what is left is the material work. You need to set the material as a postprocess material. To utilize the stencil applied to your mesh you need to add a scene texture node then in its settings select “custom stencil”. What this node outputs is the literal value of the stencil applied. For example a cube mesh with a stencil value of one will appear solid white because it is returning one. A mesh with a stencil of 200 will glow like a white sun in the viewport because it will be drawn with the value of 200 (if you were to plug the stencil node into emissive color). The setup I have in the screen shot is very simple but should work for what you are describing.

I’m assuming you will only be using a stencil value of 1 so in this case the lerp will go from scene color (postprocessInput0) to the water texture sample. Just assign anything you want to have water drawn on it a stencil of 1.

Let me know if that helps,

I ended up using a different method, but I’ll play with this later to see if I can get it to do what I was thinking about. (One of my team members was also curious, so I’ll share it with him as well.)

Thank you.