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
al_draw_tinted_bitmap(backbuffer, al_map_rgba_f(1,1,1,0.95), 0, 0, 0);
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 ... )
http://www.allegro.cc/files/attachment/606036
http://www.allegro.cc/files/attachment/606037
1) clear your buffer to black at the start of the level/game
2) draw translucent black rectangle to the buffer
3) draw your sprites/scene to the buffer
4) draw the buffer to the screen backbuffer
5) repeat from step 2
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.
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.
I think you don't understand me. My code is:
How can i draw " translucent black rectangle" with Allegro 5?
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.
Thanks thanks thanks million time thanks
I really appreciate it.
can you upload the screenshot of your result? I'd like to see motion blur in action using A5.
Results:
{"name":"606044","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/5\/6\/56f38fab2ac52b5560e00f2700482d01.png","w":1297,"h":1038,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/5\/6\/56f38fab2ac52b5560e00f2700482d01"}
{"name":"606045","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/5\/9\/59b88b15447e45bca01c2728a5b5b3b3.png","w":1293,"h":997,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/5\/9\/59b88b15447e45bca01c2728a5b5b3b3"}
Alpha values:
First 80
Second 50