#2D glow / bloom effect objects overlapping black

1 messages · Page 1 of 1 (latest)

trail copper
#

Hello everybody!

It's my first post, I hope I'm not making any mistake! 🤞
I searched for a while in this forum channel without finding anything about this.

I don't like to feel helpless and having to bother people like this, I always do my best to solve problems on my own, but I've been searching for days without finding a solution, so here I am. 😅
I followed a tutorial from Brackeys (and others, with the same approach) to make a glow effect on some tiles in my 2D world with shadergraph. The effect is looking very good, I just adjusted the settings a little to suit my needs. However, if everything looks good at first glance, something's wrong when two glowing objects overlap: the overlapping areas go black.

I understand the why, as it is making the objects transparent and the transparency adds up in the overlapping areas. But I'd like to find a way to prevent this.

I attached screenshots to illustrate my point. In the first, it's the raw lava, without any shader. Then, it's the glowing effect of the shader, with spaced tiles. The third image illustrates the issue I'm talking about, with overlapped tiles. Finally, the last is the best (kind of...) thing I could get by tweaking stencil and depth buffers settings. However, it seems more like the opposite of what I need, as it renders the farthest tiles first and doesn't render the overlapping parts of the one a bit closer.

I hope there is a solution to this, because it looks so much better with this effect, but if not, well, I'll have to give up on this. 🥲

Thank you very much in advance for your help!

long heart
#

The emission map typically wouldn't contribute to alpha, but in some situations you might want it to

#

Obviously for tile sorting to work correctly you'll want to avoid manually tweaking stencils or depth sorting, and with this fix you can avoid it

#

But note that adding to base color only works correctly with unlit sprites, not with lit sprites affected by 2D lighting as shown in the video, as adding doesn't introduce emission but multiplies incoming light however much or little of it there is