|
|
| [A5] Motion Blur Effect |
|
tolgagerekci
Member #14,293
May 2012
|
I want to create motion blur effect with Allegro5. I simply created a blur bitmap for this effect. My steps: 1-) Draw backbuffer to blur using 2-) Clear backbuffer using 3-) Draw blur to backbuffer using 4-) Draw sprites to backbuffer 5-) Flip display But when my blurred pixels transparency goes 255, they become white. And i get something like this pictures.(fitsr pic is from starting of game. second picture is when im moving ... ) |
|
Trent Gamblin
Member #261
April 2000
|
1) clear your buffer to black at the start of the level/game Just make sure you draw an "opaque-enough" black rectangle to suit your desired trail length. Not sure a good way to get motion blur on some parts and not on others.
|
|
Todd Cope
Member #998
November 2000
|
I create a cheap motion blur effect for certain sprites in one of my games by taking a few "snapshots" of the sprite going back into the past and drawing them with a lower opacity the older they are. The "snapshot" consists of a pointer to the bitmap to draw, positioning data, and a timer used to calculate the opacity. |
|
tolgagerekci
Member #14,293
May 2012
|
I think you don't understand me. My code is: 1//-----INIT PART---------------
2
3ALLEGRO_BITMAP *tri = al_create_bitmap(al_get_bitmap_width(al_get_backbuffer(display)),al_get_bitmap_height(al_get_backbuffer(display)));
4
5ALLEGRO_BITMAP *blur = al_create_bitmap(al_get_bitmap_width(al_get_backbuffer(display)),al_get_bitmap_height(al_get_backbuffer(display)));
6
7al_set_target_bitmap(tri);
8
9al_clear_to_color(al_map_rgb(0,0,0));
10
11al_set_target_bitmap(blur);
12
13al_clear_to_color(al_map_rgb(0,0,0));
14
15al_set_target_bitmap(al_get_backbuffer(display));
16
17//-----DRAWING PART------------
18
19//---------------------------------------
20al_set_target_bitmap(blur);
21
22al_draw_tinted_bitmap(tri,al_map_rgba_f(1,1,1,0.95), 0, 0, 0);
23
24//----------------------------------------
25
26al_set_target_bitmap(tri);
27
28al_clear_to_color(al_map_rgba(0,0,0,255));
29
30al_draw_bitmap(blur,0,0,0);
31
32cam.StartCamera();
33
34int j = 0;
35for(j = 0; j < bullets.size(); j++)
36{
37 bullets[j]->Draw();
38}
39for(j = 0; j < enemybullets.size(); j++)
40{
41 enemybullets[j]->Draw();
42}
43spaceship.Draw();
44
45al_set_target_bitmap( al_get_backbuffer(display) );
46
47al_clear_to_color(al_map_rgb(0,0,0));
48
49al_draw_bitmap(tri,0,0,0);
50
51gamemenu->Draw();
52
53gameBar->Draw();
54
55mouse->Draw();
56
57al_flip_display();
How can i draw " translucent black rectangle" with Allegro 5? |
|
Todd Cope
Member #998
November 2000
|
al_draw_filled_rectangle(left, top, right, bottom, al_map_rgba_f(0.0, 0.0, 0.0, 0.5)); Replace the 0.5 with whatever value suits your needs. A lower value will produce more blurring. This works with fine with the default blender setting. |
|
tolgagerekci
Member #14,293
May 2012
|
Thanks thanks thanks million time thanks |
|
Hyena_
Member #8,852
July 2007
|
can you upload the screenshot of your result? I'd like to see motion blur in action using A5.
|
|
tolgagerekci
Member #14,293
May 2012
|
Results: Alpha values: First 80 |
|
|