Quantcast
Channel: Question and Answer » libgdx
Viewing all articles
Browse latest Browse all 434

GLSL 2D Silhouette

$
0
0

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:

Hyper Light Drifter Silhouette

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:

  1. Write the top layer to the stencil buffer
  2. Render the entities (silhouettes) within the stencil

Is this right? If anyone can enlighten me, it would be greatly appreciated!


Viewing all articles
Browse latest Browse all 434

Trending Articles