Basically, I would like to make a diagram around a cube. For this I can use SCNTechnique, which has the following rendering passes:
- Usually visualize cubes, as well as write their occupied pixels to the stencil buffer.
- Rendering a little big cubes if they do not intersect with the stencil in the first pass.
The problem is that the documentation for stencils is SCNTechniquevery sparse, and I can’t determine exactly how to use it.
I have already successfully drawn outlines, first drawing larger outline cubes with the depth turned off, and then drawing normal cubes, and this works pretty well, however I would like to use stencils instead of other complications using this method.
In an attempt to get it to work using stencil buffers, my first pass stencilStateslooks like (how and why I think I need properties):
clear = YES
enable = YES
behavior:
writeMask = 1
function = always
The second pass is stencilStatesas follows:
clear = NO
enable = NO
behavior:
readMask = 1
fail = keep
pass = zero
There are quite a few other properties for stencil buffer behavior, but I'm not sure what I need and how to use them. I am also not sure if the stencil buffer should be specified as input or output for each pass?
Change 1: . Exactly what I am looking for for implementation is visualized by drawing a blue larger cube of the contour first without writing to the depth buffer:

- , , , , , , , !
2: , , OpenGL ( C) . , ( ), , , .
, :
glStencilFunc(GL_ALWAYS, 1, 0xFF);
glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
glStencilMask(0xFF);
glClear(GL_STENCIL_BUFFER_BIT);
, :
glStencilFunc(GL_EQUAL, 0, 0xFF);
glStencilMask(0x00);
, , , SCNTechnique.