Just like the question says. Is it possible to selectively set the value of the stencil buffer based on a property of a vertex, like the value of its normal, during its vertex processing phase? Instead of setting for all fragments of the model. Basically I want to detect the edges of my model by using variation in vertex normals and use them to set the stencil values in the corresponding fragments for some special effects
Asked
Active
Viewed 192 times
4
-
I don't quite get what you mean. If you compute a value per vertex it will get interpolated over the surrounding triangles. Do you want each triangle to get a different stencil value, computed from its vertex normals somehow? In any case, outputting to the stencil buffer from a shader is not widely supported (though it can be done with [this extension](https://www.opengl.org/registry/specs/ARB/shader_stencil_export.txt)) , so you probably want to use a regular offscreen render target instead. – Nathan Reed Sep 14 '16 at 16:09