Allegro.cc Forums » Programming Questions » Is it possible to acheive "screen" blending with al_set_blender()?

 Is it possible to acheive "screen" blending with al_set_blender()?
 Tumlee Member #15,061 April 2013 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?
 Edgar Reynaldo Member #8,592 May 2007 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*drr = 0 + sr + dr - sr*drsor = sr(1 - dr) + drorr = sr + dr(1 - sr)So, use al_set_blender(ALLEGRO_ADD , ALLEGRO_INVERSE_DEST_COLOR , ALLEGRO_ONE);oral_set_blender(ALLEGRO_ADD , ALLEGRO_ONE , ALLEGRO_INVERSE_SRC_COLOR);That should get you your 'screen' blending back. Elizabeth Warren for President 2020! | Modern Allegro 4 and 5 binaries | Allegro 5 compile guideKing Piccolo will make it so
 Tumlee Member #15,061 April 2013 Thank you very much! It's amazing how I can pass calculus and then trip over my own feet on basic algebra.
 Arthur Kalliokoski Second in Command February 2005 It takes constant practice to maintain. “Throughout history, poverty is the normal condition of man. Advances which permit this norm to be exceeded — here and there, now and then — are the work of an extremely small minority, frequently despised, often condemned, and almost always opposed by all right-thinking people. Whenever this tiny minority is kept from creating, or (as sometimes happens) is driven out of a society, the people then slip back into abject poverty. This is known as "bad luck.”― Robert A. Heinlein
 Go to: Allegro Development Installation, Setup & Configuration Allegro.cc Comments Off-Topic Ordeals The Depot Game Design & Concepts Programming Questions Recent Threads