Ok, I tried something:
I reused the sample from @qq2315137135 to test it:
The PR adds two new properties to the highlight layer:
- stencilReference. Let’s you get the stencil value used by the layer, so you can factor it with your code
- numStencilBits. The number of bits the layer should use. It’s 8 by default, but if you set it to 2, for example, then you can use the lowest 6 bits of the stencil reference value for your own use.
PG : https://playground.babylonjs.com/?snapshot=refs/pull/17934/merge#00PM1W#54
Note that you have to enable the stencil buffer on the layer texture itself (generateStencilBuffer: true when you create the layer)!
Let me know if it can work for you.
