How to eliminate blending in custom draw

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By grognard3

I’m using custom drawing to draw semi-transparent circles around objects. But, because they are semi-transparent, when circles overlap their transparency is added together, making the ugly overlap in the picture, below. Is there any way to turn off this additive blending in custom drawing? I want the circles to merge seemlessly so that every point in the circle has the same transparency level.

Example Image

:bust_in_silhouette: Reply From: sash-rc

In other words you need to combine silhouettes and have resulting shape a uniform transparency?

If so, I’d suggest first draw merged circles with opaque colors to texture (like ViewportTexture), then draw that texture with transparency. Don’t know if this will impact performance significantly though.

Another approach is to use shaders and maybe depth-buffer.

Thanks for the suggestion! I’m having a little trouble figuring out the drawing to ViewportTexture, and I can’t seem to find the correct tutorial anywhere. Could you give me a little guidance on the process, or point me in the right direction? Thanks again!

grognard3 | 2021-06-27 22:27

Nevermind, I finally figured it out. I ended up needing to use a separate scene to draw the circles, then instancing that scene within a viewport node and mirror the texture of that viewport node onto a sprite, and then changing the transparency of that sprite. irritating, but functional :slight_smile:

grognard3 | 2021-06-28 01:40