Blendmode extensions

Hi, I’m realising the limitations in blend modes can make various visual effects quite cumbersome to get done, and was hoping there might currently be development on an official extension.

Something extensive, like the implementation in ex. SFML would makes things very convenient: https://www.sfml-dev.org/documentation/2.2/structsf_1_1BlendMode.php

As in SDL the keyword is Simple, SMFL seems to me to have too much cpabilities and more parameters, i.e. less simple.

But, yes, I wish an extension:
The SDL_BLENDMODE_BLEND alpha blending rule for the alpha channel
dstA = srcA + (dstA * (1-srcA))
has a drawback : dstA will acquire an alpha value less than 0xff (or less the initial dstA value) thus providing some artefacts if we superimpose multiple surfaces or multiple textures in this mode.

The simplest alternate blend mode will some blend with SDL_BLENDMODE_ADD mode, having

  • the same dstRGB rule as for SDL_BLENDMODE_BLEND i.e. dstRGB = (srcRGB * srcA) + (dstRGB * (1-srcA))
  • but with alpha rule: dstA = dstA like SDL_BLENDMODE_ADD.

Neverthless, I believe the followind dstA rule will be more convenient:
dstA = 255 - (255-dstA)*(255-srcA)/255
or considering 255 == 1.0 for better understanding (1.0= opaque, 0.0 = transparent):
dstA = 1.0 - (1.0-srcA)*(1.0-srcA)

Conceptually interesting would be a blend mode working like superiposed dias (slides),but this will be more complex, because of the R, G, B interdependance (soustractive effects ).