Write on stencil ...

Hey community, for a post process effect purpose I need to write values on the stencil buffers. But not the same value for the whole mesh, I need to put one value for the faces that are in “front normal”, and another value for those that are in “back face” !
So my question is, Is it possible to write values on stencil or event post process input from a material ? And how ?
Thanks in advance !

In fact, I want to send the back face to the post process in any ways, is there any way of doing that ? With the post process inputs ?

Until Direct3D 11.3 (which might not be supported by all GPUs, even the latest D3D standard only makes this functionality optional) it is not possible to output custom values to the stencil buffer. There are certain fixed function operations like increment and replace, but they will be uniform for the entire draw call.

The stencil buffer is used for other things by the engine in the regular render passes, but you can enable custom depth/stencil drawing on a per-mesh component basis, and specify which stencil value it should write. Your best bet is to make one material that draws only front faces, and one that draws only back faces (or more simply, just make a copy of the mesh with its normals inverted), and give them different stencil values.

Yeah, I’ve though about that, I’ll try it, or find a better solution to my problem !
There is no way to get a custom buffer on Unreal or a custom texture that can be used in post process ?

You could do it in code fairly easily by allocating your own render target. If you are not that familiar with the engine it should be possible to do it in blueprint using a scene capture component, with a bit of finesse to get the camera variables right and draw the correct material.