mirror of
https://github.com/nunuhara/xsystem4.git
synced 2026-09-30 02:48:14 +03:00
The multiply and screen blend functions used in render_flat_item ignored the source alpha, so transparent pixels still modulated the destination color instead of leaving it untouched. Add a draw_filter uniform to the parts fragment shader and have it output an alpha-baked source color, so that the framebuffer result after the GL blend equation interpolates correctly in alpha: - multiply: shader outputs src = mix(vec3(1.0), mod_color, alpha) blend (GL_DST_COLOR, GL_ZERO) gives src*dst, i.e. mix(dst, mod_color*dst, alpha) - screen: shader outputs src = mod_color * alpha blend (GL_ONE, GL_ONE_MINUS_SRC_COLOR) gives src + (1-src)*dst, i.e. mod_color*alpha + (1 - mod_color*alpha)*dst In both cases alpha=0 leaves the destination untouched, alpha=1 gives the full multiply/screen result. Also switch the surface-area mask from multiplication to discard, so pixels outside the rect leave the destination intact under multiply blending (where multiplying src by 0 would otherwise zero out dst).