I’m trying to render a silhouette of any entity behind foreground objects to indicate their position to the player. Here’s an example of what I want to achieve, from Hyper Light Drifter:

From what I’ve read online about GLSL and the ways I might be able to achieve this, the closest thing I can think of to achieve this would be to use the stencil buffer, which was also indicated in this question:
2D Hidden Object Silhouette Shader
I don’t quite understand how I can achieve this within LibGDX. Should I be using a vertex / fragment shader, or the native Gdx methods? This is my current rendering workflow:
Render Lower Tiled Map Layers
Render Entities
Render Upper Tiled Map Layers
From what I understand, I would have to:
- Write the top layer to the stencil buffer
- Render the entities (silhouettes) within the stencil
Is this right? If anyone can enlighten me, it would be greatly appreciated!