Creating an opaque silhouette is not a problem; rendering a mesh, you want to have a silhouette of, with a fragment shader that returns the color of choice, and a ZTest set to Greater with writing to depth buffer disabled will do the trick.
In layman’s terms…
When the 2D image that you see on your games screen is rendered from the 3D models, those 3D models are drawn one by one.
Those models are drown in their entirety, and as the new models get drawn they overlap, or end up behind, the models that are already drawn.
Every time a pixel is drawn to the screen it’s depth is compared to the pixel that is already on the same position, if there is one.
By the default, you want to draw the pixel only if it’s depth value is smaller, if it is closer to the “camera”, than the previous one; so that objects that are closer get drawn over the objects that are behind them, and vice versa.
If you flip that test, so that you draw when the pixel that is already at the same position is closer to the camera than the one that is trying to get drawn, and only change the color without touching the depth value, you’ll get the silhouette effect.
But that is the simple part of this problem, more complicated one is the transparency.
So if this silhouette is a model, as any other, standard alpha blending will do the trick?
Since drawing to the depth buffer is disabled, and the model is drawn in its entirety, pixels will overlap.
Final result for such attempt is disappointing.
My solution is not that complicated.
I’m rendering the opaque silhouette with the objects that can hide, in this case, main player character into a separate buffer.
Everything except the silhouette is unlit and white; I’m rendering it black, since the final result looks most natural, but it can be any color or texture.
This is how that buffer looks.
After I have it, I combine the main frame buffer with the silhouette one.
Everything that’s white gets ignored through the pixel shader, and the colored parts are added with transparency level of my choice.
The final result is a perfectly good looking silhouette, without any overlaps.
You can leave your opinion in the comment section of this post