The important thing is that all relevant stencil passes happen together and that the clip cap rendering happen last in those sets of stencil rendering. That demo has 3 clip caps that have to get rendered and in this order:
- Clip Plane Surface 1
-
4x2x stencil passes with render order1
- 1x clip surface as with render order
1.1
-
- Clip Plane Surface 2
-
4x2x stencil passes with render order2
- 1x clip surface as with render order
2.1
-
- Clip Plane Surface 3
-
4x2x stencil passes with render order3
- 1x clip surface as with render order
3.1
-
- Geometry surface color
- 1x geometry rendered with render order
6
- 1x geometry rendered with render order
After all the stencil passes we render the normal surface of the geometry. TBH the fact that that is rendered with render order 6 is not so important because it does not do anything with the stencil buffer. The geometry surface material is only rendered once though.