Skip to content

BLEND_OVERLAY flag #2373

Open
Open
@itzpr3d4t0r

Description

@itzpr3d4t0r

Description

We've had an essential number of blend modes available for a long time, which are:
MAX MIN ADD SUB MULT
While these flags can be combined together to achieve more effects, it's not possible to achieve all possible blend modes, even some of the most basic ones.

I propose to add one more blend flag called OVERLAY (both RGB and RGBA) which is:

  • A very common blend mode present in most image editing softwares
  • Can help with creating masked special effects for colorization and achieve generally better contrasted results compared to MULT.

This is an example screenshot comparing the current blend flags with OVERLAY (all use the same "BASE" BW image and the same overlay color):

image
This is another example comparing with MULT and a colored base with the same overlay color:
image

While it's possible to achieve virtually any blend mode with surfarrays/numpy or even GPU shaders i strongly believe expanding on blend flags is a valid path, especially because it would:

  • Help achieve a wider range of effects in most CPU-based programs
  • Avoid the incovenience of using external libraries and write more complex programs
  • Not everyone with a big project could be willing to switch to GPU stuff because of the time required to switch

Technicalities

Implementing such blend flags includes implementing 6 functions internally, 3 for alpha and 3 non-alpha versions, for single pixel, SSE2 and AVX2 versions), not to mention tests to ensure the correct behaviour. This could lead to difficulties during the review phase since 6 functions would need to be checked individually since they're mostly selected at compile time. So for this very reason i was planning to implement these flags in 2 or 3 phases where either:

  • Only the single pixel and AVX2 versions are implemented first together and then the SSE2 version
  • The single pixel version first, then the SSE2 and then AVX2

Another thing that could simplify the review process is to only add the RGB version first and then the RGBA version in a followup PR.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions