Write Shader Graph into Stencil for Render Feature

First of all, is it fine to ask the same question here after asking on Discord or is this annoying (already asked there but got no answer)?

I am working on a project that features notes, similar like post-its, as the game world. Here you can see a quick sketch of a couple of notes that form a pond. The pond itself is made in shader graph, so we can dynamically increase or decrease the water level (needed for some levels). Now I want to render a particle system of small bubbles inside the pond.

All notes use the same material with a texture array, but all meshes are their own mesh. Do you have any ideas how I could mask my particles? It’s easy to mask them by the water line, but I don’t know how to mask them for the water area. If I use a render feature for the meshes only the bubbles will also be visible outside of the pond (i.e. in the ground).

So the question at the end is (I think…): Can I write the blue area in the stencil buffer via shader graph and then use it in a render feature to mask my particles? And if so, how do I do that? :slightly_smiling_face:

(If it is important how the body of water is rendered: The shader graph uses the world position with slight noise added to Y, smoothstep and masking by the texture array to be rendered. This works for each note individually, but I need all texture masks in one big texture to mask my particles. Since the notes are 3D meshes (and change position) a flat 2D texture won’t do it).

image