Custom blend mode? A=max(As, Ad)?

100 views
Skip to first unread message

Jona

unread,
Apr 21, 2021, 3:21:28 PM4/21/21
to skia-discuss
I'm trying to achieve the following blend mode:
A=max(As, Ad)

I did achieve this using lighten blend mode and then applying a color filter to swap one of the color channel as the alpha channel. However, this did loose the alpha channel which holds the anti-alias of the shape drawn.

How could I achieve such blend mode? How could I build my own blend mode?

Any help or direction would be greatly appreciated!
- Jona

John Stiles

unread,
Aug 23, 2021, 3:19:01 PM8/23/21
to skia-discuss
Sorry for the late reply, but if you are still looking for a solution here, Runtime Effects now supports authoring a custom blend function. You can write a simple runtime blend function which returns max(src, dst) and apply it to your SkPaint.
Check out SkRuntimeEffect::MakeBlender().
This tech is very new (it didn't exist yet in April when you posted this!) but it should be a very good fit for this.

Reply all
Reply to author
Forward
0 new messages