Outline sprite shader on 2d particles system

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

Is it possible to apply/make outline sprite shader (like one in 2d shaders demo) on 2d particles system? Not on individual particles but on the whole of the particles emited (whole system). Like in the image below.

I think it could be possible for each emitter, look at the glass bubbles demo structure to see how to apply it.

Or maybe having the particles on its own canvas layer you can make a full screen shader that affects only these nodes.

eons | 2017-02-04 20:17

:bust_in_silhouette: Reply From: Zylann

If you want a shader to produce this outline, you need to render the particles on its own offscreen viewport, then draw it in the game world using a ViewportSprite that has a CanvasItemMaterial and the outline shader.

The reason why is that the shader needs to access pixels from the final result, not individual particles as they are drawn.

Another idea would be to have the particle system draw twice: once where particles are a bit scaled up and coloured differently, and a second time normally, over previous ones. On circular and square particles it would work and produce an outline without shader, but I don’t think particles allow this without C++ modification.

Thanks again Zylann!!! I think that your first suggestion is approach that I will try to implement as it seems straighforward one.

pospathos | 2017-02-05 00:36

I had tried your first suggestion and it works like a charm. Thank you! :slight_smile:

pospathos | 2017-02-05 01:31

Hello, can you describe how you did that? I want to achieve the same effect but I’m not sure about how to draw on a offscreen viewport and all that stuff.

Hephep | 2019-07-19 12:19