Is there a possibility for SDL_BLENDMODE_MOD and SDL_SetTextureColorMod to actually ignore pixels from source texture which do have alpha set to 0?
The problem is following:
- Load any texture which has totally invisible pixels (alpha set to 0).
- Modulate that texture using SDL_SetTextureColorMod with a red color.
- Set blend mode of that texture to SDL_BLENDMODE_MOD.
The expected result as far as it goes for me would be modulating only visible pixels of the source texture (alpha > 0) and blending it into the screen. However, the current result is that the whole rectangle is modulated with a red color, even totally invisible pixels resulting in reddish modulation of the whole rectangle instead of only visible pixels.
I can solve that blending issue by using a custom blending mode such as:
SDL_ComposeCustomBlendMode(SDL_BLENDFACTOR_DST_COLOR, SDL_BLENDFACTOR_ONE_MINUS_SRC_ALPHA, SDL_BLENDOPERATION_ADD, SDL_BLENDFACTOR_DST_COLOR, SDL_BLENDFACTOR_ONE_MINUS_SRC_ALPHA, SDL_BLENDOPERATION_ADD);
However, that does not solve my problem as custom blend modes are only supported by hardware renderers while I wish to use the software one as well.
I did try to solve this issue by using a render target to which I first draw a base texture and then color modulated mask texture. This one actually works with one mask. I can easily draw that render target into the screen with SDL_BLENDMODE_BLEND later on, however, as soon as I try to modulate next masks within render target the base pixels and the previously modulated mask become black on every renderer.