How to do a silhouette when players, npc, enemies, entites are behind an object

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Dava
:warning: Old Version Published before Godot 3 was released.

The title says it all, how do you do a silhouette form of your objects, especially when they’re behind other objects like rocks and trees, walls, etc

Need to mess with shaders. I don’t know much about it but there’s a tutorial in here.

mateusak | 2016-07-24 15:01

:bust_in_silhouette: Reply From: Leonard Meagher

I got this to work oddly enough by doing these things

  1. Create a mesh instance, and select “Use Alpha” in the Material options (or if you’re doing a shader use DIFFUSE_ALPHA, instead of just DIFFUSE)

  2. Create a mesh instance as a child of the above mesh instance, and set it to “On Top” (I recommend using the “create outline mesh” tool to do this, also setting “unshaded” to me makes it look nice)

If you’d like object an object to be in front of this effect, set it’s material to “use alpha” also

This is the way I found out how to hack around it, but I wouldn’t expect this to work everywhere, or to be supported after 3.0 but who knows

For the outline mesh, I set the Outline Size to 1, then scaled the resulting mesh to about 0.499, since the outline options don’t allow the size to be 0, and so there wasn’t any bits poking out.

Leonard Meagher | 2016-10-18 02:31

The reason I suspect this works, is because Juan has told me that the alpha pipeline renders objects slightly different, and the fact the child mesh isn’t rendered in that same way, probably has a heavy roll in why this works.

Leonard Meagher | 2016-10-18 02:35

:bust_in_silhouette: Reply From: eons

If 2D, your solution might be with light node and light mask (from CanvasItem), never played much with lights but with a quick test I was able to do this:

enter image description here

The left and right sprites are on different light mask, the center light2D affects only one of them.