Render Stencil on top of other stencil?

Heya potential answerers.
So I’m trying to do something similar to how you can superimpose custom depth on top of postprocess0 but I want to have multiple layers to this.
For example I’d want one color in stencil 1 and another in stencil 2.
That much I can achieve, my problem is in wanting to superimpose one stencil on top of another.
For example I would want stencil 1 to superimpose over stencil 2 instead of the default behaviour which seems to use depth.

Is there something like multiple custom depth layers out there, or am I trying to do something impossible.

Thank you to any responders.

Edit: added visual example

For example here. I’d want green to render on top of blue and blue to render on top of red. And by extension green on top of red as well. In the image they are arranged by depth. Red < Blue < Green.
The final result im looking for would look like this
image
Although the depth would be the same.

The end goal is to have a sort of matrioska doll of spheres where each smaller sphere superimposes upon all the others.

the stencil buffer is like a data layer. it has 256 values. you can potentially do 256 layers. you just gotta increment or set the correct value and then filter them in the composite and render the different materials.

Ok so you’re saying its possible. Forgive me but I was never a natural at this stuff. How exactly would you filter a stencil layer to superimpose it over another stencil layer.
Thanks in advance if you take the time to help.