|
Blending mode for additive lighting |
Chris Katko
Member #1,881
January 2002
|
HURRY. A.CC IS FAST. ANSWER MY QUESTION. I draw all my tiles and then, I draw "light" rectangles for each tile with this blender: al_set_blender(ALLEGRO_BLEND_OPERATIONS.ALLEGRO_DEST_MINUS_SRC, ALLEGRO_ONE, ALLEGRO_ALPHA); In retrospect, I'm almost certain I didn't even need it. (I think I'm just inverting black and white.) What's the right one (or steps) for creating a lighting pass, where unless I draw "light" to this buffer, I get complete darkness? Should I have two separate buffers? A lighting buffer, and a tile buffer, draw to them both (allowing multiple lights) and then combine them at the end? I don't have relevant image examples but its like this left image: {"name":"Color_add_subtract_450.jpg","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/e\/4\/e43343cc13f700335b8b446467b03276.jpg","w":450,"h":339,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/e\/4\/e43343cc13f700335b8b446467b03276"} or maybe I should be using MULTIPLICATIVE lighting per this second image?: {"name":"2sHjXGr.png","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/d\/6\/d65454164423691dc730a10473ba13cb.png","w":1280,"h":1024,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/d\/6\/d65454164423691dc730a10473ba13cb"} Either way, the more I think about it, the more I believe I need a second lighting buffer, that is then combined together at the end. I wonder if shadows can be drawn the same way, or I should use a third pass / buffer for shadows? -----sig: |
Edgar Reynaldo
Major Reynaldo
May 2007
|
First draw a shadow mask buffer with additive lighting then draw your Shadow mask over your backbuffer with multiplicative blending. My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
Chris Katko
Member #1,881
January 2002
|
I read your post and it seems like techno babble. Then I read a few hours of articles and I come back and go "Hmm, yeah, basically." -----sig: |
princeofspace
Member #11,874
April 2010
|
For what it's worth, in my code it looks like this: [draw stage here] al_set_blender(ALLEGRO_DEST_MINUS_SRC, ALLEGRO_ONE, ALLEGRO_ONE); [draw shadows here] al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_INVERSE_ALPHA); [draw lighting here]
|
Edgar Reynaldo
Major Reynaldo
May 2007
|
Chris Katko said: I read your post and it seems like techno babble. Then I read a few hours of articles and I come back and go "Hmm, yeah, basically."
Mathematically, it's the only thing that makes sense. The multiply blender ; Additive lighting is the only thing that can make things lighter. princeofspace said: For what it's worth, in my code it looks like this: [draw stage here] al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_INVERSE_ALPHA); [draw lighting here]
How does the premultiplied alpha blender draw lights? By drawing partially opaque white? That works. My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
princeofspace
Member #11,874
April 2010
|
Yeah, for the pixel art games I make, it gives me the look I want. It also makes it easier (for me, anyway) for drawing primitives as dynamic lighting sources. To be honest, though, I wrote this code a while back, and don't remember why I came to this process. I think I read about I here on this forum! |
|