Additive blending with alpha channel
3c1u opened this issue · comments
Hi, I'm using Piston for my game development and I thought that adding a blending mode such as "Screen" like in Photoshop will be convenient.
I've tried Blend::Add
and it was disappointing because it doesn't handle alpha channel, whereas lighter
mode in CanvasRenderingContext2D::globalCompositeOperation
(JavaScript/HTML5 Canvas) does. I modified the graphics
crate (3c1u/gfx_graphics and 3c1u/graphics) to replicate this as Blend::Screen
.
I drew rgba(0, 0, 255, 0.5)
(left) and rgba(0, 0, 255, 1.0)
(right) over rgba(255, 0, 0, 1.0)
and the following images are the results.
top: lighter
(HTML5 Canvas), bottom: Blend::Screen
(modified Piston)
top: lighter
(HTML5 Canvas), bottom: Blend::Add
(unmodified Piston)
Is it possible to add this feature to Piston, as well as other graphic backends?
Yes! Can you make a PR?
Renamed to Blend::Lighter
(because it was actually different from "Screen" from Photoshop) and made a PR (PistonDevelopers/graphics#1131). Thank you.