Alpha Bleeding explained

Posted on

Alpha bleeding investigation

Blending is a common technique to achieve partial-transparency of various things (UI, 2D and 3D models). In many cases it means that your texture has an additional channel, alpha channel, that determines how much each pixel is opaque.

But there is a trap — colors from fully transparent pixels (that you, by default, don’t see in usual 2D image viewers and editors) can still affect the final rendering output, because when rendering we do filtering that can average RGB colors from neighboring pixels. The way to fix these problems is alpha bleeding, which means that your transparent pixels also need some sensible RGB values.

I have written now a proper manual page about the “alpha bleeding”, what problem does it solve and how to actually use it.

Our castle-view-image, that is already bundled with CGE binary release, contains a ready menu item to do it.

Note that the issue is not specific to Castle Game Engine. It’s an effect of how the GPU is using alpha and averaging RGBA pixels, and it really affects all game engines that exist. But some engines hide it better than us right now 🙂 E.g. Unity does alpha bleeding for you automatically, during texture import, if you select Alpha is Transparency. In CGE, we do not (yet) have so trivial UI to do this.

Please support the engine development on our Patreon. It funds development of the engine, it means we have resources to add engine features that make it easier to use and we have time to document them properly!

Start the discussion at Castle Game Engine Forum