I’m using custom depth and the stencil value seems to be always zero. The last time I used custom stencil was with 4.10 or 4.11 and it worked (didn’t test it with the same object) but I’m not sure at which point it stopped working.
Should I use some other technique (which I can in my case) or is there some user error on my side?
There is an option within Project Settings > Rendering > Postprocessing > Custom Depth-Stencil Pass > Enabled with Stencil. I believe this option was added in 4.12 release.
What this option does is creates the Depth Buffer immediately and the Stencil is available for read/write. Let me know if you have further questions or need additional assistance.
No worries, we tend to add a lot of new features within each new major release. It can be easy to overlook or miss some of them as the notes can be very lengthy as well.