|
|
This thread is locked; no one can reply to it.
|
1
2
|
| Lighting and Allegro 5 |
|
Myrdos
Member #1,772
December 2001
|
I just noticed something, you use the following tint when drawing the background: al_map_rgba_f(0.2, 0.2, 0.2, 1.0) But I had thought pre-multiplied alpha worked like so: al_map_rgba_f(r * alpha, g * alpha, b * alpha, alpha) Mark Oates: If you get that working with Allegro 5's graphics, you be sure to let me know. __________________________________________________ |
|
Trent Gamblin
Member #261
April 2000
|
Yeah, it does work like that. Alpha is 100%, you don't want to make the image transparent, just darker (and that was just so you can more easily see the light.) The .2 makes is 20% brighness. So it's 0.2*1.0 = 0.2.
|
|
Myrdos
Member #1,772
December 2001
|
That makes sense. __________________________________________________ |
|
Dario ff
Member #10,065
August 2008
|
I've used the method described by Mark multiple times. It works. TranslatorHack 2010, a human translation chain in a.cc. |
|
auamidium
Member #9,630
March 2008
|
Not sure how to do quotes, but I'm trying Mark Oates' idea right now with this code: 1al_draw_bitmap(testPng,0,0,0);
2
3 al_set_target_bitmap(lightLayer);
4 al_clear_to_color(al_map_rgb_f(0,0,0));
5 centered_draw_bitmap(lanternLight, 300,300,0);
6
7 al_set_target_backbuffer(display);
8
9 push_allegro_state(ALLEGRO_STATE_BLENDER);
10 al_set_blender(ALLEGRO_DEST_MINUS_SRC,ALLEGRO_ONE,ALLEGRO_ONE);
11
12 al_draw_bitmap(lightLayer,0,0,0);
13
14 pop_allegro_state();
Where I am trying to draw an 800x600 blank white space called lightLayer and draw lanternLight on top of it, which is just a black circle. I'm getting this (see attachment), in the image after blending, which I don't understand, since the edges of my lanternLight png square should have been mixed into the white of lightLayer. Also, a bit off topic, but I don't understand what states are used for. Is it that I can't blend anything without toggling some kind of blending-mode on/off? And do I need to make another buffer like in Allegro 4 if I can just use al_set_target_backbuffer and al_flip_display? Thanks Edit: I just noticed the space outside the black square is brighter than the should-be-lit space inside the circle. That would imply what I'm doing is completely faulty. Is there some understanding I am obviously missing by my codes? It'll be open source if I ever finish it. |
|
Mark Oates
Member #1,146
March 2001
|
You're clearing to black: al_clear_to_color(al_map_rgb_f(0,0,0)); You should clear to white: al_clear_to_color(al_map_rgb_f(1,1,1)); (or, just al_clear_to_color(al_color_name("white"));) [edit:] also, if you use bitmaps for (black) lights, they should be on a clear alpha backdrop, that way you can add multiple lights together correctly without overlapping another light. -- |
|
|
1
2
|