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

  • $\begingroup$ 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) , so you probably want to use a regular offscreen render target instead. $\endgroup$ – Nathan Reed Sep 14 '16 at 16:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.