Is it possible to acheive "screen" blending with al_set_blender()?
I want to set a certain blending mode that I have used in previous games, called "screen" blending, which results in a color that is always at least as bright as the input colors, but is not the same as additive blending. More details about it can be found here.
Basically, I want the resulting color to be the following:
r = 1 - ((1 - sr) * (1 - dr));
g = 1 - ((1 - sg) * (1 - dg));
b = 1 - ((1 - sb) * (1 - db));
Is this at all possible using al_set_blender() or am I going to have to do this sort of stuff with my own code?
Rearrange your formula a bit to see which blender you need :
r = 1 - (1-sr)*(1-dr)
r = 1 - (1 -sr -dr +sr*dr)
r = 1 - 1 + sr + dr - sr*dr
r = 0 + sr + dr - sr*dr
r = sr(1 - dr) + dr
r = sr + dr(1 - sr)
So, use al_set_blender(ALLEGRO_ADD , ALLEGRO_INVERSE_DEST_COLOR , ALLEGRO_ONE);
al_set_blender(ALLEGRO_ADD , ALLEGRO_ONE , ALLEGRO_INVERSE_SRC_COLOR);
That should get you your 'screen' blending back.
Thank you very much! It's amazing how I can pass calculus and then trip over my own feet on basic algebra.
Thread #612797. Printed from Allegro.cc
It takes constant practice to maintain.