Godot version: 4.4.1 (stable)
I am trying to achieve a specific effect involving how transparent textures are drawn over each other based on their alpha values. Specifically, I want sprites with higher opacity to completely overwrite lower-opacity ones in areas where they overlap, rather than blending.
In this image the regular behavior is shown, five circles with different alpha values are drawn. When they overlap, the result is standard alpha blending — the in-between areas blend smoothly.
In this second image MY intended behavior is shown, circles with higher opacity values overwrite the ones with lower opacity in the overlapping regions. There is no blending, only the topmost visible pixel remains.
This might seem counterintuitive to typical transparency rendering, but it is the intended effect I want to create. I have tried multiple methods. I looked into CanvasGroup, but it only helps when all alpha values are the same. I attempted a system using a SubViewport where I render each sprite in order from highest to lowest alpha. I also tried writing a shader that samples the previous texture and only draws pixels where the alpha of the previous layer is zero.
Despite trying these approaches, I could not get the full effect working. Either the masking fails or blending still occurs in some form. So, is there a correct way to implement this effect in Godot 4.x?
Ideally, I want a system where I can render multiple sprites into a SubViewport or similar, and have each sprite draw only on pixels that have not already been written to by a higher-opacity sprite. If this requires a specific shader or rendering technique, I would appreciate a clear explanation for example.
Please do NOT just link to documentation or another post without explanation I have already read much of the documentation, and context is what I’m missing.
Thank you, and sorry if this is a lot of details lol.





